KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > testCallEJB1InSB_TestingSessionBean


1 package test;
2
3 import java.util.logging.Level JavaDoc;
4 import java.util.logging.Logger JavaDoc;
5 import javax.ejb.*;
6 import javax.naming.Context JavaDoc;
7 import javax.naming.InitialContext JavaDoc;
8 import javax.naming.NamingException JavaDoc;
9
10 /**
11  * This is the bean class for the TestingSessionBean enterprise bean.
12  * Created 29.4.2005 15:24:25
13  * @author lm97939
14  */

15 public class TestingSessionBean implements SessionBean, TestingSessionRemoteBusiness, TestingSessionLocalBusiness {
16     private SessionContext context;
17     
18     // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">
19
// TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
20
// TODO Add business methods or web service operations
21
/**
22      * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
23      */

24     public void setSessionContext(SessionContext aContext) {
25         context = aContext;
26     }
27     
28     /**
29      * @see javax.ejb.SessionBean#ejbActivate()
30      */

31     public void ejbActivate() {
32         
33     }
34     
35     /**
36      * @see javax.ejb.SessionBean#ejbPassivate()
37      */

38     public void ejbPassivate() {
39         
40     }
41     
42     /**
43      * @see javax.ejb.SessionBean#ejbRemove()
44      */

45     public void ejbRemove() {
46         
47     }
48     // </editor-fold>
49

50     /**
51      * See section 7.10.3 of the EJB 2.0 specification
52      * See section 7.11.3 of the EJB 2.1 specification
53      */

54     public void ejbCreate() {
55         // TODO implement ejbCreate if necessary, acquire resources
56
// This method has access to the JNDI context so resource aquisition
57
// spanning all methods can be performed here such as home interfaces
58
// and data sources.
59
}
60     
61     
62     
63     // Add business logic below. (Right-click in editor and choose
64
// "EJB Methods > Add Business Method" or "Web Service > Add Operation")
65

66     public String JavaDoc testBusinessMethod1() {
67         //TODO implement testBusinessMethod1
68
return null;
69     }
70
71     public String JavaDoc testBusinessMethod2(String JavaDoc a, int b) throws Exception JavaDoc {
72         //TODO implement testBusinessMethod2
73
return null;
74     }
75
76     private TestingEntityLocalHome lookupTestingEntityBean() {
77         try {
78             Context JavaDoc c = new InitialContext JavaDoc();
79             TestingEntityLocalHome rv = (TestingEntityLocalHome) c.lookup("java:comp/env/ejb/TestingEntityBean");
80             return rv;
81         }
82         catch(NamingException JavaDoc ne) {
83             Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
84             throw new RuntimeException JavaDoc(ne);
85         }
86     }
87     
88     
89     
90 }
91
Popular Tags