KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > applimet > AppliSession


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: AppliSession.java,v 1.4 2004/07/06 09:45:27 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.beans.applimet;
27
28 import java.rmi.RemoteException JavaDoc;
29 import javax.ejb.CreateException JavaDoc;
30 import javax.ejb.SessionBean JavaDoc;
31 import javax.ejb.SessionContext JavaDoc;
32 import javax.naming.Context JavaDoc;
33 import javax.naming.InitialContext JavaDoc;
34 import javax.naming.NamingException JavaDoc;
35 import javax.rmi.PortableRemoteObject JavaDoc;
36 import org.objectweb.jonas.common.Log;
37 import org.objectweb.util.monolog.api.Logger;
38 import org.objectweb.util.monolog.api.BasicLevel;
39
40 /**
41  */

42 public class AppliSession implements SessionBean JavaDoc {
43
44     static protected Logger logger = null;
45     private MetHome th;
46     private Met tr;
47
48     SessionContext JavaDoc ejbContext;
49
50     public void ejbRemove() throws RemoteException JavaDoc {
51         logger.log(BasicLevel.DEBUG, "");
52         try {
53             tr.remove();
54         } catch (Exception JavaDoc e) {
55             logger.log(BasicLevel.ERROR, "Cannot remove Met:" + e);
56             throw new RemoteException JavaDoc("Cannot remove Met:" + e);
57         }
58     }
59
60     public void ejbCreate() throws CreateException JavaDoc {
61         logger.log(BasicLevel.DEBUG, "");
62         try{
63             Context JavaDoc ctx = new InitialContext JavaDoc();
64             Object JavaDoc objref = ctx.lookup(MetHome.JNDI_NAME);
65             th = (MetHome) PortableRemoteObject.narrow(objref, MetHome.class);
66             tr = th.create();
67         } catch(Exception JavaDoc e) {
68             logger.log(BasicLevel.ERROR, "Cannot create Met:" + e);
69             throw new CreateException JavaDoc("Cannot create Met:" + e);
70         }
71     }
72
73     public void methodeApplicative() throws RemoteException JavaDoc {
74         logger.log(BasicLevel.DEBUG, "");
75         try {
76             tr.methode1();
77         } catch (Exception JavaDoc e) {
78             logger.log(BasicLevel.ERROR, "Cannot call Met:" + e);
79             throw new RemoteException JavaDoc("Cannot call Met:" + e);
80         }
81     }
82
83     public void noTxMethod() throws RemoteException JavaDoc {
84         logger.log(BasicLevel.DEBUG, "");
85         try {
86             ejbContext.getRollbackOnly();
87             throw new RemoteException JavaDoc("Should get IllegalStateException");
88         } catch (IllegalStateException JavaDoc e) {
89         }
90     }
91
92     public void ejbActivate() {
93         logger.log(BasicLevel.DEBUG, "");
94     }
95
96     public void ejbPassivate() {
97         logger.log(BasicLevel.DEBUG, "");
98     }
99
100     public void setSessionContext(javax.ejb.SessionContext JavaDoc ctx) {
101         if (logger == null) {
102             logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
103         }
104         logger.log(BasicLevel.DEBUG, "");
105         ejbContext = ctx;
106     }
107
108     public void unsetSessionContext() {
109         logger.log(BasicLevel.DEBUG, "");
110     }
111 }
112
Popular Tags