Source Code Cross Referenced for PersonneEC2.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » beans » annuaire » 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.jtests.beans.annuaire 
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: PersonneEC2.java 4406 2004-03-19 11:57:20Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        // PersonneEC2.java
027:        package org.objectweb.jonas.jtests.beans.annuaire;
028:
029:        import java.rmi.RemoteException;
030:        import java.util.Collection;
031:        import java.util.Iterator;
032:
033:        import javax.ejb.CreateException;
034:        import javax.ejb.DuplicateKeyException;
035:        import javax.ejb.EntityBean;
036:        import javax.ejb.EntityContext;
037:        import javax.ejb.RemoveException;
038:        import javax.ejb.TimedObject;
039:        import javax.ejb.Timer;
040:        import javax.ejb.TimerService;
041:
042:        import org.objectweb.jonas.common.Log;
043:        import org.objectweb.util.monolog.api.BasicLevel;
044:        import org.objectweb.util.monolog.api.Logger;
045:
046:        /**
047:         * This is an entity bean with "container managed persistence version 2.x".
048:         * @author Philippe Durieux, Helene Joanin (jonas team)
049:         */
050:        public abstract class PersonneEC2 implements  EntityBean, TimedObject {
051:
052:            static protected Logger logger = null;
053:            EntityContext ejbContext;
054:
055:            // ------------------------------------------------------------------
056:            // Get and Set accessor methods of the bean's abstract schema
057:            // ------------------------------------------------------------------
058:            public abstract String getNom();
059:
060:            public abstract void setNom(String n);
061:
062:            public abstract String getNumero(); // Tx Attribute = Required
063:
064:            public abstract void setNumero(String n); // Tx Attribute = Required
065:
066:            public abstract int getTimerIdent();
067:
068:            public abstract void setTimerIdent(int id);
069:
070:            public abstract int getTimerCount();
071:
072:            public abstract void setTimerCount(int cnt);
073:
074:            // ------------------------------------------------------------------
075:            // EntityBean implementation
076:            // ------------------------------------------------------------------
077:
078:            /**
079:             * Set the associated entity context. The container invokes this method 
080:             * on an instance after the instance has been created.
081:             * This method is called in an unspecified transaction context. 
082:             * 
083:             * @param ctx - An EntityContext interface for the instance. The instance
084:             * should store the reference to the context in an instance variable.
085:             * @throws EJBException Thrown by the method to indicate a failure caused by a
086:             * system-level error.
087:             */
088:            public void setEntityContext(EntityContext ctx) {
089:                if (logger == null)
090:                    logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
091:                logger.log(BasicLevel.DEBUG, "");
092:                ejbContext = ctx;
093:            }
094:
095:            /**
096:             * Unset the associated entity context. The container calls this method
097:             * before removing the instance. 
098:             * This is the last method that the container invokes on the instance.
099:             * The Java garbage collector will eventually invoke the finalize() method
100:             * on the instance.
101:             * This method is called in an unspecified transaction context.
102:             *
103:             * @throws EJBException Thrown by the method to indicate a failure caused by a
104:             * system-level error.
105:             */
106:            public void unsetEntityContext() {
107:                logger.log(BasicLevel.DEBUG, "");
108:                ejbContext = null;
109:            }
110:
111:            /**
112:             * A container invokes this method before it removes the EJB object
113:             * that is currently associated with the instance. This method is
114:             * invoked when a client invokes a remove operation on the enterprise Bean's
115:             * home interface or the EJB object's remote interface. This method
116:             * transitions the instance from the ready state to the pool of available
117:             * instances.
118:             *
119:             * This method is called in the transaction context of the remove operation.
120:             * @throws RemoveException  The enterprise Bean does not allow destruction of the object.
121:             * @throws EJBException - Thrown by the method to indicate a failure caused by a system-level
122:             * error.
123:             */
124:            public void ejbRemove() throws RemoveException {
125:                logger.log(BasicLevel.DEBUG, "");
126:            }
127:
128:            /**
129:             * A container invokes this method to instruct the instance to synchronize
130:             * its state by loading it state from the underlying database. 
131:             * This method always executes in the proper transaction context.
132:             *
133:             * @throws EJBException Thrown by the method to indicate a failure caused by
134:             * a system-level error.
135:             */
136:            public void ejbLoad() {
137:                logger.log(BasicLevel.DEBUG, "");
138:            }
139:
140:            /**
141:             * A container invokes this method to instruct the instance to synchronize
142:             * its state by storing it to the underlying database. 
143:             * This method always executes in the proper transaction context.
144:             *
145:             * @throws EJBException Thrown by the method to indicate a failure caused by
146:             * a system-level error.
147:             */
148:            public void ejbStore() {
149:                logger.log(BasicLevel.DEBUG, "");
150:            }
151:
152:            /**
153:             * There must be an ejbPostCreate par ejbCreate method
154:             *
155:             * @throws CreateException Failure to create an entity EJB object.
156:             */
157:            public void ejbPostCreate(String nom, String numero)
158:                    throws CreateException {
159:                logger.log(BasicLevel.DEBUG, "");
160:            }
161:
162:            public void ejbPostCreate(String nom, String numero, boolean t)
163:                    throws CreateException {
164:                logger.log(BasicLevel.DEBUG, "");
165:            }
166:
167:            public java.lang.String ejbCreate(String nom, String numero)
168:                    throws CreateException, DuplicateKeyException {
169:                logger.log(BasicLevel.DEBUG, "ejbCreate(" + nom + ", " + numero
170:                        + ")");
171:
172:                // Init here the bean fields
173:                setNom(nom);
174:                setNumero(numero);
175:                setTimerIdent(0);
176:                setTimerCount(0);
177:
178:                // In CMP, should return null.
179:                return null;
180:            }
181:
182:            public java.lang.String ejbCreate(String nom, String numero,
183:                    boolean t) throws CreateException, DuplicateKeyException {
184:                logger.log(BasicLevel.DEBUG, "ejbCreate nom numero boolean");
185:
186:                // Init here the bean fields
187:                setNom(nom);
188:                setNumero(numero);
189:                setTimerIdent(0);
190:                setTimerCount(0);
191:
192:                // In CMP, should return null.
193:                return null;
194:            }
195:
196:            /**
197:             * This method is called before the instance enters the "passive" state. 
198:             * The instance should release any resources that it can re-acquire later in the 
199:             * ejbActivate() method.
200:             * After the passivate method completes, the instance must be in a state that 
201:             * allows the container to use the Java Serialization protocol to externalize 
202:             * and store away the instance's state. 
203:             * This method is called with no transaction context. 
204:             *
205:             * @exception EJBException - Thrown if the instance could not perform the 
206:             * function requested by the container 
207:             */
208:            public void ejbPassivate() {
209:                logger.log(BasicLevel.DEBUG, "");
210:            }
211:
212:            /**
213:             * This method is called when the instance is activated from its "passive" state.
214:             * The instance should acquire any resource that it has released earlier in the 
215:             * ejbPassivate() method. 
216:             * This method is called with no transaction context.
217:             * 
218:             * @exception EJBException - Thrown if the instance could not perform the 
219:             * function requested by the container 
220:             */
221:            public void ejbActivate() {
222:                logger.log(BasicLevel.DEBUG, "");
223:            }
224:
225:            // ------------------------------------------------------------------
226:            // Personne implementation
227:            // ------------------------------------------------------------------
228:
229:            /**
230:             * getNumeroNTX / Tx Attribute = Supports
231:             */
232:            public String getNumeroNTX() {
233:                logger.log(BasicLevel.DEBUG, "");
234:                return getNumero();
235:            }
236:
237:            /**
238:             * setNumeroNTX / Tx Attribute = Supports
239:             */
240:            public void setNumeroNTX(String s) {
241:                logger.log(BasicLevel.DEBUG, "");
242:                setNumero(s);
243:            }
244:
245:            //
246:            // Methods only implemented in the entity bean with "CMP version 1.x"
247:            // used to test the isModified extension for CMP version 1 Entity Bean.
248:            // (defined here to have a common interface)
249:            //
250:
251:            public boolean isModified() {
252:                throw new UnsupportedOperationException();
253:            }
254:
255:            public void reset() {
256:                throw new UnsupportedOperationException();
257:            }
258:
259:            public boolean isModifiedCalled() {
260:                throw new UnsupportedOperationException();
261:            }
262:
263:            public boolean ejbStoreCalled() {
264:                throw new UnsupportedOperationException();
265:            }
266:
267:            public boolean isDirty() {
268:                throw new UnsupportedOperationException();
269:            }
270:
271:            public int setTimer(int dur, int period) {
272:                TimerService timerservice = ejbContext.getTimerService();
273:                Timer mt = null;
274:                int ret = getTimerIdent() + 1;
275:                setTimerIdent(ret);
276:                if (period > 0) {
277:                    mt = timerservice.createTimer(1000 * dur, 1000 * period,
278:                            new Integer(ret));
279:                } else {
280:                    mt = timerservice.createTimer(1000 * dur, new Integer(ret));
281:                }
282:                return ret;
283:            }
284:
285:            public void cancelTimer(int ident) throws RemoteException {
286:                TimerService timerservice = ejbContext.getTimerService();
287:                Collection timerList = timerservice.getTimers();
288:                for (Iterator i = timerList.iterator(); i.hasNext();) {
289:                    Timer t = (Timer) i.next();
290:                    Integer id = (Integer) t.getInfo();
291:                    if (id.intValue() == ident) {
292:                        t.cancel();
293:                    }
294:                }
295:            }
296:
297:            public long getTimeRemaining(int ident) throws RemoteException {
298:                TimerService timerservice = ejbContext.getTimerService();
299:                Collection timerList = timerservice.getTimers();
300:                long ret = -1;
301:                for (Iterator i = timerList.iterator(); i.hasNext();) {
302:                    Timer t = (Timer) i.next();
303:                    Integer id = (Integer) t.getInfo();
304:                    if (id.intValue() == ident) {
305:                        ret = t.getTimeRemaining();
306:                    }
307:                }
308:                return ret;
309:            }
310:
311:            // -----------------------------------------------------------
312:            // TimedObject implementation
313:            // -----------------------------------------------------------
314:
315:            /**
316:             * A timer is expired.
317:             */
318:            public void ejbTimeout(Timer timer) {
319:                setTimerCount(getTimerCount() + 1);
320:            }
321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.