Source Code Cross Referenced for JStatelessSwitch.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) 1999-2005 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: JStatelessSwitch.java 8375 2006-05-19 07:31:06Z durieuxp $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ejb.container;
025:
026:        import java.rmi.NoSuchObjectException;
027:        import java.rmi.RemoteException;
028:
029:        import javax.ejb.RemoveException;
030:        import javax.transaction.Transaction;
031:        import javax.xml.rpc.handler.MessageContext;
032:
033:        import org.objectweb.jonas_timer.TraceTimer;
034:        import org.objectweb.util.monolog.api.BasicLevel;
035:
036:        /**
037:         * JStatelessSwitch is the implementation of JSessionSwitch dedicated to the
038:         * Stateless Session Bean.
039:         * @author Philippe Durieux
040:         */
041:        public class JStatelessSwitch extends JSessionSwitch {
042:
043:            /**
044:             * Service Endpoint
045:             */
046:            private JServiceEndpoint se = null;
047:
048:            /**
049:             * Keep this object alive, because it is unique.
050:             */
051:            private boolean keepalive;
052:
053:            /**
054:             * constructor.
055:             * @param bf The Bean Factory
056:             * @throws RemoteException if the constructor fails
057:             */
058:            public JStatelessSwitch(JStatelessFactory bf)
059:                    throws RemoteException {
060:                super (bf);
061:                if (TraceEjb.isDebugIc()) {
062:                    TraceEjb.interp.log(BasicLevel.DEBUG, "");
063:                }
064:
065:                // Create ServiceEndpoint if defined in the bean descriptor
066:                if (bf.getSEHome() != null) {
067:                    se = bf.getSEHome().createServiceEndpointObject();
068:                    se.setSessionSwitch(this );
069:                }
070:                keepalive = (bf.singleSwitchOn());
071:            }
072:
073:            // ===============================================================
074:            // TimerEventListener implementation
075:            // ===============================================================
076:
077:            /**
078:             * The session timeout has expired, or a Timer on this bean has expired.
079:             * @param arg Not Used.
080:             */
081:            public synchronized void timeoutExpired(Object arg) {
082:                if (TraceTimer.logger.isLoggable(BasicLevel.DEBUG)) {
083:                    TraceTimer.logger.log(BasicLevel.DEBUG,
084:                            "stateless session '" + bf.getEJBName()
085:                                    + "' : timeout expired");
086:                }
087:                mytimer = null;
088:                noLongerUsed();
089:            }
090:
091:            // ===============================================================
092:            // other public methods
093:            // ===============================================================
094:
095:            /**
096:             * @return The ServiceEndpoint
097:             */
098:            public JServiceEndpoint getServiceEndpoint() {
099:                return se;
100:            }
101:
102:            /**
103:             * @return The JAX-RPC MessageContext
104:             */
105:            public MessageContext getMsgContext() {
106:                if (se == null) {
107:                    TraceEjb.logger.log(BasicLevel.ERROR,
108:                            "No ServiceEndpoint for this bean");
109:                    return null;
110:                }
111:                return se.getMessageContext();
112:            }
113:
114:            /**
115:             * get an initialized Bean Context
116:             * @param tx Current transaction (not used)
117:             * @return the Session Context
118:             * @throws RemoteException if context cannot be obtained
119:             */
120:            public JSessionContext getICtx(Transaction tx)
121:                    throws RemoteException {
122:                if (TraceEjb.isDebugIc()) {
123:                    TraceEjb.interp.log(BasicLevel.DEBUG, "");
124:                }
125:                return (JStatelessContext) ((JStatelessFactory) bf)
126:                        .getJContext(this );
127:            }
128:
129:            /**
130:             * release the bean context. Assumes that only 1 Context is managed at a
131:             * time. Contexts are release at each request, in case of stateless session.
132:             * @param tx Current transaction (not used)
133:             */
134:            public void releaseICtx(RequestCtx req, boolean discard) {
135:                if (TraceEjb.isDebugIc()) {
136:                    TraceEjb.interp.log(BasicLevel.DEBUG, "");
137:                }
138:                JStatelessContext bctx = (JStatelessContext) req.ejbContext;
139:                if (bctx == null) {
140:                    TraceEjb.interp.log(BasicLevel.WARN, "No ejbContext");
141:                    return;
142:                }
143:                if ((bctx.isMarkedRemoved() || discard) && !keepalive) {
144:                    stopTimer();
145:                    noLongerUsed();
146:                }
147:                ((JStatelessFactory) bf).releaseJContext(bctx);
148:            }
149:
150:            /**
151:             * This Session is no longer used.
152:             */
153:            public void noLongerUsed() {
154:                if (TraceEjb.isDebugIc()) {
155:                    TraceEjb.interp.log(BasicLevel.DEBUG, "");
156:                }
157:
158:                // Unexport the EJBObject from the Orb
159:                if (myremote != null) {
160:                    try {
161:                        myremote.unexportObject();
162:                    } catch (NoSuchObjectException e) {
163:                        TraceEjb.logger.log(BasicLevel.ERROR, "exception", e);
164:                    }
165:                }
166:
167:                // return the SessionSwitch in the pool.
168:                // will be reused for another Session.
169:                bf.removeEJB(this );
170:            }
171:
172:            /**
173:             * This is not used for stateless
174:             * @param mc Not Used.
175:             */
176:            public void setMustCommit(boolean mc) {
177:            }
178:
179:            /**
180:             * This is not used for stateless
181:             */
182:            public void pushConnectionList() {
183:            }
184:
185:            /**
186:             * This is not used for stateless
187:             */
188:            public void popConnectionList() {
189:            }
190:
191:            /**
192:             * This is not used for stateless
193:             * @param tx the transaction object
194:             */
195:            public void enlistConnections(Transaction tx) {
196:            }
197:
198:            /**
199:             * This is not used for stateless
200:             * @param tx the transaction object
201:             */
202:            public void delistConnections(Transaction tx) {
203:            }
204:
205:            /**
206:             * This do nothing for stateless
207:             */
208:            public void saveBeanTx() {
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.