001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: MetSession.java 4664 2004-04-28 15:32:38Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.beans.applimet;
027:
028: import java.rmi.RemoteException;
029: import java.sql.SQLException;
030: import javax.ejb.CreateException;
031: import javax.ejb.SessionBean;
032: import javax.ejb.SessionContext;
033: import org.objectweb.jonas.common.Log;
034: import org.objectweb.util.monolog.api.Logger;
035: import org.objectweb.util.monolog.api.BasicLevel;
036:
037: /**
038: */
039: public class MetSession implements SessionBean {
040:
041: SessionContext ejbContext;
042: static protected Logger logger = null;
043: private Dao dao;
044: private Dao dao2;
045:
046: public void ejbRemove() throws RemoteException {
047: logger.log(BasicLevel.DEBUG, "");
048: try {
049: dao.removeConnexion();
050: } catch (SQLException e) {
051: throw new RemoteException("cannot remove Connexion: " + e);
052: }
053: }
054:
055: public void ejbCreate() throws CreateException {
056: logger.log(BasicLevel.DEBUG, "");
057: try {
058: dao = new Dao();
059: } catch (Exception e) {
060: throw new CreateException("Cannot create Dao: " + e);
061: }
062: }
063:
064: public void methode1() throws RemoteException {
065: logger.log(BasicLevel.DEBUG, "");
066: try {
067: String liste = dao.rechercherTousLesMarches();
068: logger.log(BasicLevel.DEBUG, liste);
069: } catch (Exception e) {
070: throw new RemoteException("Error calling Dao: " + e);
071: }
072: }
073:
074: public void moscone1() throws java.rmi.RemoteException {
075: logger.log(BasicLevel.DEBUG, "");
076: try {
077: dao2 = new Dao();
078: dao2.rechercherTousLesMarches();
079: dao2.removeConnexion();
080: } catch (Exception e) {
081: throw new RemoteException("Error on Dao2: " + e);
082: }
083: }
084:
085: public void getconn() throws java.rmi.RemoteException {
086: logger.log(BasicLevel.DEBUG, "");
087: try {
088: dao2 = new Dao();
089: } catch (Exception e) {
090: throw new RemoteException("Cannot create Dao: " + e);
091: }
092: }
093:
094: public void getconntx() throws java.rmi.RemoteException {
095: logger.log(BasicLevel.DEBUG, "");
096: try {
097: dao2 = new Dao();
098: } catch (Exception e) {
099: throw new RemoteException("Cannot create Dao: " + e);
100: }
101: }
102:
103: public void useconn() throws java.rmi.RemoteException {
104: logger.log(BasicLevel.DEBUG, "");
105: try {
106: String liste = dao2.rechercherTousLesMarches();
107: logger.log(BasicLevel.DEBUG, liste);
108: } catch (Exception e) {
109: throw new RemoteException("Error calling Dao: " + e);
110: }
111: }
112:
113: public void closeconn() throws java.rmi.RemoteException {
114: logger.log(BasicLevel.DEBUG, "");
115: try {
116: dao2.removeConnexion();
117: } catch (SQLException e) {
118: throw new RemoteException("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 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: }
|