Source Code Cross Referenced for JAASOpBean.java in  » J2EE » JOnAS-4.8.6 » jaasclient » beans » secusb » 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 » jaasclient.beans.secusb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 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:         * Initial developer(s):
022:         * --------------------------------------------------------------------------
023:         * $Id: JAASOpBean.java 4618 2004-04-19 06:39:30Z benoitf $
024:         * --------------------------------------------------------------------------
025:         */package jaasclient.beans.secusb;
026:
027:        import javax.ejb.EJBException;
028:        import javax.ejb.SessionBean;
029:        import javax.ejb.SessionContext;
030:        import javax.ejb.SessionSynchronization;
031:
032:        /**
033:         * This is an example of Session Bean, statefull, and synchronized.
034:         * @author JOnAS team
035:         */
036:        public class JAASOpBean implements  SessionBean, SessionSynchronization {
037:
038:            /**
039:             * Actual state of the bean
040:             */
041:            private int total = 0;
042:
043:            /**
044:             * value inside Tx, not yet committed.
045:             */
046:            private int newtotal = 0;
047:
048:            /**
049:             * User client
050:             */
051:            private String clientUser = null;
052:
053:            /* ========================= ejbCreate methods ============================ */
054:
055:            /**
056:             * There must be one ejbCreate() method per create() method on the Home
057:             * interface, and with the same signature.
058:             * @param user the user name
059:             */
060:            public void ejbCreate(String user) {
061:                total = 0;
062:                // in case we are outside transactions
063:                newtotal = total;
064:                clientUser = user;
065:            }
066:
067:            /* =============== javax.ejb.SessionBean 2.0 implementation ============== */
068:
069:            /**
070:             * The activate method is called when the instance is activated from its
071:             * "passive" state. The instance should acquire any resource that it has
072:             * released earlier in the ejbPassivate() method. This method is called with
073:             * no transaction context.
074:             * @throws EJBException Thrown by the method to indicate a failure caused by
075:             *         a system-level error.
076:             * @throws java.rmi.RemoteException This exception is defined in the method
077:             *         signature to provide backward compatibility for enterprise beans
078:             *         written for the EJB 1.0 specification. Enterprise beans written
079:             *         for the EJB 1.1 specification should throw the
080:             *         javax.ejb.EJBException instead of this exception. Enterprise
081:             *         beans written for the EJB2.0 and higher specifications must throw
082:             *         the javax.ejb.EJBException instead of this exception.
083:             */
084:            public void ejbActivate() throws EJBException,
085:                    java.rmi.RemoteException {
086:                // Nothing to do for this simple example
087:            }
088:
089:            /**
090:             * The passivate method is called before the instance enters the "passive"
091:             * state. The instance should release any resources that it can re-acquire
092:             * later in the ejbActivate() method. After the passivate method completes,
093:             * the instance must be in a state that allows the container to use the Java
094:             * Serialization protocol to externalize and store away the instance's
095:             * state. This method is called with no transaction context.
096:             * @throws EJBException Thrown by the method to indicate a failure caused by
097:             *         a system-level error.
098:             * @throws java.rmi.RemoteException This exception is defined in the method
099:             *         signature to provide backward compatibility for enterprise beans
100:             *         written for the EJB 1.0 specification. Enterprise beans written
101:             *         for the EJB 1.1 specification should throw the
102:             *         javax.ejb.EJBException instead of this exception. Enterprise
103:             *         beans written for the EJB2.0 and higher specifications must throw
104:             *         the javax.ejb.EJBException instead of this exception.
105:             */
106:            public void ejbPassivate() throws EJBException,
107:                    java.rmi.RemoteException {
108:                // Nothing to do for this simple example
109:            }
110:
111:            /**
112:             * A container invokes this method before it ends the life of the session
113:             * object. This happens as a result of a client's invoking a remove
114:             * operation, or when a container decides to terminate the session object
115:             * after a timeout. This method is called with no transaction context.
116:             * @throws EJBException Thrown by the method to indicate a failure caused by
117:             *         a system-level error.
118:             * @throws java.rmi.RemoteException This exception is defined in the method
119:             *         signature to provide backward compatibility for enterprise beans
120:             *         written for the EJB 1.0 specification. Enterprise beans written
121:             *         for the EJB 1.1 specification should throw the
122:             *         javax.ejb.EJBException instead of this exception. Enterprise
123:             *         beans written for the EJB2.0 and higher specifications must throw
124:             *         the javax.ejb.EJBException instead of this exception.
125:             */
126:            public void ejbRemove() throws EJBException,
127:                    java.rmi.RemoteException {
128:                // Nothing to do for this simple example
129:            }
130:
131:            /**
132:             * Set the associated session context. The container calls this method after
133:             * the instance creation. The enterprise Bean instance should store the
134:             * reference to the context object in an instance variable. This method is
135:             * called with no transaction context.
136:             * @param sessionContext A SessionContext interface for the instance.
137:             * @throws EJBException Thrown by the method to indicate a failure caused by
138:             *         a system-level error.
139:             * @throws java.rmi.RemoteException This exception is defined in the method
140:             *         signature to provide backward compatibility for applications
141:             *         written for the EJB 1.0 specification. Enterprise beans written
142:             *         for the EJB 1.1 specification should throw the
143:             *         javax.ejb.EJBException instead of this exception. Enterprise
144:             *         beans written for the EJB2.0 and higher specifications must throw
145:             *         the javax.ejb.EJBException instead of this exception.
146:             */
147:            public void setSessionContext(SessionContext sessionContext)
148:                    throws EJBException, java.rmi.RemoteException {
149:            }
150:
151:            /*
152:             * ============== javax.ejb.SessionSynchronization implementation
153:             * =============
154:             */
155:
156:            /**
157:             * The afterBegin method notifies a session Bean instance that a new
158:             * transaction has started, and that the subsequent business methods on the
159:             * instance will be invoked in the context of the transaction. The instance
160:             * can use this method, for example, to read data from a database and cache
161:             * the data in the instance fields. This method executes in the proper
162:             * transaction context.
163:             * @throws EJBException Thrown by the method to indicate a failure caused by
164:             *         a system-level error.
165:             * @throws java.rmi.RemoteException - This exception is defined in the
166:             *         method signature to provide backward compatibility for enterprise
167:             *         beans written for the EJB 1.0 specification. Enterprise beans
168:             *         written for the EJB 1.1 and higher specifications should throw
169:             *         the javax.ejb.EJBException instead of this exception. Enterprise
170:             *         beans written for the EJB 2.0 and higher specifications must not
171:             *         throw the java.rmi.RemoteException.
172:             */
173:            public void afterBegin() throws EJBException,
174:                    java.rmi.RemoteException {
175:                newtotal = total;
176:            }
177:
178:            /**
179:             * The beforeCompletion method notifies a session Bean instance that a
180:             * transaction is about to be committed. The instance can use this method,
181:             * for example, to write any cached data to a database. This method executes
182:             * in the proper transaction context. <b>Note: </b> The instance may still
183:             * cause the container to rollback the transaction by invoking the
184:             * setRollbackOnly() method on the instance context, or by throwing an
185:             * exception.
186:             * @throws EJBException Thrown by the method to indicate a failure caused by
187:             *         a system-level error.
188:             * @throws java.rmi.RemoteException - This exception is defined in the
189:             *         method signature to provide backward compatibility for enterprise
190:             *         beans written for the EJB 1.0 specification. Enterprise beans
191:             *         written for the EJB 1.1 and higher specifications should throw
192:             *         the javax.ejb.EJBException instead of this exception. Enterprise
193:             *         beans written for the EJB 2.0 and higher specifications must not
194:             *         throw the java.rmi.RemoteException.
195:             */
196:            public void beforeCompletion() throws EJBException,
197:                    java.rmi.RemoteException {
198:            }
199:
200:            /**
201:             * The afterCompletion method notifies a session Bean instance that a
202:             * transaction commit protocol has completed, and tells the instance whether
203:             * the transaction has been committed or rolled back. This method executes
204:             * with no transaction context.
205:             * @param committed - True if the transaction has been committed, false if
206:             *        is has been rolled back.
207:             * @throws EJBException Thrown by the method to indicate a failure caused by
208:             *         a system-level error.
209:             * @throws java.rmi.RemoteException - This exception is defined in the
210:             *         method signature to provide backward compatibility for enterprise
211:             *         beans written for the EJB 1.0 specification. Enterprise beans
212:             *         written for the EJB 1.1 and higher specifications should throw
213:             *         the javax.ejb.EJBException instead of this exception. Enterprise
214:             *         beans written for the EJB 2.0 and higher specifications must not
215:             *         throw the java.rmi.RemoteException.
216:             */
217:            public void afterCompletion(boolean committed) throws EJBException,
218:                    java.rmi.RemoteException {
219:
220:                if (committed) {
221:                    total = newtotal;
222:                } else {
223:                    newtotal = total;
224:                }
225:            }
226:
227:            /* ========================= Op implementation ============================ */
228:
229:            /**
230:             * Business method implementation.
231:             * @param s nb of shares to be bought
232:             */
233:            public void buy(int s) {
234:                newtotal = newtotal + s;
235:                return;
236:            }
237:
238:            /**
239:             * Business method implementation.
240:             * @return the nb of shares bought
241:             */
242:            public int read() {
243:                return newtotal;
244:            }
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.