1 17 18 package org.sape.carbon.services.jmx.server.mx4j; 19 20 import java.lang.reflect.Method ; 21 import java.lang.reflect.Proxy ; 22 23 import javax.management.MBeanServer ; 24 25 import org.sape.carbon.core.util.reflection.GenericProxy; 26 27 import mx4j.connector.RemoteMBeanServer; 28 29 37 public class RemoteMBeanServerProxy extends GenericProxy { 38 41 private RemoteMBeanServer remoteServer; 42 43 46 private static final Class [] INTERFACES = {MBeanServer .class}; 47 48 53 public RemoteMBeanServerProxy(RemoteMBeanServer remoteServer) { 54 this.remoteServer = remoteServer; 55 } 56 57 66 protected Object handleInvoke( 67 Object proxy, Method m, Object [] args) 68 throws Throwable { 69 70 Class serverClass = 71 RemoteMBeanServer.class; 73 Method method = 74 serverClass.getMethod(m.getName(), m.getParameterTypes()); 75 76 return method.invoke(this.remoteServer, args); 77 } 78 79 85 public static MBeanServer buildServerProxy(RemoteMBeanServer server) { 86 Object proxy = 87 Proxy.newProxyInstance( 88 RemoteMBeanServerProxy.class.getClassLoader(), 89 RemoteMBeanServerProxy.INTERFACES, 90 new RemoteMBeanServerProxy(server)); 91 92 return (MBeanServer ) proxy; 93 } 94 } 95 | Popular Tags |