1 22 package org.jboss.ejb3.session; 23 24 import javax.ejb.EJBMetaData ; 25 import javax.ejb.Handle ; 26 import javax.ejb.HomeHandle ; 27 import javax.ejb.Remote ; 28 import javax.ejb.RemoteHome ; 29 import org.jboss.annotation.ejb.RemoteBinding; 30 import org.jboss.aop.Advisor; 31 import org.jboss.ejb3.Container; 32 import org.jboss.ejb3.EJBContainer; 33 import org.jboss.ejb3.ProxyFactory; 34 import org.jboss.logging.Logger; 35 import org.jboss.ejb3.proxy.EJBMetaDataImpl; 36 import org.jboss.ejb3.proxy.handle.HomeHandleImpl; 37 38 44 public abstract class BaseSessionProxyFactory implements ProxyFactory 45 { 46 private static final Logger log = Logger.getLogger(BaseSessionProxyFactory.class); 47 48 protected Container container; 49 protected Advisor advisor; 50 51 public Object createHomeProxy() 52 { 53 throw new RuntimeException ("NYI"); 54 } 55 56 public void setContainer(Container container) 57 { 58 this.container = container; 59 this.advisor = (Advisor) container; 60 } 61 62 protected void setEjb21Objects(BaseSessionRemoteProxy proxy) 63 { 64 proxy.setHandle(getHandle()); 65 proxy.setHomeHandle(getHomeHandle()); 66 proxy.setEjbMetaData(getEjbMetaData()); 67 } 68 69 abstract protected Handle getHandle(); 70 71 protected HomeHandle getHomeHandle() 72 { 73 EJBContainer ejbContainer = (EJBContainer)container; 74 75 HomeHandleImpl homeHandle = null; 76 77 RemoteBinding remoteBindingAnnotation = (RemoteBinding)ejbContainer.resolveAnnotation(RemoteBinding.class); 78 if (remoteBindingAnnotation != null) 79 homeHandle = new HomeHandleImpl(remoteBindingAnnotation.jndiBinding() + "Home"); 80 81 return homeHandle; 82 } 83 84 protected EJBMetaData getEjbMetaData() 85 { 86 Class remote = null; 87 Class home = null; 88 Class pkClass = Object .class; 89 HomeHandleImpl homeHandle = null; 90 91 EJBContainer ejbContainer = (EJBContainer)container; 92 93 Remote remoteAnnotation = (Remote )ejbContainer.resolveAnnotation(Remote .class); 94 if (remoteAnnotation != null) 95 remote = remoteAnnotation.value()[0]; 96 RemoteHome homeAnnotation = (RemoteHome )ejbContainer.resolveAnnotation(RemoteHome .class); 97 if (homeAnnotation != null) 98 home = homeAnnotation.value(); 99 RemoteBinding remoteBindingAnnotation = (RemoteBinding)ejbContainer.resolveAnnotation(RemoteBinding.class); 100 if (remoteBindingAnnotation != null) 101 homeHandle = new HomeHandleImpl(remoteBindingAnnotation.jndiBinding()); 102 103 EJBMetaDataImpl metadata = new EJBMetaDataImpl(remote, home, pkClass, true, false, homeHandle); 104 105 return metadata; 106 } 107 108 } 109 | Popular Tags |