1 package test; 2 3 import java.util.logging.Level ; 4 import java.util.logging.Logger ; 5 import javax.ejb.*; 6 import javax.naming.Context ; 7 import javax.naming.InitialContext ; 8 import javax.naming.NamingException ; 9 import javax.rmi.PortableRemoteObject ; 10 11 16 public class TestingSessionBean implements SessionBean, TestingSessionRemoteBusiness, TestingSessionLocalBusiness { 17 private SessionContext context; 18 19 25 public void setSessionContext(SessionContext aContext) { 26 context = aContext; 27 } 28 29 32 public void ejbActivate() { 33 34 } 35 36 39 public void ejbPassivate() { 40 41 } 42 43 46 public void ejbRemove() { 47 48 } 49 51 55 public void ejbCreate() { 56 } 61 62 63 64 67 public String testBusinessMethod1() { 68 return null; 70 } 71 72 public String testBusinessMethod2(String a, int b) throws Exception { 73 return null; 75 } 76 77 private TestingEntityLocalHome lookupTestingEntityBean() { 78 try { 79 Context c = new InitialContext (); 80 TestingEntityLocalHome rv = (TestingEntityLocalHome) c.lookup("java:comp/env/ejb/TestingEntityBean"); 81 return rv; 82 } 83 catch(NamingException ne) { 84 Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne); 85 throw new RuntimeException (ne); 86 } 87 } 88 89 private TestingEntityRemoteHome lookupMyTestingEntityBean() { 90 try { 91 Context c = new InitialContext (); 92 Object remote = c.lookup("java:comp/env/ejb/MyTestingEntityBean"); 93 TestingEntityRemoteHome rv = (TestingEntityRemoteHome) PortableRemoteObject.narrow(remote, TestingEntityRemoteHome.class); 94 return rv; 95 } 96 catch(NamingException ne) { 97 Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne); 98 throw new RuntimeException (ne); 99 } 100 } 101 102 103 104 } 105
| Popular Tags
|