KickJava   Java API By Example, From Geeks To Geeks.

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


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: MetSession.java,v 1.3 2004/04/28 15:32:38 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

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

39 public class MetSession implements SessionBean JavaDoc {
40
41     SessionContext JavaDoc ejbContext;
42     static protected Logger logger = null;
43     private Dao dao;
44     private Dao dao2;
45
46     public void ejbRemove() throws RemoteException JavaDoc {
47         logger.log(BasicLevel.DEBUG, "");
48         try {
49             dao.removeConnexion();
50         } catch (SQLException JavaDoc e) {
51             throw new RemoteException JavaDoc("cannot remove Connexion: " + e);
52         }
53     }
54
55     public void ejbCreate() throws CreateException JavaDoc {
56         logger.log(BasicLevel.DEBUG, "");
57         try {
58             dao = new Dao();
59         } catch (Exception JavaDoc e) {
60             throw new CreateException JavaDoc("Cannot create Dao: " + e);
61         }
62     }
63
64     public void methode1() throws RemoteException JavaDoc {
65         logger.log(BasicLevel.DEBUG, "");
66         try {
67             String JavaDoc liste = dao.rechercherTousLesMarches();
68             logger.log(BasicLevel.DEBUG, liste);
69         } catch (Exception JavaDoc e) {
70             throw new RemoteException JavaDoc("Error calling Dao: " + e);
71         }
72     }
73
74     public void moscone1() throws java.rmi.RemoteException JavaDoc {
75         logger.log(BasicLevel.DEBUG, "");
76         try {
77             dao2 = new Dao();
78             dao2.rechercherTousLesMarches();
79             dao2.removeConnexion();
80         } catch (Exception JavaDoc e) {
81             throw new RemoteException JavaDoc("Error on Dao2: " + e);
82         }
83     }
84
85     public void getconn() throws java.rmi.RemoteException JavaDoc {
86         logger.log(BasicLevel.DEBUG, "");
87         try {
88             dao2 = new Dao();
89         } catch (Exception JavaDoc e) {
90             throw new RemoteException JavaDoc("Cannot create Dao: " + e);
91         }
92     }
93
94     public void getconntx() throws java.rmi.RemoteException JavaDoc {
95         logger.log(BasicLevel.DEBUG, "");
96         try {
97             dao2 = new Dao();
98         } catch (Exception JavaDoc e) {
99             throw new RemoteException JavaDoc("Cannot create Dao: " + e);
100         }
101     }
102
103     public void useconn() throws java.rmi.RemoteException JavaDoc {
104         logger.log(BasicLevel.DEBUG, "");
105         try {
106             String JavaDoc liste = dao2.rechercherTousLesMarches();
107             logger.log(BasicLevel.DEBUG, liste);
108         } catch (Exception JavaDoc e) {
109             throw new RemoteException JavaDoc("Error calling Dao: " + e);
110         }
111     }
112
113     public void closeconn() throws java.rmi.RemoteException JavaDoc {
114         logger.log(BasicLevel.DEBUG, "");
115         try {
116             dao2.removeConnexion();
117         } catch (SQLException JavaDoc e) {
118             throw new RemoteException JavaDoc("cannot remove Connexion: " + e);
119         }
120     }
121
122     public void ejbActivate() {
123         logger.log(BasicLevel.DEBUG, "");
124     }
125
126     public void ejbPassivate() {
127         logger.log(BasicLevel.DEBUG, "");
128     }
129
130     public void setSessionContext(javax.ejb.SessionContext JavaDoc ctx) {
131         if (logger == null) {
132             logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
133         }
134         logger.log(BasicLevel.DEBUG, "");
135         ejbContext = ctx;
136     }
137
138     public void unsetSessionContext() {
139         logger.log(BasicLevel.DEBUG, "");
140     }
141 }
142
Popular Tags