1 22 package org.jboss.naming.interceptors; 23 24 import javax.management.MBeanServer ; 25 import javax.management.ObjectName ; 26 27 import org.jboss.logging.Logger; 28 import org.jboss.mx.interceptor.AbstractInterceptor; 29 import org.jboss.mx.server.Invocation; 30 import org.jboss.mx.util.MBeanServerLocator; 31 import org.jnp.interfaces.Naming; 32 import org.jnp.interfaces.NamingContext; 33 34 40 public class ProxyFactoryInterceptor 41 extends AbstractInterceptor 42 { 43 private static Logger log = Logger.getLogger(ProxyFactoryInterceptor.class); 44 private String proxyName; 45 private Naming proxy; 46 47 public void setProxyName(String proxyName) 48 { 49 this.proxyName = proxyName; 50 } 51 52 public Object invoke(Invocation invocation) throws Throwable 54 { 55 Object value = invocation.nextInterceptor().invoke(invocation); 56 if( value instanceof NamingContext ) 57 { 58 initNamingProxy(); 59 NamingContext ctx = (NamingContext) value; 60 ctx.setNaming(proxy); 61 } 62 return value; 63 } 64 65 69 private void initNamingProxy() 70 throws Exception 71 { 72 if( proxy != null ) 73 return; 74 75 ObjectName proxyFactory = new ObjectName (proxyName); 76 MBeanServer server = MBeanServerLocator.locateJBoss(); 77 proxy = (Naming) server.getAttribute(proxyFactory, "Proxy"); 78 } 79 } 80 | Popular Tags |