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 Politecnica 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.EntityDesc;
33: import org.objectweb.util.monolog.api.BasicLevel;
34:
35: /**
36: * Generic part of the JEntityLocalHome implementation for replicated EB
37: * @author Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es)
38: * @author Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es)
39: */
40: public abstract class JRepEntityLocalHome extends JEntityLocalHome {
41:
42: /**
43: * constructor
44: * @param dd The Entity Deployment Decriptor
45: * @param bf The Entity Factory
46: */
47: public JRepEntityLocalHome(EntityDesc dd, JEntityFactory bf) {
48: super (dd, bf);
49: if (TraceEjb.isDebugIc()) {
50: TraceEjb.interp.log(BasicLevel.DEBUG, "");
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(JEntityContext bctx) {
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: JRepUtil.addEntityBean(bctx, rootId);
70: } catch (ArrayIndexOutOfBoundsException e) {
71: if (TraceCmi.isDebugCmiHA()) {
72: TraceCmi
73: .debugCmiHA("Not in a remote method call chain.");
74: }
75: // do nothing
76: }
77: }
78:
79: public abstract JEntityLocal createLocalObject();
80:
81: }
|