author | dfuchs |
Wed, 10 Sep 2008 16:27:13 +0200 | |
changeset 1227 | 4546977d0d66 |
parent 1156 | bbc2d15aaf7a |
permissions | -rw-r--r-- |
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
1 |
/* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
4 |
* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
8 |
* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
13 |
* accompanied this code). |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
14 |
* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
18 |
* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
21 |
* have any questions. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
22 |
*/ |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
23 |
/* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
24 |
* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
25 |
* @test JMXDomainTest.java |
1227
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
1156
diff
changeset
|
26 |
* @bug 5072476 |
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
27 |
* @summary Basic test for JMXDomain. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
28 |
* @author Daniel Fuchs |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
29 |
* @run clean JMXDomainTest Wombat WombatMBean |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
30 |
* @run build JMXDomainTest Wombat WombatMBean |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
31 |
* @run main JMXDomainTest |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
32 |
*/ |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
33 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
34 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
35 |
import java.util.Collections; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
36 |
import java.util.concurrent.ArrayBlockingQueue; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
37 |
import java.util.concurrent.BlockingQueue; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
38 |
import java.util.concurrent.TimeUnit; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
39 |
import java.util.Map; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
40 |
import java.util.Set; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
41 |
import javax.management.Attribute; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
42 |
import javax.management.AttributeList; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
43 |
import javax.management.AttributeNotFoundException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
44 |
import javax.management.DynamicMBean; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
45 |
import javax.management.InstanceAlreadyExistsException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
46 |
import javax.management.InstanceNotFoundException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
47 |
import javax.management.InvalidAttributeValueException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
48 |
import javax.management.ListenerNotFoundException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
49 |
import javax.management.MBeanException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
50 |
import javax.management.MBeanInfo; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
51 |
import javax.management.MBeanNotificationInfo; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
52 |
import javax.management.MBeanRegistration; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
53 |
import javax.management.MBeanRegistrationException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
54 |
import javax.management.MBeanServer; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
55 |
import javax.management.MBeanServerDelegate; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
56 |
import javax.management.MBeanServerFactory; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
57 |
import javax.management.MBeanServerNotification; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
58 |
import javax.management.NotCompliantMBeanException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
59 |
import javax.management.Notification; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
60 |
import javax.management.NotificationBroadcaster; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
61 |
import javax.management.NotificationEmitter; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
62 |
import javax.management.NotificationFilter; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
63 |
import javax.management.NotificationListener; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
64 |
import javax.management.ObjectInstance; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
65 |
import javax.management.ObjectName; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
66 |
import javax.management.ReflectionException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
67 |
import javax.management.namespace.JMXDomain; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
68 |
import javax.management.namespace.MBeanServerSupport; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
69 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
70 |
/** |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
71 |
* Test simple creation/registration of namespace. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
72 |
* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
73 |
*/ |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
74 |
public class JMXDomainTest { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
75 |
private static Map<String,Object> emptyEnvMap() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
76 |
return Collections.emptyMap(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
77 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
78 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
79 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
80 |
public static class LocalDomainRepository |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
81 |
extends MBeanServerSupport { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
82 |
private final MBeanServer server; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
83 |
private final String domain; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
84 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
85 |
public class DynamicMBeanProxy implements DynamicMBean { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
86 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
87 |
private final MBeanServer server; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
88 |
private final ObjectName name; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
89 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
90 |
public DynamicMBeanProxy(MBeanServer s, ObjectName n) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
91 |
this.server = s; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
92 |
this.name = n; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
93 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
94 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
95 |
public Object getAttribute(String attribute) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
96 |
throws AttributeNotFoundException, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
97 |
MBeanException, ReflectionException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
98 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
99 |
return server.getAttribute(name, attribute); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
100 |
} catch (RuntimeException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
101 |
throw x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
102 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
103 |
throw new RuntimeException(x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
104 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
105 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
106 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
107 |
public void setAttribute(Attribute attribute) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
108 |
throws AttributeNotFoundException, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
109 |
InvalidAttributeValueException, MBeanException, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
110 |
ReflectionException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
111 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
112 |
server.setAttribute(name, attribute); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
113 |
} catch (RuntimeException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
114 |
throw x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
115 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
116 |
throw new RuntimeException(x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
117 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
118 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
119 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
120 |
public AttributeList getAttributes(String[] attributes) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
121 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
122 |
return server.getAttributes(name, attributes); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
123 |
} catch (RuntimeException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
124 |
throw x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
125 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
126 |
throw new RuntimeException(x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
127 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
128 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
129 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
130 |
public AttributeList setAttributes(AttributeList attributes) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
131 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
132 |
return server.setAttributes(name, attributes); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
133 |
} catch (RuntimeException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
134 |
throw x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
135 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
136 |
throw new RuntimeException(x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
137 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
138 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
139 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
140 |
public Object invoke(String actionName, Object[] params, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
141 |
String[] signature) throws MBeanException, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
142 |
ReflectionException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
143 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
144 |
return server.invoke(name, actionName, params, signature); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
145 |
} catch (RuntimeException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
146 |
throw x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
147 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
148 |
throw new RuntimeException(x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
149 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
150 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
151 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
152 |
public MBeanInfo getMBeanInfo() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
153 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
154 |
return server.getMBeanInfo(name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
155 |
} catch (RuntimeException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
156 |
throw x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
157 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
158 |
throw new RuntimeException(x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
159 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
160 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
161 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
162 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
163 |
public LocalDomainRepository(String domain) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
164 |
this.server = MBeanServerFactory.newMBeanServer(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
165 |
this.domain = domain; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
166 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
167 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
168 |
@Override |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
169 |
protected Set<ObjectName> getNames() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
170 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
171 |
final ObjectName name = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
172 |
ObjectName.getInstance(domain+":*"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
173 |
return server.queryNames(name, null); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
174 |
} catch (RuntimeException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
175 |
throw x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
176 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
177 |
throw new RuntimeException(x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
178 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
179 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
180 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
181 |
@Override |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
182 |
public DynamicMBean getDynamicMBeanFor(ObjectName name) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
183 |
throws InstanceNotFoundException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
184 |
if (server.isRegistered(name)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
185 |
return new DynamicMBeanProxy(server, name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
186 |
throw new InstanceNotFoundException(name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
187 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
188 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
189 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
190 |
@Override |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
191 |
public NotificationEmitter |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
192 |
getNotificationEmitterFor(final ObjectName name) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
193 |
throws InstanceNotFoundException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
194 |
if (server.isInstanceOf(name, NotificationEmitter.class.getName())) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
195 |
return new NotificationEmitter() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
196 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
197 |
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
198 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
199 |
server.removeNotificationListener(name, listener, filter, handback); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
200 |
} catch (InstanceNotFoundException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
201 |
throw new IllegalArgumentException(String.valueOf(name), x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
202 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
203 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
204 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
205 |
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
206 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
207 |
server.addNotificationListener(name, listener, filter, handback); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
208 |
} catch (InstanceNotFoundException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
209 |
throw new IllegalArgumentException(String.valueOf(name), x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
210 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
211 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
212 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
213 |
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
214 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
215 |
server.removeNotificationListener(name, listener); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
216 |
} catch (InstanceNotFoundException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
217 |
throw new IllegalArgumentException(String.valueOf(name), x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
218 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
219 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
220 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
221 |
public MBeanNotificationInfo[] getNotificationInfo() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
222 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
223 |
return server.getMBeanInfo(name).getNotifications(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
224 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
225 |
throw new IllegalArgumentException(String.valueOf(name), x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
226 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
227 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
228 |
}; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
229 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
230 |
return null; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
231 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
232 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
233 |
@Override |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
234 |
public ObjectInstance registerMBean(Object object, ObjectName name) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
235 |
throws InstanceAlreadyExistsException, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
236 |
MBeanRegistrationException, NotCompliantMBeanException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
237 |
return server.registerMBean(object, name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
238 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
239 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
240 |
@Override |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
241 |
public void unregisterMBean(ObjectName name) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
242 |
throws InstanceNotFoundException, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
243 |
MBeanRegistrationException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
244 |
server.unregisterMBean(name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
245 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
246 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
247 |
@Override |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
248 |
public ObjectInstance createMBean(String className, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
249 |
ObjectName name, ObjectName loaderName, Object[] params, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
250 |
String[] signature, boolean useCLR) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
251 |
throws ReflectionException, InstanceAlreadyExistsException, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
252 |
MBeanRegistrationException, MBeanException, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
253 |
NotCompliantMBeanException, InstanceNotFoundException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
254 |
if (useCLR && loaderName == null) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
255 |
return server.createMBean(className, name, params, signature); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
256 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
257 |
return server.createMBean(className, name, loaderName, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
258 |
params, signature); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
259 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
260 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
261 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
262 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
263 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
264 |
private static MBeanServer newMBeanServer() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
265 |
return MBeanServerFactory.newMBeanServer(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
266 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
267 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
268 |
public static interface ThingMBean {} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
269 |
public static class Thing implements ThingMBean, MBeanRegistration { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
270 |
public ObjectName preRegister(MBeanServer server, ObjectName name) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
271 |
throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
272 |
if (name == null) return new ObjectName(":type=Thing"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
273 |
else return name; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
274 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
275 |
public void postRegister(Boolean registrationDone) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
276 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
277 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
278 |
public void preDeregister() throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
279 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
280 |
public void postDeregister() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
281 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
282 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
283 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
284 |
/** |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
285 |
* Test that it is possible to create a dummy MBean with a null |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
286 |
* ObjectName - this is just a sanity check - as there are already |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
287 |
* other JMX tests that check that. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
288 |
* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
289 |
* @throws java.lang.Exception |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
290 |
*/ |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
291 |
public static void testCreateWithNull() throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
292 |
final MBeanServer server = newMBeanServer(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
293 |
final ObjectInstance oi = server.registerMBean(new Thing(),null); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
294 |
server.unregisterMBean(oi.getObjectName()); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
295 |
System.out.println("testCreateWithNull PASSED"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
296 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
297 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
298 |
public static void testRegisterSimple() throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
299 |
final ObjectName name = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
300 |
JMXDomain.getDomainObjectName("gloups"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
301 |
final JMXDomain jmxDomain = new JMXDomain( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
302 |
MBeanServerFactory.newMBeanServer()); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
303 |
testRegister("testRegisterSimple: ",name,jmxDomain); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
304 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
305 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
306 |
public static void testRegisterPseudoVirtual() |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
307 |
throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
308 |
final ObjectName name = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
309 |
JMXDomain.getDomainObjectName("gloups"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
310 |
final JMXDomain jmxDomain = new JMXDomain( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
311 |
new LocalDomainRepository("gloups")); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
312 |
testRegister("testRegisterPseudoVirtual: ",name,jmxDomain); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
313 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
314 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
315 |
public static void testRegister(final String test, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
316 |
final ObjectName name, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
317 |
final JMXDomain jmxDomain) throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
318 |
System.out.println(test+" START"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
319 |
MBeanServer server = newMBeanServer(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
320 |
final ObjectInstance oi = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
321 |
server.registerMBean(jmxDomain,name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
322 |
System.out.println(test+"Succesfully registered namespace: "+name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
323 |
if (!server.isRegistered(name)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
324 |
fail(test+name+" is not registered!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
325 |
if (!server.queryNames(new ObjectName(name.getDomain()+":*"), null). |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
326 |
contains(name)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
327 |
fail(test+name+" not in queryNames"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
328 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
329 |
final Thing thing = new Thing(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
330 |
final ObjectName thingName = new ObjectName("gloups:type=Thing"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
331 |
server.registerMBean(thing,thingName); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
332 |
if (!server.isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
333 |
fail(test+thingName+" is not registered!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
334 |
if (!jmxDomain.getSourceServer().isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
335 |
fail(test+thingName+" is not registered in domain!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
336 |
if (!server.queryNames(new ObjectName(name.getDomain()+":*"), null). |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
337 |
contains(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
338 |
fail(test+thingName+" not in queryNames"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
339 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
340 |
server.unregisterMBean(name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
341 |
if (server.isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
342 |
fail(test+thingName+" is still registered!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
343 |
if (server.queryNames(new ObjectName(name.getDomain()+":*"), null). |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
344 |
contains(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
345 |
fail(test+thingName+" still in queryNames"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
346 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
347 |
server.registerMBean(jmxDomain, name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
348 |
if (!server.isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
349 |
fail(test+thingName+" is not registered again!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
350 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
351 |
System.out.println(test+" PASSED"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
352 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
353 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
354 |
private static MBeanServerNotification pop( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
355 |
BlockingQueue<Notification> queue, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
356 |
String type, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
357 |
ObjectName mbean, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
358 |
String test) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
359 |
throws InterruptedException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
360 |
final Notification n = queue.poll(1, TimeUnit.SECONDS); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
361 |
if (!(n instanceof MBeanServerNotification)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
362 |
fail(test+"expected MBeanServerNotification, got "+n); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
363 |
final MBeanServerNotification msn = (MBeanServerNotification)n; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
364 |
if (!type.equals(msn.getType())) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
365 |
fail(test+"expected "+type+", got "+msn.getType()); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
366 |
if (!mbean.apply(msn.getMBeanName())) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
367 |
fail(test+"expected "+mbean+", got "+msn.getMBeanName()); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
368 |
System.out.println(test+" got: "+msn); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
369 |
return msn; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
370 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
371 |
private static MBeanServerNotification popADD( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
372 |
BlockingQueue<Notification> queue, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
373 |
ObjectName mbean, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
374 |
String test) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
375 |
throws InterruptedException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
376 |
return pop(queue, MBeanServerNotification.REGISTRATION_NOTIFICATION, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
377 |
mbean, test); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
378 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
379 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
380 |
private static MBeanServerNotification popREM( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
381 |
BlockingQueue<Notification> queue, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
382 |
ObjectName mbean, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
383 |
String test) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
384 |
throws InterruptedException { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
385 |
return pop(queue, MBeanServerNotification.UNREGISTRATION_NOTIFICATION, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
386 |
mbean, test); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
387 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
388 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
389 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
390 |
public static void testRegisterNotifSimple() throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
391 |
final ObjectName name = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
392 |
JMXDomain.getDomainObjectName("gloups"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
393 |
final JMXDomain jmxDomain = new JMXDomain( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
394 |
MBeanServerFactory.newMBeanServer()); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
395 |
testRegisterNotif("testRegisterNotifSimple: ",name,jmxDomain); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
396 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
397 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
398 |
public static void testRegisterNotifPseudoVirtual() |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
399 |
throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
400 |
final ObjectName name = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
401 |
JMXDomain.getDomainObjectName("gloups"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
402 |
final JMXDomain jmxDomain = new JMXDomain( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
403 |
new LocalDomainRepository("gloups")); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
404 |
testRegisterNotif("testRegisterNotifPseudoVirtual: ",name,jmxDomain); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
405 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
406 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
407 |
public static void testRegisterNotif(final String test, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
408 |
final ObjectName name, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
409 |
final JMXDomain jmxDomain) throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
410 |
System.out.println(test+" START"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
411 |
MBeanServer server = newMBeanServer(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
412 |
final ObjectInstance oi = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
413 |
server.registerMBean(jmxDomain,name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
414 |
System.out.println(test+"Succesfully registered namespace: "+name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
415 |
if (!server.isRegistered(name)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
416 |
fail(test+name+" is not registered!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
417 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
418 |
final BlockingQueue<Notification> queue = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
419 |
new ArrayBlockingQueue<Notification>(10); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
420 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
421 |
final NotificationListener l = new NotificationListener() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
422 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
423 |
public void handleNotification(Notification notification, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
424 |
Object handback) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
425 |
try { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
426 |
if (!queue.offer(notification,5,TimeUnit.SECONDS)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
427 |
throw new RuntimeException("timeout exceeded"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
428 |
} catch (Exception x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
429 |
fail(test+"failed to handle notif", x); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
430 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
431 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
432 |
}; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
433 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
434 |
server.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, l, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
435 |
null, null); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
436 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
437 |
final Thing thing = new Thing(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
438 |
final ObjectName thingName = new ObjectName("gloups:type=Thing"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
439 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
440 |
server.registerMBean(thing,thingName); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
441 |
if (!jmxDomain.getSourceServer().isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
442 |
fail(test+thingName+" is not registered in domain!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
443 |
popADD(queue, thingName, test); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
444 |
server.unregisterMBean(thingName); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
445 |
if (jmxDomain.getSourceServer().isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
446 |
fail(test+thingName+" is still registered in domain!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
447 |
popREM(queue, thingName, test); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
448 |
if (queue.size() != 0) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
449 |
fail(test+queue.size()+" notifs remain in queue "+queue); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
450 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
451 |
server.unregisterMBean(name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
452 |
popREM(queue, name, test); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
453 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
454 |
jmxDomain.getSourceServer().registerMBean(thing,thingName); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
455 |
if (server.isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
456 |
fail(test+thingName+" is still registered in domain!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
457 |
jmxDomain.getSourceServer().unregisterMBean(thingName); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
458 |
if (queue.size() != 0) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
459 |
fail(test+queue.size()+" notifs remain in queue "+queue); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
460 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
461 |
server.registerMBean(jmxDomain, name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
462 |
if (!server.isRegistered(name)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
463 |
fail(test+name+" is not registered again!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
464 |
popADD(queue, name, test); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
465 |
if (queue.size() != 0) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
466 |
fail(test+queue.size()+" notifs remain in queue "+queue); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
467 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
468 |
server.registerMBean(thing,thingName); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
469 |
if (!jmxDomain.getSourceServer().isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
470 |
fail(test+thingName+" is not registered in domain!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
471 |
popADD(queue, thingName, test); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
472 |
server.unregisterMBean(thingName); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
473 |
if (jmxDomain.getSourceServer().isRegistered(thingName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
474 |
fail(test+thingName+" is still registered in domain!"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
475 |
popREM(queue, thingName, test); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
476 |
if (queue.size() != 0) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
477 |
fail(test+queue.size()+" notifs remain in queue "+queue); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
478 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
479 |
System.out.println(test+" PASSED"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
480 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
481 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
482 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
483 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
484 |
private static void fail(String msg) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
485 |
raise(new RuntimeException(msg)); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
486 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
487 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
488 |
private static void fail(String msg, Throwable cause) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
489 |
raise(new RuntimeException(msg,cause)); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
490 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
491 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
492 |
private static void raise(RuntimeException x) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
493 |
lastException = x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
494 |
exceptionCount++; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
495 |
throw x; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
496 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
497 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
498 |
private static volatile Exception lastException = null; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
499 |
private static volatile int exceptionCount = 0; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
500 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
501 |
public static void main(String... args) throws Exception { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
502 |
testCreateWithNull(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
503 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
504 |
testRegisterSimple(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
505 |
testRegisterNotifSimple(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
506 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
507 |
testRegisterPseudoVirtual(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
508 |
testRegisterNotifPseudoVirtual(); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
509 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
510 |
if (lastException != null) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
511 |
throw lastException; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
512 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
diff
changeset
|
513 |
} |