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 org.objectweb.carol.cmi.configuration.TraceCmi;
30: import org.objectweb.carol.cmi.ha.RequestId;
31: import org.objectweb.jonas.ha.interceptor.HACurrentDelegateImpl;
32: import org.objectweb.jonas_ejb.deployment.api.SessionDesc;
33:
34: /**
35: * Generic part of the EJBLocalHome implementation for replicated SFSBs
36: * @author Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es)
37: * @author Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es)
38: */
39: public abstract class JRepStatefulLocalHome extends JSessionLocalHome {
40:
41: /**
42: * constructor
43: * @param dd The Session Deployment Decriptor
44: * @param bf The Session Factory
45: * @throws Exception
46: */
47: public JRepStatefulLocalHome(SessionDesc dd, JSessionFactory bf) {
48: super (dd, bf);
49: if (TraceCmi.isDebugCmiHA()) {
50: TraceCmi.debugCmiHA("JRepStatefulLocalHome : this=" + this );
51: }
52: }
53:
54: /**
55: * Called if we have to replicate a request
56: * @param rctx The RequestCtx that was returned at preInvoke()
57: */
58: protected void replicateCreate(JStatefulSwitch sfsw) {
59: if (TraceCmi.isDebugCmiHA()) {
60: TraceCmi.debugCmiHA("replicateBean : this=" + this );
61: }
62: // Create the rootId from the current HACtx/Thread association
63: HACurrentDelegateImpl current = HACurrentDelegateImpl
64: .getCurrent();
65: // Obtain the root request
66: RequestId rootId = null;
67: try {
68: rootId = (RequestId) current.getRequests().get(0);
69:
70: JRepStatefulLocal jrsl = (JRepStatefulLocal) sfsw
71: .getLocal();
72:
73: JRepUtil
74: .addModifiedBean(sfsw, jrsl.getClusterOId(), rootId);
75: } catch (ArrayIndexOutOfBoundsException e) {
76: if (TraceCmi.isDebugCmiHA()) {
77: TraceCmi
78: .debugCmiHA("Not in a remote method call chain.");
79: }
80: // do nothing
81: }
82: }
83:
84: protected BeanFactory getBeanFactory() {
85: return bf;
86: }
87:
88: /**
89: * Creates the EJBLocalObject This is in the generated class because it is
90: * mainly "new objectClass()"
91: * @return The Local Object
92: */
93: abstract public JSessionLocal createLocalObject();
94:
95: }
|