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:
33: /**
34: * Generic part of the EJBObject implementation for replicated SFSBs
35: * @author Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es)
36: * @author Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es)
37: */
38: public abstract class JRepEntityLocal extends JEntityLocal {
39:
40: /**
41: * Constructor
42: * @param bf
43: */
44: public JRepEntityLocal(JEntityFactory bf) {
45: super (bf);
46: }
47:
48: /* (non-Javadoc)
49: * @see org.objectweb.jonas_ejb.container.JEntityLocal#postInvoke(org.objectweb.jonas_ejb.container.RequestCtx)
50: */
51: public void postInvoke(RequestCtx rctx, JEntityContext bctx) {
52: try {
53: postInvokeHook(bctx);
54: } catch (Exception e) {
55: e.printStackTrace();
56: TraceCmi.error("Error calling postInvokeHook in sfsb.", e);
57: } finally {
58: super .postInvoke(rctx);
59: }
60: }
61:
62: /**
63: * Implements the hook to perform the required replication
64: * tasks after the bean context has been established
65: * @param rctx The RequestCtx that was returned at preInvoke()
66: */
67: private void postInvokeHook(JEntityContext bctx) {
68: if (TraceCmi.isDebugCmiHA()) {
69: TraceCmi
70: .debugCmiHA("---------------------------------------");
71: TraceCmi.debugCmiHA("In PostInvoke hook for: "
72: + bctx.getPrimaryKey());
73: }
74:
75: // Create the rootId from the current HACtx/Thread association
76: HACurrentDelegateImpl current = HACurrentDelegateImpl
77: .getCurrent();
78: // Obtain the root request
79: RequestId rootId = null;
80: try {
81: rootId = (RequestId) current.getRequests().get(0);
82: JRepUtil.addEntityBean(bctx, rootId);
83: } catch (ArrayIndexOutOfBoundsException e) {
84: TraceCmi.debugCmiHA("Don't need to be replicate.");
85: }
86:
87: if (TraceCmi.isDebugCmiHA()) {
88: TraceCmi
89: .debugCmiHA("---------------------------------------");
90: }
91: }
92: }
|