jdk/test/javax/management/MBeanServer/DynamicWrapperMBeanTest.java
author emcmanus
Thu, 27 Nov 2008 15:44:32 +0100
changeset 1636 eb801ce73ac9
parent 1247 b4c26443dee5
permissions -rw-r--r--
6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection Reviewed-by: dfuchs, jfdenise
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
     1
/*
1247
b4c26443dee5 6754988: Update copyright year
xdono
parents: 1004
diff changeset
     2
 * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
     4
 *
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
     8
 *
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    13
 * accompanied this code).
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    14
 *
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    18
 *
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    21
 * have any questions.
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    22
 */
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    23
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    24
/*
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    25
 * @test DynamicWrapperMBeanTest
1636
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    26
 * @bug 6624232 6776225
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    27
 * @summary Test the DynamicWrapperMBean interface
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    28
 * @author Eamonn McManus
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    29
 */
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    30
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    31
import java.lang.management.ManagementFactory;
1636
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    32
import javax.annotation.Resource;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    33
import javax.management.JMX;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    34
import javax.management.ListenerNotFoundException;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    35
import javax.management.MBeanNotificationInfo;
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    36
import javax.management.MBeanServer;
1636
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    37
import javax.management.Notification;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    38
import javax.management.NotificationBroadcaster;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    39
import javax.management.NotificationBroadcasterSupport;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    40
import javax.management.NotificationEmitter;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    41
import javax.management.NotificationFilter;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    42
import javax.management.NotificationInfo;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    43
import javax.management.NotificationListener;
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    44
import javax.management.ObjectName;
1636
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    45
import javax.management.SendNotification;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    46
import javax.management.StandardEmitterMBean;
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    47
import javax.management.StandardMBean;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    48
import javax.management.modelmbean.ModelMBeanInfo;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    49
import javax.management.modelmbean.ModelMBeanInfoSupport;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    50
import javax.management.modelmbean.ModelMBeanOperationInfo;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    51
import javax.management.modelmbean.RequiredModelMBean;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    52
import static javax.management.StandardMBean.Options;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    53
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    54
public class DynamicWrapperMBeanTest {
1636
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    55
    private static String failure;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    56
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    57
    public static void main(String[] args) throws Exception {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    58
        wrapTest();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    59
        notifTest();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    60
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    61
        if (failure == null)
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    62
            System.out.println("TEST PASSED");
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    63
        else
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    64
            throw new Exception("TEST FAILED: " + failure);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    65
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    66
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    67
    private static final Options wrappedVisOpts = new Options();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    68
    private static final Options wrappedInvisOpts = new Options();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    69
    static {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    70
        wrappedVisOpts.setWrappedObjectVisible(true);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    71
        wrappedInvisOpts.setWrappedObjectVisible(false);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    72
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    73
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    74
    public static interface WrappedMBean {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    75
        public void sayHello();
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    76
    }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    77
    public static class Wrapped implements WrappedMBean {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    78
        public void sayHello() {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    79
            System.out.println("Hello");
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    80
        }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    81
    }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    82
1636
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
    83
    private static void wrapTest() throws Exception {
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    84
        if (Wrapped.class.getClassLoader() ==
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    85
                StandardMBean.class.getClassLoader()) {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    86
            throw new Exception(
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    87
                    "TEST ERROR: Resource and StandardMBean have same ClassLoader");
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    88
        }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    89
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    90
        assertEquals("Options withWrappedObjectVisible(false)",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    91
                     new Options(), wrappedInvisOpts);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    92
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    93
        Wrapped resource = new Wrapped();
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    94
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    95
        StandardMBean visible =
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    96
                new StandardMBean(resource, WrappedMBean.class, wrappedVisOpts);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    97
        StandardMBean invisible =
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    98
                new StandardMBean(resource, WrappedMBean.class, wrappedInvisOpts);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
    99
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   100
        assertEquals("getResource withWrappedObjectVisible(true)",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   101
                resource, visible.getWrappedObject());
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   102
        assertEquals("getResource withWrappedObjectVisible(false)",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   103
                invisible, invisible.getWrappedObject());
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   104
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   105
        System.out.println("===Testing StandardMBean===");
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   106
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   107
        ObjectName visibleName = new ObjectName("a:type=visible");
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   108
        ObjectName invisibleName = new ObjectName("a:type=invisible");
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   109
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   110
        mbs.registerMBean(visible, visibleName);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   111
        mbs.registerMBean(invisible, invisibleName);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   112
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   113
        assertEquals("ClassLoader for visible resource",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   114
                Wrapped.class.getClassLoader(),
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   115
                mbs.getClassLoaderFor(visibleName));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   116
        assertEquals("ClassLoader for invisible resource",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   117
                StandardMBean.class.getClassLoader(),
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   118
                mbs.getClassLoaderFor(invisibleName));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   119
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   120
        assertEquals("isInstanceOf(WrappedMBean) for visible wrapped",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   121
                true, mbs.isInstanceOf(visibleName, WrappedMBean.class.getName()));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   122
        assertEquals("isInstanceOf(WrappedMBean) for invisible wrapped",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   123
                false, mbs.isInstanceOf(invisibleName, WrappedMBean.class.getName()));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   124
        assertEquals("isInstanceOf(StandardMBean) for visible wrapped",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   125
                false, mbs.isInstanceOf(visibleName, StandardMBean.class.getName()));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   126
        assertEquals("isInstanceOf(StandardMBean) for invisible wrapped",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   127
                true, mbs.isInstanceOf(invisibleName, StandardMBean.class.getName()));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   128
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   129
        mbs.unregisterMBean(visibleName);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   130
        mbs.unregisterMBean(invisibleName);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   131
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   132
        System.out.println("===Testing RequiredModelMBean===");
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   133
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   134
        // Godawful Model MBeans...
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   135
        ModelMBeanOperationInfo mmboi = new ModelMBeanOperationInfo(
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   136
                "say hello to the nice man", Wrapped.class.getMethod("sayHello"));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   137
        ModelMBeanInfo visibleMmbi = new ModelMBeanInfoSupport(
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   138
                Wrapped.class.getName(), "Visible wrapped", null, null,
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   139
                new ModelMBeanOperationInfo[] {mmboi}, null);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   140
        ModelMBeanInfo invisibleMmbi = new ModelMBeanInfoSupport(
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   141
                Wrapped.class.getName(), "Invisible wrapped", null, null,
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   142
                new ModelMBeanOperationInfo[] {mmboi}, null);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   143
        RequiredModelMBean visibleRmmb = new RequiredModelMBean(visibleMmbi);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   144
        RequiredModelMBean invisibleRmmb = new RequiredModelMBean(invisibleMmbi);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   145
        visibleRmmb.setManagedResource(resource, "VisibleObjectReference");
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   146
        invisibleRmmb.setManagedResource(resource, "ObjectReference");
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   147
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   148
        mbs.registerMBean(visibleRmmb, visibleName);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   149
        mbs.registerMBean(invisibleRmmb, invisibleName);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   150
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   151
        assertEquals("ClassLoader for visible wrapped",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   152
                Wrapped.class.getClassLoader(),
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   153
                mbs.getClassLoaderFor(visibleName));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   154
        assertEquals("ClassLoader for invisible wrapped",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   155
                StandardMBean.class.getClassLoader(),
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   156
                mbs.getClassLoaderFor(invisibleName));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   157
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   158
        assertEquals("isInstanceOf(WrappedMBean) for visible resource",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   159
                true, mbs.isInstanceOf(visibleName, WrappedMBean.class.getName()));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   160
        assertEquals("isInstanceOf(WrappedMBean) for invisible resource",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   161
                false, mbs.isInstanceOf(invisibleName, WrappedMBean.class.getName()));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   162
        assertEquals("isInstanceOf(RequiredModelMBean) for visible resource",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   163
                false, mbs.isInstanceOf(visibleName, RequiredModelMBean.class.getName()));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   164
        assertEquals("isInstanceOf(RequiredModelMBean) for invisible resource",
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   165
                true, mbs.isInstanceOf(invisibleName, RequiredModelMBean.class.getName()));
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   166
1636
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   167
        mbs.unregisterMBean(visibleName);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   168
        mbs.unregisterMBean(invisibleName);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   169
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   170
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   171
    private static enum WrapType {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   172
        NBS("NotificationBroadcasterSupport"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   173
        INJ("@Resource SendNotification"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   174
        STD_MBEAN_NBS("StandardMBean delegating to NotificationBroadcasterSupport"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   175
        STD_MBEAN_INJ("StandardMBean delegating to @Resource SendNotification"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   176
        STD_MBEAN_SUB_NBS("StandardMBean subclass implementing NotificationBroadcaster"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   177
        STD_MBEAN_SUB_INJ("StandardMBean subclass with @Resource SendNotification"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   178
        STD_EMIT_MBEAN_NBS("StandardEmitterMBean delegating to NotificationBroadcasterSupport"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   179
        STD_EMIT_MBEAN_INJ("StandardEmitterMBean delegating to @Resource SendNotification"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   180
        STD_EMIT_MBEAN_SUB("StandardEmitterMBean subclass"),
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   181
        STD_EMIT_MBEAN_SUB_INJ("StandardEmitterMBean subclass with @Resource SendNotification");
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   182
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   183
        WrapType(String s) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   184
            this.s = s;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   185
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   186
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   187
        @Override
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   188
        public String toString() {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   189
            return s;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   190
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   191
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   192
        private final String s;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   193
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   194
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   195
    @NotificationInfo(
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   196
        types = {"foo", "bar"}
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   197
    )
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   198
    public static interface BroadcasterMBean {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   199
        public void send(Notification n);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   200
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   201
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   202
    public static class Broadcaster
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   203
            extends NotificationBroadcasterSupport implements BroadcasterMBean {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   204
        public void send(Notification n) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   205
            super.sendNotification(n);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   206
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   207
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   208
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   209
    public static interface SendNotifMBean extends BroadcasterMBean {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   210
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   211
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   212
    public static class SendNotif implements SendNotifMBean {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   213
        @Resource
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   214
        private volatile SendNotification sendNotif;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   215
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   216
        public void send(Notification n) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   217
            sendNotif.sendNotification(n);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   218
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   219
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   220
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   221
    public static class StdBroadcaster
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   222
            extends StandardMBean
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   223
            implements BroadcasterMBean, NotificationBroadcaster {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   224
        private final NotificationBroadcasterSupport nbs =
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   225
                new NotificationBroadcasterSupport();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   226
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   227
        public StdBroadcaster() throws Exception {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   228
            super(BroadcasterMBean.class);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   229
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   230
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   231
        public void send(Notification n) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   232
            nbs.sendNotification(n);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   233
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   234
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   235
        public void addNotificationListener(NotificationListener listener,
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   236
                NotificationFilter filter, Object handback) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   237
            nbs.addNotificationListener(listener, filter, handback);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   238
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   239
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   240
        public MBeanNotificationInfo[] getNotificationInfo() {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   241
            return null;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   242
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   243
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   244
        public void removeNotificationListener(NotificationListener listener)
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   245
                throws ListenerNotFoundException {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   246
            nbs.removeNotificationListener(listener);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   247
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   248
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   249
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   250
    public static class StdSendNotif
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   251
            extends StandardMBean implements SendNotifMBean {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   252
        @Resource
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   253
        private volatile SendNotification sendNotif;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   254
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   255
        public StdSendNotif() throws Exception {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   256
            super(SendNotifMBean.class);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   257
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   258
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   259
        public void send(Notification n) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   260
            sendNotif.sendNotification(n);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   261
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   262
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   263
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   264
    public static class StdEmitterBroadcaster // :-)
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   265
            extends StandardEmitterMBean
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   266
            implements BroadcasterMBean {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   267
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   268
        public StdEmitterBroadcaster() throws Exception {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   269
            super(BroadcasterMBean.class, null);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   270
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   271
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   272
        public void send(Notification n) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   273
            super.sendNotification(n);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   274
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   275
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   276
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   277
    // This case is unlikely - if you're using @Resource SendNotification
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   278
    // then there's no point in using StandardEmitterMBean, since
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   279
    // StandardMBean would suffice.
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   280
    public static class StdEmitterSendNotif
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   281
            extends StandardEmitterMBean implements SendNotifMBean {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   282
        @Resource
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   283
        private volatile SendNotification sendNotif;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   284
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   285
        public StdEmitterSendNotif() {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   286
            super(SendNotifMBean.class, null);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   287
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   288
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   289
        public void send(Notification n) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   290
            sendNotif.sendNotification(n);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   291
        }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   292
    }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   293
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   294
    // Test that JMX.isNotificationSource and
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   295
    // mbs.isInstanceOf("NotificationBroadcaster") work correctly even when
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   296
    // the MBean is a broadcaster by virtue of its wrapped resource.
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   297
    // Test that we find the MBeanNotificationInfo[] from the @NotificationInfo
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   298
    // annotation on BroadcasterMBean.  We cover a large number of different
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   299
    // MBean types, but all ultimately implement that interface.
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   300
    private static void notifTest() throws Exception {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   301
        System.out.println("===Testing notification senders===");
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   302
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   303
        for (WrapType wrapType : WrapType.values()) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   304
            System.out.println("---" + wrapType);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   305
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   306
            final Object mbean;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   307
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   308
            switch (wrapType) {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   309
            case NBS:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   310
                // An MBean that extends NotificationBroadcasterSupport
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   311
                mbean = new Broadcaster();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   312
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   313
            case INJ:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   314
                // An MBean that injects SendNotification
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   315
                mbean = new SendNotif();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   316
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   317
            case STD_MBEAN_NBS:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   318
                // A StandardMBean that delegates to a NotificationBroadcasterSupport
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   319
                mbean = new StandardMBean(
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   320
                        new Broadcaster(), BroadcasterMBean.class, wrappedVisOpts);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   321
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   322
            case STD_MBEAN_INJ:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   323
                // A StandardMBean that delegates to an object that injects
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   324
                // SendNotification
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   325
                mbean = new StandardMBean(
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   326
                        new SendNotif(), BroadcasterMBean.class, wrappedVisOpts);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   327
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   328
            case STD_EMIT_MBEAN_NBS: {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   329
                // A StandardEmitterMBean that delegates to a NotificationBroadcasterSupport
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   330
                Broadcaster broadcaster = new Broadcaster();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   331
                mbean = new StandardEmitterMBean(
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   332
                        broadcaster, BroadcasterMBean.class, wrappedVisOpts,
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   333
                        broadcaster);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   334
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   335
            }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   336
            case STD_EMIT_MBEAN_INJ: {
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   337
                // A StandardEmitterMBean that delegates to an object that injects
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   338
                // SendNotification
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   339
                SendNotif sendNotif = new SendNotif();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   340
                mbean = new StandardEmitterMBean(
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   341
                        sendNotif, BroadcasterMBean.class, wrappedVisOpts,
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   342
                        null);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   343
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   344
            }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   345
            case STD_MBEAN_SUB_NBS:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   346
                // A subclass of StandardMBean that implements NotificationBroadcaster
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   347
                mbean = new StdBroadcaster();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   348
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   349
            case STD_MBEAN_SUB_INJ:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   350
                // A subclass of StandardMBean that injects SendNotification
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   351
                mbean = new StdSendNotif();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   352
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   353
            case STD_EMIT_MBEAN_SUB:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   354
                // A subclass of StandardEmitterMBean
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   355
                mbean = new StdEmitterBroadcaster();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   356
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   357
            case STD_EMIT_MBEAN_SUB_INJ:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   358
                // A subclass of StandardEmitterMBean that injects SendNotification
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   359
                // (which is a rather strange thing to do and probably a user
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   360
                // misunderstanding but we should do the right thing anyway).
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   361
                mbean = new StdEmitterSendNotif();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   362
                break;
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   363
            default:
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   364
                throw new AssertionError();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   365
            }
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   366
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   367
            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   368
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   369
            final ObjectName name = new ObjectName("a:type=Sender");
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   370
            mbs.registerMBean(mbean, name);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   371
            boolean isBroadcaster = mbs.isInstanceOf(
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   372
                    name, NotificationBroadcaster.class.getName());
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   373
            assertEquals("JMX.isNotificationSource(mbean)",
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   374
                    true, JMX.isNotificationSource(mbean));
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   375
            assertEquals("isInstanceOf(NotificationBroadcaster)",
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   376
                    true, isBroadcaster);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   377
            MBeanNotificationInfo[] mbnis =
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   378
                    mbs.getMBeanInfo(name).getNotifications();
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   379
            assertEquals("MBeanNotificationInfo not empty",
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   380
                    true, (mbnis.length > 0));
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   381
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   382
            mbs.unregisterMBean(name);
eb801ce73ac9 6776225: JMX.isNotificationSource wrong when DynamicWrapperMBean + SendNotification injection
emcmanus
parents: 1247
diff changeset
   383
        }
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   384
    }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   385
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   386
    private static void assertEquals(String what, Object expect, Object actual) {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   387
        if (equal(expect, actual))
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   388
            System.out.println("OK: " + what + " = " + expect);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   389
        else
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   390
            fail(what + " should be " + expect + ", is " + actual);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   391
    }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   392
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   393
    private static boolean equal(Object x, Object y) {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   394
        if (x == y)
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   395
            return true;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   396
        if (x == null || y == null)
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   397
            return false;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   398
        return x.equals(y);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   399
    }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   400
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   401
    private static void fail(String why) {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   402
        failure = why;
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   403
        System.out.println("FAIL: " + why);
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   404
    }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents:
diff changeset
   405
}