1 22 package org.jboss.ejb3.test.ejbcontext; 23 24 import javax.annotation.Resource; 25 import javax.ejb.EJB ; 26 import javax.ejb.EJBContext ; 27 import javax.ejb.Remote ; 28 import javax.ejb.SessionContext ; 29 import javax.ejb.Stateful ; 30 31 import javax.naming.InitialContext ; 32 33 import org.jboss.annotation.ejb.RemoteBinding; 34 import org.jboss.annotation.ejb.RemoteBindings; 35 import org.jboss.logging.Logger; 36 37 43 @Stateful(name="Stateful") 44 @RemoteBindings({@RemoteBinding(jndiBinding = "Stateful"), @RemoteBinding(jndiBinding = "StatefulRemote")}) 45 public class StatefulBean 46 implements org.jboss.ejb3.test.ejbcontext.Stateful, StatefulRemote 47 { 48 private static final Logger log = Logger.getLogger(StatefulBean.class); 49 50 @Resource 51 SessionContext sessionContext; 52 53 @EJB (mappedName="StatefulRemote") 54 StatefulRemote statefulRemote = null; 55 56 String state = ""; 57 58 public void testEjbContext() throws Exception 59 { 60 InitialContext jndiContext = new InitialContext (); 61 EJBContext ejbContext = (EJBContext )jndiContext.lookup("java:comp.ejb3/EJBContext"); 62 log.info("EJBContext " + ejbContext); 63 } 64 65 public void test() 66 { 67 68 } 69 70 public String getState() 71 { 72 return state; 73 } 74 75 public void setState(String state) 76 { 77 this.state = state; 78 } 79 80 public Object getBusinessObject() throws Exception 81 { 82 return sessionContext.getBusinessObject(org.jboss.ejb3.test.ejbcontext.Stateful.class); 83 } 84 85 86 public Class testInvokedBusinessInterface() throws Exception 87 { 88 return sessionContext.getInvokedBusinessInterface(); 89 } 90 91 public Class testInvokedBusinessInterface2() throws Exception 92 { 93 return sessionContext.getInvokedBusinessInterface(); 94 } 95 96 public Class testLocalInvokedBusinessInterface() throws Exception 97 { 98 return statefulRemote.testInvokedBusinessInterface2(); 99 } 100 } 101 | Popular Tags |