Source Code Cross Referenced for EJBTimerTask.java in  » J2EE » jfox » org » jfox » ejb3 » timer » 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 » jfox » org.jfox.ejb3.timer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFox - The most lightweight Java EE Application Server!
003:         * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
004:         *
005:         * JFox is licenced and re-distributable under GNU LGPL.
006:         */
007:        package org.jfox.ejb3.timer;
008:
009:        import java.io.Serializable;
010:        import java.lang.reflect.Method;
011:        import java.util.ArrayList;
012:        import java.util.Arrays;
013:        import java.util.Date;
014:        import java.util.List;
015:        import java.util.concurrent.ScheduledFuture;
016:        import java.util.concurrent.TimeUnit;
017:        import javax.ejb.EJBException;
018:        import javax.ejb.NoSuchObjectLocalException;
019:        import javax.ejb.Timer;
020:        import javax.ejb.TimerHandle;
021:
022:        import org.jfox.ejb3.EJBObjectId;
023:        import org.jfox.ejb3.SimpleEJB3Container;
024:        import org.jfox.mvc.SessionContext;
025:
026:        /**
027:         * @author <a href="mailto:yangyong@ufsoft.com.cn">Young Yang</a>
028:         */
029:
030:        public class EJBTimerTask implements  Timer, TimerHandle, Runnable {
031:
032:            private EJBObjectId ejbObjectId;
033:
034:            private final List<Method> timeoutMethods = new ArrayList<Method>();
035:
036:            private Serializable info;
037:
038:            private SimpleEJB3Container.ContainerTimerService timerService;
039:
040:            /**
041:             * Scheduled future
042:             */
043:            private ScheduledFuture future;
044:
045:            private SessionContext sessionContext;
046:
047:            public EJBTimerTask(
048:                    SimpleEJB3Container.ContainerTimerService timerService,
049:                    Serializable info) {
050:                this .timerService = timerService;
051:                this .info = info;
052:            }
053:
054:            public EJBObjectId getEJBObjectId() {
055:                return ejbObjectId;
056:            }
057:
058:            public void setEJBObjectId(EJBObjectId ejbObjectId) {
059:                this .ejbObjectId = ejbObjectId;
060:            }
061:
062:            public SessionContext getSessionContext() {
063:                return sessionContext;
064:            }
065:
066:            // set security context when createTimer
067:            public void setSessionContext(SessionContext sessionContext) {
068:                this .sessionContext = sessionContext;
069:            }
070:
071:            public void setFuture(ScheduledFuture future) {
072:                this .future = future;
073:            }
074:
075:            public long getTimeRemaining() throws IllegalStateException,
076:                    NoSuchObjectLocalException, EJBException {
077:                return future.getDelay(TimeUnit.MILLISECONDS);
078:            }
079:
080:            public Date getNextTimeout() throws IllegalStateException,
081:                    NoSuchObjectLocalException, EJBException {
082:                return new Date(System.currentTimeMillis()
083:                        + future.getDelay(TimeUnit.MILLISECONDS));
084:            }
085:
086:            public Serializable getInfo() throws IllegalStateException,
087:                    NoSuchObjectLocalException, EJBException {
088:                return info;
089:            }
090:
091:            public TimerHandle getHandle() throws IllegalStateException,
092:                    NoSuchObjectLocalException, EJBException {
093:                return this ;
094:            }
095:
096:            public Timer getTimer() throws IllegalStateException,
097:                    NoSuchObjectLocalException, EJBException {
098:                return this ;
099:            }
100:
101:            /**
102:             * need remove from EJBTimerService's timers
103:             */
104:            public void cancel() {
105:                future.cancel(false);
106:            }
107:
108:            public void addTimeoutMethod(Method[] timeoutMethods) {
109:                this .timeoutMethods.addAll(Arrays.asList(timeoutMethods));
110:            }
111:
112:            public Method[] getTimeoutMethods() {
113:                return timeoutMethods
114:                        .toArray(new Method[timeoutMethods.size()]);
115:            }
116:
117:            public void run() {
118:                // 执行 @Timeout 方法
119:                timerService.timeout(this );
120:            }
121:
122:            public static void main(String[] args) {
123:
124:            }
125:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.