Source Code Cross Referenced for JRepStatefulLocal.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ejb » container » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_ejb.container 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2006 Bull S.A.S.
004:         * Contact: jonas-team@objectweb.org
005:         * Copyright (C) 2006 Distributed Systems Lab.
006:         * Universidad Polit??cnica de Madrid (Spain)
007:         * Contact: http://lsd.ls.fi.upm.es/lsd
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2.1 of the License, or any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
022:         * USA
023:         *
024:         * --------------------------------------------------------------------------
025:         *
026:         * --------------------------------------------------------------------------
027:         */package org.objectweb.jonas_ejb.container;
028:
029:        import java.io.StringWriter;
030:        import java.rmi.RemoteException;
031:
032:        import javax.ejb.EJBException;
033:
034:        import org.objectweb.carol.cmi.ClusterOIdFactory;
035:        import org.objectweb.carol.cmi.ObjectId;
036:        import org.objectweb.carol.cmi.ServerConfigException;
037:        import org.objectweb.carol.cmi.configuration.TraceCmi;
038:
039:        /**
040:         * Generic part of the EJBObject implementation for replicated SFSBs
041:         * @author Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es)
042:         * @author Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es)
043:         */
044:        public abstract class JRepStatefulLocal extends JSessionLocal {
045:
046:            public ObjectId clusterOId = null;
047:
048:            /**
049:             * constructor
050:             * @param bf The Session Factory
051:             * @throws Exception 
052:             */
053:            public JRepStatefulLocal(JSessionFactory bf) {
054:                super (bf);
055:                if (TraceCmi.isDebugCmiHA()) {
056:                    TraceCmi.debugCmiHA("JRepStatefulLocal : this=" + this );
057:                }
058:
059:                // COMPLETE: Handle errors
060:                // Obtain a new cluster object id
061:                try {
062:                    clusterOId = ClusterOIdFactory.getInstance().getId();
063:                } catch (ServerConfigException e) {
064:                    java.io.StringWriter sw = new StringWriter();
065:                    java.io.PrintWriter pw = new java.io.PrintWriter(sw);
066:                    e.printStackTrace(pw);
067:                    TraceCmi.error("JRepStatefulLocal constructor: "
068:                            + sw.toString(), e);
069:                }
070:            }
071:
072:            /**
073:             * preInvoke is called before any request.
074:             * @param txa Transaction Attribute (Supports, Required, ...)
075:             * @return A RequestCtx object
076:             * @throws RemoteException Thrown when the method failed due to a
077:             *         system-level failure.
078:             */
079:            public RequestCtx preInvoke(int txa) {
080:                RequestCtx rctx = super .preInvoke(txa);
081:                /* ******************REPLICATION CODE STARTS HERE*********************** */
082:                preInvokeHook(rctx); // Replication algorithm link
083:                /* **********************END OF REPLICATION CODE************************ */
084:                return rctx;
085:            }
086:
087:            /**
088:             * postInvoke is called after any request.
089:             * @param rctx The RequestCtx that was returned at preInvoke()
090:             * @param remove TODO
091:             * @parem response The response that is going to be returned to the client
092:             *        (Needed by HA)
093:             * @throws RemoteException Thrown when the method failed due to a
094:             *         system-level failure.
095:             */
096:            public void postInvoke(RequestCtx rctx, boolean remove) {
097:                /* ******************REPLICATION CODE STARTS HERE*********************** */
098:                try {
099:                    postInvokeHook(rctx, remove); // Replication algorithm
100:                    // link
101:                    /* **********************END OF REPLICATION CODE************************ */
102:                } catch (Exception e) {
103:                    e.printStackTrace();
104:                    TraceCmi.error("Error calling postInvokeHook in sfsb.", e);
105:                } finally {
106:                    super .postInvoke(rctx);
107:                }
108:            }
109:
110:            /* ******************REPLICATION CODE STARTS HERE*********************** */
111:
112:            // ------------------------------------------------------------------------
113:            // Protected methods ------------------------------------------------------
114:            // ------------------------------------------------------------------------
115:            /**
116:             * Injects the state of the bean if the cluster object id received in the
117:             * request is in the current node. It extracts the object id passed through
118:             * the interceptors from the request id included in the current HA context.
119:             */
120:            protected void injectState() {
121:                JRepUtil
122:                        .injectState(this .clusterOId, (JStatefulSwitch) this .bs);
123:            }
124:
125:            // ------------------------------------------------------------------------
126:            // Private methods --------------------------------------------------------
127:            // ------------------------------------------------------------------------
128:
129:            /**
130:             * preInvokeHook implements the hook to perform the required replication
131:             * tasks before the bean context has been established. In this case, it
132:             * saves the current state of the bean before perform the invocation, in the
133:             * request context.
134:             * @param rctx The RequestCtx that was returned at preInvoke()
135:             */
136:            private void preInvokeHook(RequestCtx rctx) {
137:                try {
138:                    JRepUtil.preInvokeHook(bs, clusterOId, rctx);
139:                } catch (EJBException e) {
140:                    // COMPLETE: Handle errors
141:                    e.printStackTrace();
142:                    TraceCmi.error("Error in preInvokeHook in sfsb.", e);
143:                }
144:            }
145:
146:            /**
147:             * postInvokeHook implements the hook to perform the required replication
148:             * tasks after the bean context has been established
149:             * @param rctx The RequestCtx that was returned at preInvoke()
150:             * @parem response The response that is going to be returned to the client
151:             * @param remove true if it is an invocation to a remove method
152:             */
153:            private void postInvokeHook(RequestCtx rctx, boolean remove) {
154:                JRepUtil.postInvokeHook(rctx, this .clusterOId, bs, remove);
155:            }
156:
157:            /**
158:             * Gets the clusterOId
159:             * @return the clusterOid
160:             */
161:            public ObjectId getClusterOId() {
162:                return clusterOId;
163:            }
164:
165:            /**
166:             * Sets the clusterOId
167:             * @param oid
168:             */
169:            public void setClusterOId(ObjectId oid) {
170:                clusterOId = oid;
171:            }
172:
173:            /* **********************END OF REPLICATION CODE************************ */
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.