KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > bsf > smartValueObject > demo > SVODemoServiceBean


1 package org.bsf.smartValueObject.demo;
2
3 import org.bsf.commons.ejb.SessionAdapterBean;
4
5 import javax.ejb.CreateException JavaDoc;
6 import javax.naming.InitialContext JavaDoc;
7 import javax.naming.NamingException JavaDoc;
8
9 /**
10  * This EJB is used as the server service for the SVO demo.
11  * Its main goal is to create the stateful bean that the client will
12  * use.
13  *
14  * @ejb:bean type="Stateless"
15  * name="SVODemoService"
16  * jndi-name="ejb/SVODemoService"
17  * generate="true"
18  * view-type="remote"
19  *
20  * @ejb:home extends="javax.ejb.EJBHome"
21  * generate="remote"
22  *
23  * @ejb:interface extends="javax.ejb.EJBObject"
24  * generate="remote"
25  *
26  * @ejb:transaction type="Required"
27  *
28  * @ejb:ejb-ref ejb-name="SVODemoUser"
29  * view-type="remote"
30  *
31  */

32 public class SVODemoServiceBean extends SessionAdapterBean {
33     SVODemoUserHome userHome = null;
34
35     /**
36      * @ejb:interface-method
37      */

38     public SVODemoUser createUserService(){
39         try {
40             logInfo("SVODemo : new user connected.");
41
42             return userHome.create();
43         } catch (Exception JavaDoc e) {
44             handleExceptionAsSystemException(e);
45             return null;
46         }
47     }
48
49     /**
50      * During the creation of the EJB we retrieve a ref on the local home
51      * of the SVODemoUser
52      * @throws CreateException
53      */

54     public void ejbCreate() throws CreateException JavaDoc {
55
56         // Retrieves the local home of the Lov Entity bean and keeps it for further use
57
try {
58             InitialContext JavaDoc ic = new InitialContext JavaDoc();
59             userHome = (SVODemoUserHome)
60                     ic.lookup("java:comp/env/ejb/SVODemoUser");
61         } catch( NamingException JavaDoc e ) {
62             handleExceptionAsSystemException( e );
63         }
64     }
65 }
66
Popular Tags