1 16 17 package org.springframework.jmx.access; 18 19 import org.springframework.aop.framework.ProxyFactory; 20 import org.springframework.beans.factory.BeanClassLoaderAware; 21 import org.springframework.beans.factory.FactoryBean; 22 import org.springframework.beans.factory.InitializingBean; 23 import org.springframework.jmx.MBeanServerNotFoundException; 24 import org.springframework.util.ClassUtils; 25 26 51 public class MBeanProxyFactoryBean extends MBeanClientInterceptor 52 implements FactoryBean, BeanClassLoaderAware, InitializingBean { 53 54 private Class proxyInterface; 55 56 private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); 57 58 private Object mbeanProxy; 59 60 61 68 public void setProxyInterface(Class managementInterface) { 69 this.proxyInterface = managementInterface; 70 } 71 72 public void setBeanClassLoader(ClassLoader classLoader) { 73 this.beanClassLoader = classLoader; 74 } 75 76 80 public void afterPropertiesSet() throws MBeanServerNotFoundException, MBeanInfoRetrievalException { 81 super.afterPropertiesSet(); 82 83 if (this.proxyInterface == null) { 84 throw new IllegalArgumentException ("Property 'proxyInterface' is required"); 85 } 86 this.mbeanProxy = new ProxyFactory(this.proxyInterface, this).getProxy(this.beanClassLoader); 87 } 88 89 90 public Object getObject() { 91 return this.mbeanProxy; 92 } 93 94 public Class getObjectType() { 95 return this.proxyInterface; 96 } 97 98 public boolean isSingleton() { 99 return true; 100 } 101 102 } 103 | Popular Tags |