1 22 package org.jboss.tutorial.ejb21_client_adaptors.bean; 23 24 import javax.naming.*; 25 import javax.ejb.EJB ; 26 import javax.ejb.EJBs ; 27 import javax.ejb.Remote ; 28 import javax.ejb.Stateful ; 29 import javax.ejb.Init ; 30 import javax.ejb.RemoteHome ; 31 32 import org.jboss.annotation.ejb.RemoteBinding; 33 import org.jboss.ejb3.Container; 34 import org.jboss.logging.Logger; 35 36 40 @Stateful (name="Session1") 41 @Remote (Session1Remote.class) 42 @RemoteHome (Session1RemoteHome.class) 43 @RemoteBinding(jndiBinding = "Session1Remote") 44 @EJBs ({@EJB (name="session2", beanInterface=org.jboss.tutorial.ejb21_client_adaptors.bean.Session2LocalHome.class, beanName="Session2")}) 45 public class Session1Bean 46 { 47 private static final Logger log = Logger.getLogger(Session1Bean.class); 48 49 private String initValue = null; 50 51 public String getInitValue() 52 { 53 return initValue; 54 } 55 56 public String getLocalSession2InitValue() throws Exception 57 { 58 InitialContext jndiContext = new InitialContext(); 59 Object s = jndiContext.lookup(Container.ENC_CTX_NAME + "/env/session2"); 60 Session2LocalHome home = (Session2LocalHome)jndiContext.lookup(Container.ENC_CTX_NAME + "/env/session2"); 61 Session2Local session2 = home.create("initialized"); 62 return session2.getInitValue(); 63 } 64 65 @Init 66 public void ejbCreate() 67 { 68 initValue = "initialized"; 69 } 70 71 } 72 | Popular Tags |