01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: jonas-team@objectweb.org
05: * Copyright (C) 2006 Distributed Systems Lab.
06: * Universidad Polit??cnica de Madrid (Spain)
07: * Contact: http://lsd.ls.fi.upm.es/lsd
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2.1 of the License, or any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22: * USA
23: *
24: * --------------------------------------------------------------------------
25: *
26: * --------------------------------------------------------------------------
27: */package org.objectweb.jonas_ejb.container;
28:
29: import java.rmi.NoSuchObjectException;
30: import java.rmi.Remote;
31: import java.rmi.RemoteException;
32:
33: import org.objectweb.carol.cmi.ServerConfigException;
34: import org.objectweb.carol.cmi.configuration.TraceCmi;
35: import org.objectweb.jonas.ha.interceptor.HACurrentDelegateImpl;
36: import org.objectweb.jonas_ejb.deployment.api.SessionDesc;
37:
38: /**
39: * This class is the Standard Home for replicated SFSB objects It exists only
40: * for beans that have declared a Remote Interface.
41: * @author Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es)
42: * @author Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es)
43: * @author Benoit Pelletier
44: */
45: public abstract class JRepStatefulHome extends JSessionHome {
46:
47: public JRepStatefulHome(SessionDesc dd, JSessionFactory bf)
48: throws RemoteException {
49: super (dd, bf);
50: if (TraceCmi.isDebugCmiHA()) {
51: TraceCmi.debugCmiHA("JRepStatefulHome");
52: }
53: }
54:
55: /**
56: * Get the remote object as a stub object for HA remote object LB
57: * @param remote remote object
58: * @return get remote object
59: * @throws RemoteException
60: * @throws ServerConfigException
61: * @throws NoSuchObjectException if the clustered object is not found in the
62: * CMI registry
63: */
64: public Remote getHARemoteStub(Remote remote) throws RemoteException {
65: return JRepUtil.getHARemoteStub(remote, dd);
66: }
67:
68: /**
69: * postInvoke is called after any request.
70: * @param rctx The RequestCtx that was returned at preInvoke()
71: * @param remove TODO
72: * @parem response The response that is going to be returned to the client
73: * (Needed by HA)
74: * @throws RemoteException Thrown when the method failed due to a
75: * system-level failure.
76: */
77: public void postInvoke(RequestCtx rctx) throws RemoteException {
78: try {
79: super .postInvoke(rctx);
80: } finally {
81: // We dont need the request anymore so remove it
82: removeCurrentRequest();
83: }
84: }
85:
86: /**
87: * Removes the curren request from the requests heap
88: */
89: private void removeCurrentRequest() {
90: HACurrentDelegateImpl current = HACurrentDelegateImpl
91: .getCurrent();
92: current.getRequests().pop();
93: }
94: }
|