1 22 package org.jboss.ejb3.stateless; 23 24 import java.lang.reflect.InvocationTargetException ; 25 import javax.ejb.LocalHome ; 26 import org.jboss.annotation.ejb.LocalBinding; 27 import org.jboss.ejb3.JBossProxy; 28 import org.jboss.ejb3.NonSerializableFactory; 29 import org.jboss.ejb3.ProxyFactoryHelper; 30 31 32 38 public class StatelessLocalProxyFactory extends BaseStatelessProxyFactory 39 { 40 protected Class [] getInterfaces() 41 { 42 Class [] interfaces; 43 44 Class [] localInterfaces = ProxyFactoryHelper.getLocalInterfaces(container); 45 StatelessContainer statelessContainer = (StatelessContainer) container; 46 interfaces = new Class [localInterfaces.length + 2]; 47 48 System.arraycopy(localInterfaces, 0, interfaces, 0, localInterfaces.length); 49 interfaces[localInterfaces.length] = JBossProxy.class; 50 interfaces[localInterfaces.length + 1] = javax.ejb.EJBLocalObject .class; 51 52 return interfaces; 53 } 54 55 protected void initializeJndiName() 56 { 57 jndiName = ProxyFactoryHelper.getLocalJndiName(container); 58 } 59 60 @Override 61 public void start() throws Exception 62 { 63 super.start(); 64 StatelessContainer statelessContainer = (StatelessContainer) container; 65 LocalHome localHome = (LocalHome ) statelessContainer.resolveAnnotation(LocalHome .class); 66 if (localHome != null) 67 { 68 Class [] interfaces = {localHome.value()}; 69 Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(container.getBeanClass().getClassLoader(), 70 interfaces, new StatelessLocalProxy(container)); 71 NonSerializableFactory.rebind(container.getInitialContext(), jndiName + "Home", homeProxy); 72 } 73 } 74 75 @Override 76 public void stop() throws Exception 77 { 78 super.stop(); 79 StatelessContainer statelessContainer = (StatelessContainer) container; 80 LocalHome localHome = (LocalHome ) statelessContainer.resolveAnnotation(LocalHome .class); 81 if (localHome != null) 82 { 83 NonSerializableFactory.unbind(container.getInitialContext(), jndiName + "Home"); 84 } 85 } 86 87 88 public Object createProxy() 89 { 90 113 return constructProxy(new StatelessLocalProxy(container)); 114 } 115 116 protected StatelessHandleImpl getHandle() 117 { 118 StatelessHandleImpl handle = new StatelessHandleImpl(); 119 LocalBinding remoteBinding = (LocalBinding) advisor.resolveAnnotation(LocalBinding.class); 120 if (remoteBinding != null) 121 handle.jndiName = remoteBinding.jndiBinding(); 122 123 return handle; 124 } 125 126 } 127 | Popular Tags |