Source Code Cross Referenced for MdbContext.java in  » J2EE » openejb3 » org » apache » openejb » core » mdb » 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 » openejb3 » org.apache.openejb.core.mdb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */package org.apache.openejb.core.mdb;
017:
018:        import java.security.Principal;
019:        import javax.ejb.EJBHome;
020:        import javax.ejb.EJBLocalHome;
021:        import javax.ejb.MessageDrivenContext;
022:        import javax.ejb.TimerService;
023:        import javax.transaction.TransactionManager;
024:        import javax.transaction.UserTransaction;
025:
026:        import org.apache.openejb.core.BaseContext;
027:        import org.apache.openejb.core.Operation;
028:        import org.apache.openejb.core.ThreadContext;
029:        import org.apache.openejb.spi.SecurityService;
030:
031:        /**
032:         * @version $Rev: 602704 $ $Date: 2007-12-09 09:58:22 -0800 $
033:         */
034:        public class MdbContext extends BaseContext implements 
035:                MessageDrivenContext {
036:
037:            protected final static State[] states = new State[Operation
038:                    .values().length];
039:
040:            public static State[] getStates() {
041:                return states;
042:            }
043:
044:            public MdbContext(TransactionManager transactionManager,
045:                    SecurityService securityService) {
046:                super (transactionManager, securityService);
047:            }
048:
049:            protected MdbContext(TransactionManager transactionManager,
050:                    SecurityService securityService,
051:                    UserTransaction userTransaction) {
052:                super (transactionManager, securityService, userTransaction);
053:            }
054:
055:            protected State getState() {
056:                Operation operation = ThreadContext.getThreadContext()
057:                        .getCurrentOperation();
058:                State state = states[operation.ordinal()];
059:
060:                if (state == null)
061:                    throw new IllegalArgumentException("Invalid operation "
062:                            + operation + " for this context");
063:
064:                return state;
065:            }
066:
067:            /**
068:             * Dependency injection methods (e.g., setMessageDrivenContext)
069:             */
070:            protected static class InjectionMdbState extends State {
071:                @Override
072:                public EJBHome getEJBHome() {
073:                    throw new IllegalStateException();
074:                }
075:
076:                @Override
077:                public EJBLocalHome getEJBLocalHome() {
078:                    throw new IllegalStateException();
079:                }
080:
081:                @Override
082:                public Principal getCallerPrincipal(
083:                        SecurityService securityService) {
084:                    throw new IllegalStateException();
085:                }
086:
087:                @Override
088:                public boolean isCallerInRole(SecurityService securityService,
089:                        String roleName) {
090:                    throw new IllegalStateException();
091:                }
092:
093:                @Override
094:                public UserTransaction getUserTransaction(
095:                        UserTransaction userTransaction)
096:                        throws IllegalStateException {
097:                    throw new IllegalStateException();
098:                }
099:
100:                @Override
101:                public boolean getRollbackOnly(
102:                        TransactionManager transactionManager)
103:                        throws IllegalStateException {
104:                    throw new IllegalStateException();
105:                }
106:
107:                @Override
108:                public void setRollbackOnly(
109:                        TransactionManager transactionManager)
110:                        throws IllegalStateException {
111:                    throw new IllegalStateException();
112:                }
113:
114:                @Override
115:                public TimerService getTimerService()
116:                        throws IllegalStateException {
117:                    throw new IllegalStateException();
118:                }
119:
120:                @Override
121:                public boolean isUserTransactionAccessAllowed() {
122:                    return false;
123:                }
124:
125:                @Override
126:                public boolean isMessageContextAccessAllowed() {
127:                    return false;
128:                }
129:
130:                @Override
131:                public boolean isEntityManagerFactoryAccessAllowed() {
132:                    return false;
133:                }
134:
135:                @Override
136:                public boolean isEntityManagerAccessAllowed() {
137:                    return false;
138:                }
139:
140:                @Override
141:                public boolean isTimerAccessAllowed() {
142:                    return false;
143:                }
144:
145:                @Override
146:                public boolean isTimerMethodAllowed() {
147:                    return false;
148:                }
149:            }
150:
151:            /**
152:             * PostConstruct, Pre-Destroy lifecycle callback interceptor methods
153:             */
154:            protected static class LifecycleMdbState extends State {
155:                @Override
156:                public EJBHome getEJBHome() {
157:                    throw new IllegalStateException();
158:                }
159:
160:                @Override
161:                public EJBLocalHome getEJBLocalHome() {
162:                    throw new IllegalStateException();
163:                }
164:
165:                @Override
166:                public Principal getCallerPrincipal(
167:                        SecurityService securityService) {
168:                    throw new IllegalStateException();
169:                }
170:
171:                @Override
172:                public boolean isCallerInRole(SecurityService securityService,
173:                        String roleName) {
174:                    throw new IllegalStateException();
175:                }
176:
177:                @Override
178:                public boolean getRollbackOnly(
179:                        TransactionManager transactionManager)
180:                        throws IllegalStateException {
181:                    throw new IllegalStateException();
182:                }
183:
184:                @Override
185:                public void setRollbackOnly(
186:                        TransactionManager transactionManager)
187:                        throws IllegalStateException {
188:                    throw new IllegalStateException();
189:                }
190:
191:                @Override
192:                public boolean isMessageContextAccessAllowed() {
193:                    return false;
194:                }
195:
196:                @Override
197:                public boolean isEntityManagerAccessAllowed() {
198:                    return false;
199:                }
200:
201:                @Override
202:                public boolean isTimerAccessAllowed() {
203:                    return super .isTimerAccessAllowed(); //todo: consider this autogenerated code
204:                }
205:
206:                @Override
207:                public boolean isTimerMethodAllowed() {
208:                    return false;
209:                }
210:            }
211:
212:            /**
213:             * Message listener method, business method interceptor method
214:             * and imeout callback method
215:             */
216:            protected static class BusinessTimeoutMdbState extends State {
217:                @Override
218:                public EJBHome getEJBHome() {
219:                    throw new IllegalStateException();
220:                }
221:
222:                @Override
223:                public EJBLocalHome getEJBLocalHome() {
224:                    throw new IllegalStateException();
225:                }
226:
227:                @Override
228:                public boolean isCallerInRole(SecurityService securityService,
229:                        String roleName) {
230:                    throw new IllegalStateException();
231:                }
232:
233:            }
234:
235:            static {
236:                states[Operation.INJECTION.ordinal()] = new InjectionMdbState();
237:                states[Operation.CREATE.ordinal()] = new LifecycleMdbState();
238:                states[Operation.POST_CONSTRUCT.ordinal()] = new LifecycleMdbState();
239:                states[Operation.PRE_DESTROY.ordinal()] = new LifecycleMdbState();
240:                states[Operation.BUSINESS.ordinal()] = new BusinessTimeoutMdbState();
241:                states[Operation.TIMEOUT.ordinal()] = new BusinessTimeoutMdbState();
242:            }
243:
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.