Source Code Cross Referenced for StatefulSessionEnterpriseContext.java in  » EJB-Server-JBoss-4.2.1 » server » org » jboss » ejb » 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 » EJB Server JBoss 4.2.1 » server » org.jboss.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.ejb;
023:
024:        import java.io.IOException;
025:        import java.io.Serializable;
026:        import java.io.ObjectInputStream;
027:        import java.io.ObjectOutputStream;
028:
029:        import java.rmi.RemoteException;
030:        import java.security.Principal;
031:        import java.util.Date;
032:
033:        import javax.ejb.EJBLocalObject;
034:        import javax.ejb.*;
035:        import javax.transaction.UserTransaction;
036:        import javax.xml.rpc.handler.MessageContext;
037:
038:        /**
039:         * The enterprise context for stateful session beans.
040:         *
041:         * @author <a href="mailto:rickard.oberg@telkel.com">Rickard �berg</a>
042:         * @author <a href="mailto:docodan@mvcsoft.com">Daniel OConnor</a>
043:         * @version $Revision: 57209 $
044:         */
045:        public class StatefulSessionEnterpriseContext extends EnterpriseContext
046:                implements  Serializable {
047:            static final long serialVersionUID = -7027865698975183585L;
048:
049:            // Constants -----------------------------------------------------
050:
051:            // Attributes ----------------------------------------------------
052:            private EJBObject ejbObject;
053:            private EJBLocalObject ejbLocalObject;
054:            private SessionContext ctx;
055:
056:            // Static --------------------------------------------------------
057:
058:            // Constructors --------------------------------------------------
059:
060:            public StatefulSessionEnterpriseContext(Object instance,
061:                    Container con) throws RemoteException {
062:                super (instance, con);
063:                ctx = new StatefulSessionContextImpl();
064:                try {
065:                    AllowedOperationsAssociation
066:                            .pushInMethodFlag(IN_SET_SESSION_CONTEXT);
067:                    ((SessionBean) instance).setSessionContext(ctx);
068:                } finally {
069:                    AllowedOperationsAssociation.popInMethodFlag();
070:                }
071:            }
072:
073:            // Public --------------------------------------------------------
074:
075:            public void discard() throws RemoteException {
076:                // Do nothing
077:            }
078:
079:            public EJBContext getEJBContext() {
080:                return ctx;
081:            }
082:
083:            /**
084:             * During activation of stateful session beans we replace the instance
085:             * by the one read from the file.
086:             */
087:            public void setInstance(Object instance) {
088:                this .instance = instance;
089:                try {
090:                    ((SessionBean) instance).setSessionContext(ctx);
091:                } catch (Exception x) {
092:                    log.error("Failed to setSessionContext", x);
093:                }
094:            }
095:
096:            public void setEJBObject(EJBObject eo) {
097:                ejbObject = eo;
098:            }
099:
100:            public EJBObject getEJBObject() {
101:                return ejbObject;
102:            }
103:
104:            public void setEJBLocalObject(EJBLocalObject eo) {
105:                ejbLocalObject = eo;
106:            }
107:
108:            public EJBLocalObject getEJBLocalObject() {
109:                return ejbLocalObject;
110:            }
111:
112:            public SessionContext getSessionContext() {
113:                return ctx;
114:            }
115:
116:            // Package protected ---------------------------------------------
117:
118:            // Protected -----------------------------------------------------
119:
120:            // Private -------------------------------------------------------
121:
122:            private void writeObject(ObjectOutputStream out)
123:                    throws IOException, ClassNotFoundException {
124:                // No state
125:            }
126:
127:            private void readObject(ObjectInputStream in) throws IOException,
128:                    ClassNotFoundException {
129:                // No state
130:            }
131:
132:            // Inner classes -------------------------------------------------
133:
134:            protected class StatefulSessionContextImpl extends EJBContextImpl
135:                    implements  SessionContext {
136:
137:                public EJBHome getEJBHome() {
138:                    AllowedOperationsAssociation.assertAllowedIn("getEJBHome",
139:                            IN_SET_SESSION_CONTEXT | IN_EJB_CREATE
140:                                    | IN_EJB_REMOVE | IN_EJB_ACTIVATE
141:                                    | IN_EJB_PASSIVATE | IN_BUSINESS_METHOD
142:                                    | IN_AFTER_BEGIN | IN_BEFORE_COMPLETION
143:                                    | IN_AFTER_COMPLETION);
144:
145:                    return super .getEJBHome();
146:                }
147:
148:                public EJBLocalHome getEJBLocalHome() {
149:                    AllowedOperationsAssociation.assertAllowedIn(
150:                            "getEJBLocalHome", IN_SET_SESSION_CONTEXT
151:                                    | IN_EJB_CREATE | IN_EJB_REMOVE
152:                                    | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE
153:                                    | IN_BUSINESS_METHOD | IN_AFTER_BEGIN
154:                                    | IN_BEFORE_COMPLETION
155:                                    | IN_AFTER_COMPLETION);
156:
157:                    return super .getEJBLocalHome();
158:                }
159:
160:                /** Get the Principal for the current caller. This method
161:                 cannot return null according to the ejb-spec.
162:                 */
163:                public Principal getCallerPrincipal() {
164:                    AllowedOperationsAssociation.assertAllowedIn(
165:                            "getCallerPrincipal", IN_EJB_CREATE | IN_EJB_REMOVE
166:                                    | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE
167:                                    | IN_BUSINESS_METHOD | IN_AFTER_BEGIN
168:                                    | IN_BEFORE_COMPLETION
169:                                    | IN_AFTER_COMPLETION);
170:
171:                    return super .getCallerPrincipal();
172:                }
173:
174:                public boolean isCallerInRole(String id) {
175:                    AllowedOperationsAssociation.assertAllowedIn(
176:                            "isCallerInRole", IN_EJB_CREATE | IN_EJB_REMOVE
177:                                    | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE
178:                                    | IN_BUSINESS_METHOD | IN_AFTER_BEGIN
179:                                    | IN_BEFORE_COMPLETION
180:                                    | IN_AFTER_COMPLETION);
181:
182:                    return super .isCallerInRole(id);
183:                }
184:
185:                public EJBObject getEJBObject() {
186:                    AllowedOperationsAssociation.assertAllowedIn(
187:                            "getEJBObject", IN_EJB_CREATE | IN_EJB_REMOVE
188:                                    | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE
189:                                    | IN_BUSINESS_METHOD | IN_AFTER_BEGIN
190:                                    | IN_BEFORE_COMPLETION
191:                                    | IN_AFTER_COMPLETION);
192:
193:                    if (((StatefulSessionContainer) con).getRemoteClass() == null)
194:                        throw new IllegalStateException(
195:                                "No remote interface defined.");
196:
197:                    if (ejbObject == null) {
198:                        EJBProxyFactory proxyFactory = con.getProxyFactory();
199:                        if (proxyFactory == null) {
200:                            String defaultInvokerName = con.getBeanMetaData()
201:                                    .getContainerConfiguration()
202:                                    .getDefaultInvokerName();
203:                            proxyFactory = con
204:                                    .lookupProxyFactory(defaultInvokerName);
205:                        }
206:                        ejbObject = (EJBObject) proxyFactory
207:                                .getStatefulSessionEJBObject(id);
208:                    }
209:
210:                    return ejbObject;
211:                }
212:
213:                public Object getBusinessObject(Class businessInterface)
214:                        throws IllegalStateException {
215:                    throw new RuntimeException("NOT IMPLEMENTED");
216:                }
217:
218:                public Class getInvokedBusinessInterface()
219:                        throws IllegalStateException {
220:                    throw new RuntimeException("NOT IMPLEMENTED");
221:                }
222:
223:                public EJBLocalObject getEJBLocalObject() {
224:                    AllowedOperationsAssociation.assertAllowedIn(
225:                            "getEJBLocalObject", IN_EJB_CREATE | IN_EJB_REMOVE
226:                                    | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE
227:                                    | IN_BUSINESS_METHOD | IN_AFTER_BEGIN
228:                                    | IN_BEFORE_COMPLETION
229:                                    | IN_AFTER_COMPLETION);
230:
231:                    if (con.getLocalHomeClass() == null)
232:                        throw new IllegalStateException(
233:                                "No local interface for bean.");
234:                    if (ejbLocalObject == null) {
235:                        ejbLocalObject = ((StatefulSessionContainer) con)
236:                                .getLocalProxyFactory()
237:                                .getStatefulSessionEJBLocalObject(id);
238:                    }
239:                    return ejbLocalObject;
240:                }
241:
242:                public boolean getRollbackOnly() {
243:                    AllowedOperationsAssociation.assertAllowedIn(
244:                            "getRollbackOnly", IN_BUSINESS_METHOD
245:                                    | IN_AFTER_BEGIN | IN_BEFORE_COMPLETION);
246:
247:                    return super .getRollbackOnly();
248:                }
249:
250:                public void setRollbackOnly() {
251:                    AllowedOperationsAssociation.assertAllowedIn(
252:                            "setRollbackOnly", IN_BUSINESS_METHOD
253:                                    | IN_AFTER_BEGIN | IN_BEFORE_COMPLETION);
254:
255:                    super .setRollbackOnly();
256:                }
257:
258:                public UserTransaction getUserTransaction() {
259:                    AllowedOperationsAssociation.assertAllowedIn(
260:                            "getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE
261:                                    | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE
262:                                    | IN_BUSINESS_METHOD);
263:
264:                    return super .getUserTransaction();
265:                }
266:
267:                public TimerService getTimerService()
268:                        throws IllegalStateException {
269:                    throw new IllegalStateException(
270:                            "getTimerService should not be access from a stateful session bean");
271:                }
272:
273:                public MessageContext getMessageContext()
274:                        throws IllegalStateException {
275:                    AllowedOperationsAssociation.assertAllowedIn(
276:                            "getMessageContext", NOT_ALLOWED);
277:                    return null;
278:                }
279:
280:                public Object getPrimaryKey() {
281:                    return id;
282:                }
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.