Source Code Cross Referenced for JStatelessContext.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 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: JStatelessContext.java 6673 2005-04-28 16:53:00Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ejb.container;
025:
026:        import java.io.Serializable;
027:        import java.rmi.RemoteException;
028:        import java.security.Principal;
029:        import java.util.Collection;
030:        import java.util.Date;
031:        import java.util.List;
032:
033:        import javax.ejb.EJBException;
034:        import javax.ejb.EJBHome;
035:        import javax.ejb.EJBLocalHome;
036:        import javax.ejb.RemoveException;
037:        import javax.ejb.SessionBean;
038:        import javax.ejb.Timer;
039:        import javax.ejb.TimerService;
040:        import javax.xml.rpc.handler.MessageContext;
041:
042:        import org.objectweb.util.monolog.api.BasicLevel;
043:
044:        /**
045:         * This class extends JSessionContext in case of Stateless Session Bean.
046:         * @author Philippe Durieux
047:         */
048:        public class JStatelessContext extends JSessionContext implements 
049:                TimerService {
050:
051:            /**
052:             * constructor
053:             * @param bf The Bean Factory
054:             * @param sb The Session Bean instance.
055:             */
056:            public JStatelessContext(JSessionFactory bf, SessionBean sb) {
057:                super (bf, sb);
058:                if (TraceEjb.isDebugIc()) {
059:                    TraceEjb.interp.log(BasicLevel.DEBUG, "");
060:                }
061:            }
062:
063:            /**
064:             * Get access to the EJB Timer Service.
065:             * @return the EJB Timer Service
066:             * @throws IllegalStateException Thrown if the instance is not allowed to
067:             *         use this method
068:             */
069:            public TimerService getTimerService() throws IllegalStateException {
070:                if (TraceEjb.isDebugIc()) {
071:                    TraceEjb.interp.log(BasicLevel.DEBUG, "");
072:                }
073:                if (getState() == 0) {
074:                    throw new IllegalStateException(
075:                            "the instance is not allowed to call this method");
076:                }
077:                if (getState() == 1) {
078:                    // Called from ejbCreate : getTimerService should work, but
079:                    // not the timer operations! (See spec EJB 2.1 page 100)
080:                    return this ;
081:                }
082:                return bf.getTimerService();
083:            }
084:
085:            /**
086:             * set this instance as removed
087:             */
088:            public void setRemoved() throws RemoteException, RemoveException {
089:                if (TraceEjb.isDebugIc()) {
090:                    TraceEjb.interp.log(BasicLevel.DEBUG, "");
091:                }
092:                // Set a flag to finish remove at postInvoke.
093:                ismarkedremoved = true;
094:            }
095:
096:            /**
097:             * Obtain a reference to the JAX-RPC MessageContext.
098:             * @return The MessageContext for this web service invocation.
099:             * @throws java.lang.IllegalStateException - the instance is in a state that
100:             *         does not allow access to this method.
101:             */
102:            public MessageContext getMessageContext()
103:                    throws IllegalStateException {
104:                if (bs == null) {
105:                    throw new IllegalStateException(
106:                            "No SessionSwitch for that bean");
107:                }
108:                MessageContext mc = ((JStatelessSwitch) bs).getMsgContext();
109:                if (mc == null) {
110:                    throw new IllegalStateException(
111:                            "No ServiceEndpoint for that bean");
112:                }
113:                return mc;
114:            }
115:
116:            /**
117:             * Set the connection list for this instance.
118:             */
119:            public void setConnectionList(List conlist) {
120:                throw new IllegalStateException(
121:                        "Stateless beans should not reuse connections");
122:            }
123:
124:            /**
125:             * Obtain the java.security.Principal that identifies the caller.
126:             * throws a java.lang.IllegalStateException if there is no security context available
127:             * @return The Principal object that identifies the caller.
128:             * @throws IllegalStateException no security context exists
129:             */
130:            public Principal getCallerPrincipal() throws IllegalStateException {
131:                if (getState() < 2) {
132:                    throw new IllegalStateException(
133:                            "the instance is not allowed to call this method");
134:                }
135:                return super .getCallerPrincipal();
136:            }
137:
138:            /**
139:             * Test if the caller has a given role.
140:             * @param roleName The name of the security role. The role must be one of
141:             *        the security-role-ref that is defined in the deployment
142:             *        descriptor.
143:             * @return True if the caller has the specified role.
144:             * @throws IllegalStateException Security service not started
145:             */
146:            public boolean isCallerInRole(String roleName)
147:                    throws IllegalStateException {
148:                if (getState() < 2) {
149:                    throw new IllegalStateException(
150:                            "the instance is not allowed to call this method");
151:                }
152:                return super .isCallerInRole(roleName);
153:            }
154:
155:            /**
156:             * @see javax.ejb.TimerService#createTimer(long, java.io.Serializable)
157:             */
158:            public Timer createTimer(long arg0, Serializable arg1)
159:                    throws IllegalArgumentException, IllegalStateException,
160:                    EJBException {
161:                // Not allowed when called from ejbCreate
162:                if (getState() < 2) {
163:                    throw new IllegalStateException(
164:                            "the instance is not allowed to call this method");
165:                }
166:                return getTimerService().createTimer(arg0, arg1);
167:            }
168:
169:            /**
170:             * @see javax.ejb.TimerService#createTimer(long, long, java.io.Serializable)
171:             */
172:            public Timer createTimer(long arg0, long arg1, Serializable arg2)
173:                    throws IllegalArgumentException, IllegalStateException,
174:                    EJBException {
175:                // Not allowed when called from ejbCreate
176:                if (getState() < 2) {
177:                    throw new IllegalStateException(
178:                            "the instance is not allowed to call this method");
179:                }
180:                return getTimerService().createTimer(arg0, arg1, arg2);
181:            }
182:
183:            /**
184:             * @see javax.ejb.TimerService#createTimer(java.util.Date, java.io.Serializable)
185:             */
186:            public Timer createTimer(Date arg0, Serializable arg1)
187:                    throws IllegalArgumentException, IllegalStateException,
188:                    EJBException {
189:                // Not allowed when called from ejbCreate
190:                if (getState() < 2) {
191:                    throw new IllegalStateException(
192:                            "the instance is not allowed to call this method");
193:                }
194:                return getTimerService().createTimer(arg0, arg1);
195:            }
196:
197:            /**
198:             * @see javax.ejb.TimerService#createTimer(java.util.Date, long, java.io.Serializable)
199:             */
200:            public Timer createTimer(Date arg0, long arg1, Serializable arg2)
201:                    throws IllegalArgumentException, IllegalStateException,
202:                    EJBException {
203:                // Not allowed when called from ejbCreate
204:                if (getState() < 2) {
205:                    throw new IllegalStateException(
206:                            "the instance is not allowed to call this method");
207:                }
208:                return getTimerService().createTimer(arg0, arg1, arg2);
209:            }
210:
211:            /**
212:             * @see javax.ejb.TimerService#getTimers()
213:             */
214:            public Collection getTimers() throws IllegalStateException,
215:                    EJBException {
216:                // Not allowed when called from ejbCreate
217:                if (getState() < 2) {
218:                    throw new IllegalStateException(
219:                            "the instance is not allowed to call this method");
220:                }
221:                return getTimerService().getTimers();
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.