1 22 package org.jboss.ejb3.service; 23 24 import java.lang.reflect.InvocationTargetException ; 25 import org.jboss.annotation.ejb.RemoteBinding; 26 import org.jboss.aop.Advisor; 27 import org.jboss.aop.AspectManager; 28 import org.jboss.aop.advice.AdviceStack; 29 import org.jboss.ejb3.JBossProxy; 30 import org.jboss.ejb3.ProxyFactoryHelper; 31 import org.jboss.ejb3.remoting.RemoteProxyFactory; 32 import org.jboss.remoting.InvokerLocator; 33 34 35 39 public class ServiceRemoteProxyFactory extends BaseServiceProxyFactory implements RemoteProxyFactory 40 { 41 private RemoteBinding binding; 42 private InvokerLocator locator; 43 44 public void setRemoteBinding(RemoteBinding binding) 45 { 46 this.binding = binding; 47 } 48 49 protected Class [] getInterfaces() 50 { 51 Class [] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container); 52 Class [] interfaces = new Class [remoteInterfaces.length + 1]; 53 System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length); 54 interfaces[remoteInterfaces.length] = JBossProxy.class; 55 return interfaces; 56 } 57 58 protected void initializeJndiName() 59 { 60 jndiName = ProxyFactoryHelper.getRemoteJndiName(container, binding); 61 } 62 63 public void start() throws Exception 64 { 65 String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding); 66 locator = new InvokerLocator(clientBindUrl); 67 super.start(); 68 } 69 70 public Object createProxy() 71 { 72 try 73 { 74 Object containerId = container.getObjectName().getCanonicalName(); 75 String stackName = "ServiceClientInterceptors"; 76 if (binding.interceptorStack() != null && !binding.interceptorStack().equals("")) 77 { 78 stackName = binding.interceptorStack(); 79 } 80 AdviceStack stack = AspectManager.instance().getAdviceStack(stackName); 81 Object [] args = {new ServiceRemoteProxy(containerId, stack.createInterceptors((Advisor) container, null), locator)}; 82 return proxyConstructor.newInstance(args); 83 } 84 catch (InstantiationException e) 85 { 86 throw new RuntimeException (e); } 88 catch (IllegalAccessException e) 89 { 90 throw new RuntimeException (e); } 92 catch (IllegalArgumentException e) 93 { 94 throw new RuntimeException (e); } 96 catch (InvocationTargetException e) 97 { 98 throw new RuntimeException (e.getTargetException()); } 100 } 101 102 } 103 | Popular Tags |