41 package com.sun.jmx.examples.scandir;
43 import java.lang.reflect.InvocationHandler;
44 import java.lang.reflect.Proxy;
45 import java.util.logging.Logger;
46 import javax.management.JMX;
47 import javax.management.MBeanServerConnection;
48 import javax.management.MBeanServerInvocationHandler;
49 import javax.management.NotificationEmitter;
50 import javax.management.ObjectName;
62 private static final Logger
LOG =
63 Logger.getLogger(
TestUtils.class.getName());
74 if (!(proxy instanceof Proxy))
75 throw new IllegalArgumentException(
"not a "+Proxy.class.getName());
76 final Proxy p = (Proxy) proxy;
77 final InvocationHandler handler =
78 Proxy.getInvocationHandler(proxy);
79 if (handler instanceof MBeanServerInvocationHandler)
80 return ((MBeanServerInvocationHandler)handler).
getObjectName();
81 throw new IllegalArgumentException(
"not a JMX Proxy");
90 Class<T> mbeanInterface) {
91 if (proxy instanceof NotificationEmitter)
93 if (proxy ==
null)
return null;
94 if (!(proxy instanceof Proxy))
95 throw new IllegalArgumentException(
"not a "+Proxy.class.getName());
96 final Proxy p = (Proxy) proxy;
97 final InvocationHandler handler =
98 Proxy.getInvocationHandler(proxy);
99 if (!(handler instanceof MBeanServerInvocationHandler))
100 throw new IllegalArgumentException(
"not a JMX Proxy");
101 final MBeanServerInvocationHandler h =
102 (MBeanServerInvocationHandler)handler;
103 final ObjectName
name = h.getObjectName();
104 final MBeanServerConnection mbs = h.getMBeanServerConnection();
105 final boolean isMXBean = h.isMXBean();
108 newProxy = JMX.newMXBeanProxy(mbs,
name,mbeanInterface,
true);
110 newProxy = JMX.newMBeanProxy(mbs,
name,mbeanInterface,
true);