KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > container > JSessionHome


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: JSessionHome.java,v 1.23 2005/04/28 16:52:59 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_ejb.container;
27
28 import java.rmi.Remote JavaDoc;
29 import java.rmi.RemoteException JavaDoc;
30 import java.util.List JavaDoc;
31
32 import javax.ejb.RemoveException JavaDoc;
33
34 import org.objectweb.jonas_ejb.deployment.api.SessionDesc;
35 import org.objectweb.jonas_ejb.lib.EJBInvocation;
36
37 import org.objectweb.util.monolog.api.BasicLevel;
38
39 /**
40  * This class is the Standard Home for Session objects It exists only for beans
41  * that have declared a Remote Interface. It implements javax.ejb.EJBHome
42  * interface (by the inherited class JHome) It implements a pool of EJBObject's
43  * @author Philippe Durieux
44  */

45 public abstract class JSessionHome extends JHome implements Remote JavaDoc {
46
47     /**
48      * constructor
49      * @param dd The Session Bean Deployment Descriptor
50      * @param bf THe Session Bean Factory
51      */

52     public JSessionHome(SessionDesc dd, JSessionFactory bf) throws RemoteException JavaDoc {
53         super(dd, bf);
54         if (TraceEjb.isDebugIc()) {
55             TraceEjb.interp.log(BasicLevel.DEBUG, "");
56         }
57     }
58
59     public RequestCtx preInvoke(int txa) throws RemoteException JavaDoc {
60         // The connection List depends on the instance, so it must be
61
// set to null in case of Home method (create).
62
// only for stateful
63
bf.getTransactionManager().pushThreadLocalRMEventList(null);
64         return super.preInvoke(txa);
65     }
66
67     public void postInvoke(RequestCtx rctx) throws RemoteException JavaDoc {
68         super.postInvoke(rctx);
69         // save the connection List for future methods on the bean.
70
// only for stateful
71
List JavaDoc newList = bf.getTransactionManager().popThreadLocalRMEventList();
72         JSessionContext ctx = (JSessionContext) rctx.ejbContext;
73         if (ctx != null) {
74             ctx.setConnectionList(newList);
75         }
76     }
77
78     // ---------------------------------------------------------------
79
// EJBHome implementation
80
// remove(Handle) method is in the generated part.
81
// other methods are in JHome (identical for Sessions and Entities)
82
// ---------------------------------------------------------------
83

84     /**
85      * remove(pk) is not allowed for session beans
86      * @param pk the primary key
87      * @throws RemoveException Always.
88      */

89     public void remove(java.lang.Object JavaDoc pk) throws RemoteException JavaDoc, RemoveException JavaDoc {
90         throw new RemoveException JavaDoc("remove by PK Cannot be called in a session bean");
91     }
92
93     // ---------------------------------------------------------------
94
// other public methods, for internal use.
95
// ---------------------------------------------------------------
96

97     /**
98      * Creates the EJBObject (remote) this is in the generated class because it
99      * is mainly "new objectClass()"
100      * @return A JSessionRemote object
101      */

102     public abstract JSessionRemote createRemoteObject() throws RemoteException JavaDoc;
103
104 }
105
Popular Tags