Source Code Cross Referenced for SimpleSL.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » beans » transacted » 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.transacted 
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: SimpleSL.java 8456 2006-06-13 08:28:03Z durieuxp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.beans.transacted;
027:
028:        import java.rmi.RemoteException;
029:        import java.util.Collection;
030:        import java.util.Iterator;
031:
032:        import javax.ejb.EJBException;
033:        import javax.ejb.SessionBean;
034:        import javax.ejb.SessionContext;
035:        import javax.ejb.TimedObject;
036:        import javax.ejb.Timer;
037:        import javax.ejb.TimerHandle;
038:        import javax.ejb.TimerService;
039:        import javax.naming.InitialContext;
040:        import javax.naming.NamingException;
041:
042:        import org.objectweb.util.monolog.api.BasicLevel;
043:
044:        public class SimpleSL extends SimpleCommon implements  SessionBean,
045:                TimedObject {
046:
047:            protected SessionContext sessionContext;
048:            static protected int timercount = 0;
049:
050:            public void setSessionContext(SessionContext sessionContext) {
051:                initLogger();
052:                logger.log(BasicLevel.DEBUG, "");
053:                this .sessionContext = sessionContext;
054:            }
055:
056:            public void ejbActivate() {
057:                logger.log(BasicLevel.DEBUG, "");
058:            }
059:
060:            public void ejbPassivate() {
061:                logger.log(BasicLevel.DEBUG, "");
062:            }
063:
064:            public void ejbRemove() {
065:                logger.log(BasicLevel.DEBUG, "");
066:            }
067:
068:            public void ejbCreate() {
069:                logger.log(BasicLevel.DEBUG, "");
070:                try {
071:                    InitialContext ictx = new InitialContext();
072:                } catch (NamingException e) {
073:                    throw new EJBException(e);
074:                }
075:            }
076:
077:            public int setTimer(int dur, int period) {
078:                logger.log(BasicLevel.DEBUG, "");
079:                TimerService timerservice = sessionContext.getTimerService();
080:                int ret = dur * 10 + period;
081:                if (period > 0) {
082:                    timerservice.createTimer(dur * 1000, period * 1000,
083:                            new Integer(ret));
084:                } else {
085:                    timerservice.createTimer(dur * 1000, new Integer(ret));
086:                }
087:                return ret;
088:            }
089:
090:            public int setTimer(java.util.Date date, int period) {
091:                logger.log(BasicLevel.DEBUG, "");
092:                TimerService timerservice = sessionContext.getTimerService();
093:                int ret = 200 + period;
094:                if (period > 0) {
095:                    timerservice.createTimer(date, period * 1000, new Integer(
096:                            ret));
097:                } else {
098:                    timerservice.createTimer(date, new Integer(ret));
099:                }
100:                return ret;
101:            }
102:
103:            public int setTimerGetHandle(int dur, int period) {
104:                logger.log(BasicLevel.DEBUG, "");
105:                TimerService timerservice = sessionContext.getTimerService();
106:                int ret = dur * 10 + period;
107:                Timer t = null;
108:                if (period > 0) {
109:                    t = timerservice.createTimer(dur * 1000, period * 1000,
110:                            new Integer(ret));
111:                } else {
112:                    t = timerservice.createTimer(dur * 1000, new Integer(ret));
113:                }
114:                TimerHandle hdl = t.getHandle();
115:                TimerHandle hdl2 = getDeserializedHandle(hdl);
116:                if (!timersAreIdentical(hdl, hdl2)) {
117:                    logger.log(BasicLevel.ERROR, "Bad timer handle");
118:                    throw new EJBException("Bad timer handle");
119:                }
120:                return ret;
121:            }
122:
123:            public TimerHandle getTimerHandle(int ident) {
124:                logger.log(BasicLevel.DEBUG, "");
125:                TimerHandle hdl = null;
126:                TimerService timerservice = sessionContext.getTimerService();
127:                Collection timerList = timerservice.getTimers();
128:                for (Iterator i = timerList.iterator(); i.hasNext();) {
129:                    Timer t = (Timer) i.next();
130:                    Integer id = (Integer) t.getInfo();
131:                    if (id.intValue() == ident) {
132:                        hdl = t.getHandle();
133:                        TimerHandle hdl2 = getDeserializedHandle(hdl);
134:                        if (!timersAreIdentical(hdl, hdl2)) {
135:                            logger.log(BasicLevel.ERROR, "Bad timer handle");
136:                            throw new EJBException("Bad timer handle");
137:                        }
138:                        break;
139:                    }
140:                }
141:                return hdl;
142:            }
143:
144:            public void cancelTimer(int ident) {
145:                logger.log(BasicLevel.DEBUG, "");
146:                TimerService timerservice = sessionContext.getTimerService();
147:                Collection timerList = timerservice.getTimers();
148:                for (Iterator i = timerList.iterator(); i.hasNext();) {
149:                    Timer t = (Timer) i.next();
150:                    Integer id = (Integer) t.getInfo();
151:                    if (id.intValue() == ident) {
152:                        t.cancel();
153:                    }
154:                }
155:            }
156:
157:            public void cancelTimers() {
158:                logger.log(BasicLevel.DEBUG, "");
159:                TimerService timerservice = sessionContext.getTimerService();
160:                Collection timerList = timerservice.getTimers();
161:                for (Iterator i = timerList.iterator(); i.hasNext();) {
162:                    Timer t = (Timer) i.next();
163:                    t.cancel();
164:                }
165:            }
166:
167:            public long getTimeRemaining(int ident) {
168:                logger.log(BasicLevel.DEBUG, "");
169:                TimerService timerservice = sessionContext.getTimerService();
170:                Collection timerList = timerservice.getTimers();
171:                long ret = -1;
172:                for (Iterator i = timerList.iterator(); i.hasNext();) {
173:                    Timer t = (Timer) i.next();
174:                    Integer id = (Integer) t.getInfo();
175:                    if (id.intValue() == ident) {
176:                        ret = t.getTimeRemaining();
177:                    }
178:                }
179:                return ret;
180:            }
181:
182:            public int getTimerNumber() {
183:                logger.log(BasicLevel.DEBUG, "");
184:                TimerService timerservice = sessionContext.getTimerService();
185:                Collection timerList = timerservice.getTimers();
186:                return timerList.size();
187:            }
188:
189:            public int getTimerCount() {
190:                logger.log(BasicLevel.DEBUG, "");
191:                return timercount;
192:            }
193:
194:            /**
195:             * This support method calls a required method
196:             */
197:            public boolean supports_call_required() throws RemoteException {
198:                logger.log(BasicLevel.DEBUG, "");
199:                Simple mysession = (Simple) sessionContext.getEJBObject();
200:                return mysession.opwith_required();
201:            }
202:
203:            public void startInfoTimer(int dur, String info)
204:                    throws RemoteException {
205:                logger.log(BasicLevel.ERROR, "not implemented");
206:            }
207:
208:            // -----------------------------------------------------------
209:            // TimedObject implementation
210:            // -----------------------------------------------------------
211:
212:            /**
213:             * A timer is expired.
214:             */
215:            public void ejbTimeout(Timer timer) {
216:                logger.log(BasicLevel.DEBUG, "");
217:                timercount++;
218:                TimerService timerservice = sessionContext.getTimerService();
219:                Collection timerList = timerservice.getTimers();
220:                TimerHandle hdl = timer.getHandle();
221:                TimerHandle hdl2 = getDeserializedHandle(hdl);
222:                if (!timersAreIdentical(hdl, hdl2)) {
223:                    logger.log(BasicLevel.ERROR, "Bad timer handle");
224:                    throw new EJBException("Bad timer handle");
225:                }
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.