KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > ejb > TimerService


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: TimerService.java 1100 2006-08-16 13:05:31Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package javax.ejb;
27
28 import java.io.Serializable JavaDoc;
29 import java.util.Collection JavaDoc;
30 import java.util.Date JavaDoc;
31
32 /**
33  * The TimerService interface provides enterprise bean components with access to
34  * the container-provided Timer Service. The EJB Timer Service allows entity
35  * beans, stateless session beans, and message-driven beans to be registered for
36  * timer callback events at a specified time, after a specified elapsed time, or
37  * after a specified interval.
38  * @see <a HREF="http://www.jcp.org/en/jsr/detail?id=220">EJB 3.0 specification</a>
39  * @author Florent Benoit
40  */

41 public interface TimerService {
42
43     /**
44      * Create a single-action timer that expires after a specified duration.
45      * @param duration The number of milliseconds that must elapse before the
46      * timer expires.
47      * @param info Application information to be delivered along with the timer
48      * expiration notification. This can be null.
49      * @return The newly created Timer.
50      * @throws IllegalArgumentException If duration is negative
51      * @throws IllegalStateException If this method is invoked while the
52      * instance is in a state that does not allow access to this method.
53      * @throws EJBException If this method fails due to a system-level failure.
54      */

55     Timer JavaDoc createTimer(final long duration, final Serializable JavaDoc info) throws IllegalArgumentException JavaDoc, IllegalStateException JavaDoc,
56             EJBException JavaDoc;
57
58     /**
59      * Create an interval timer whose first expiration occurs after a specified
60      * duration, and whose subsequent expirations occur after a specified
61      * interval.
62      * @param initialDuration The number of milliseconds that must elapse before
63      * the first timer expiration notification.
64      * @param intervalDuration The number of milliseconds that must elapse
65      * between timer expiration notifications. Expiration notifications
66      * are scheduled relative to the time of the first expiration. If
67      * expiration is delayed(e.g. due to the interleaving of other method
68      * calls on the bean) two or more expiration notifications may occur
69      * in close succession to "catch up".
70      * @param info Application information to be delivered along with the timer
71      * expiration. This can be null.
72      * @return The newly created Timer.
73      * @throws IllegalArgumentException If initialDuration is negative, or
74      * intervalDuration is negative.
75      * @throws IllegalStateException If this method is invoked while the
76      * instance is in a state that does not allow access to this method.
77      * @throws EJBException If this method could not complete due to a
78      * system-level failure.
79      */

80     Timer JavaDoc createTimer(final long initialDuration, final long intervalDuration, final Serializable JavaDoc info)
81             throws IllegalArgumentException JavaDoc, IllegalStateException JavaDoc, EJBException JavaDoc;
82
83     /**
84      * Create a single-action timer that expires at a given point in time.
85      * @param expiration The point in time at which the timer must expire.
86      * @param info Application information to be delivered along with the timer
87      * expiration notification. This can be null.
88      * @return The newly created Timer.
89      * @throws IllegalArgumentException If expiration is null, or
90      * expiration.getTime() is negative.
91      * @throws IllegalStateException If this method is invoked while the
92      * instance is in a state that does not allow access to this method.
93      * @throws EJBException If this method could not complete due to a
94      * system-level failure.
95      */

96     Timer JavaDoc createTimer(Date JavaDoc expiration, Serializable JavaDoc info) throws IllegalArgumentException JavaDoc, IllegalStateException JavaDoc, EJBException JavaDoc;
97
98     /**
99      * Create an interval timer whose first expiration occurs at a given point
100      * in time and whose subsequent expirations occur after a specified
101      * interval.
102      * @param initialExpiration The point in time at which the first timer
103      * expiration must occur.
104      * @param intervalDuration The number of milliseconds that must elapse
105      * between timer expiration notifications. Expiration notifications
106      * are scheduled relative to the time of the first expiration. If
107      * expiration is delayed(e.g. due to the interleaving of other method
108      * calls on the bean) two or more expiration notifications may occur
109      * in close succession to "catch up".
110      * @param info Application information to be delivered along with the timer
111      * expiration. This can be null.
112      * @return The newly created Timer.
113      * @throws IllegalArgumentException If initialExpiration is null, or
114      * initialExpiration.getTime() is negative, or intervalDuration is
115      * negative.
116      * @throws IllegalStateException If this method is invoked while the
117      * instance is in a state that does not allow access to this method.
118      * @throws EJBException If this method could not complete due to a
119      * system-level failure.
120      */

121     Timer JavaDoc createTimer(Date JavaDoc initialExpiration, long intervalDuration, Serializable JavaDoc info) throws IllegalArgumentException JavaDoc,
122             IllegalStateException JavaDoc, EJBException JavaDoc;
123
124     /**
125      * Get all the active timers associated with this bean.
126      * @return A collection of javax.ejb.Timer objects.
127      * @throws IllegalStateException If this method is invoked while the
128      * instance is in a state that does not allow access to this method.
129      * @throws EJBException If this method could not complete due to a
130      * system-level failure.
131      */

132     Collection JavaDoc getTimers() throws IllegalStateException JavaDoc, EJBException JavaDoc;
133
134 }
135
Popular Tags