1
2 /*
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 *
5 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6 *
7 * The contents of this file are subject to the terms of either the GNU
8 * General Public License Version 2 only ("GPL") or the Common Development
9 * and Distribution License("CDDL") (collectively, the "License"). You
10 * may not use this file except in compliance with the License. You can obtain
11 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
12 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
13 * language governing permissions and limitations under the License.
14 *
15 * When distributing the software, include this License Header Notice in each
16 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
17 * Sun designates this particular file as subject to the "Classpath" exception
18 * as provided by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the License
20 * Header, with the fields enclosed by brackets [] replaced by your own
21 * identifying information: "Portions Copyrighted [year]
22 * [name of copyright owner]"
23 *
24 * Contributor(s):
25 *
26 * If you wish your version of this file to be governed by only the CDDL or
27 * only the GPL Version 2, indicate your decision by adding "[Contributor]
28 * elects to include this software in this distribution under the [CDDL or GPL
29 * Version 2] license." If you don't indicate a single choice of license, a
30 * recipient has the option to distribute your version of this file under
31 * either the CDDL, the GPL Version 2 or to extend the choice of license to
32 * its licensees as provided above. However, if you add GPL Version 2 code
33 * and therefore, elected the GPL Version 2 license, then the option applies
34 * only if the new code is made subject to such option by the copyright
35 * holder.
36 */
37 package javax.ejb;
38
39 import java.io.Serializable;
40 import java.util.Date;
41
42 /**
43 *
44 * The Timer interface contains information about a timer
45 * that was created through the EJB Timer Service.
46 *
47 */
48 public interface Timer {
49
50 /**
51 * Cause the timer and all its associated expiration notifications to
52 * be cancelled.
53 *
54 *
55 * @exception java.lang.IllegalStateException If this method is
56 * invoked while the instance is in a state that does not allow access
57 * to this method.
58 *
59 * @exception javax.ejb.NoSuchObjectLocalException If invoked on a timer
60 * that has expired or has been cancelled.
61 *
62 * @exception javax.ejb.EJBException If this method could not complete due
63 * to a system-level failure.
64 */
65 public void cancel() throws java.lang.IllegalStateException, javax.ejb.NoSuchObjectLocalException, javax.ejb.EJBException;
66
67 /**
68 * Get the number of milliseconds that will elapse before the next
69 * scheduled timer expiration.
70 *
71 * @return the number of milliseconds that will elapse before the next
72 * scheduled timer expiration.
73 *
74 * @exception java.lang.IllegalStateException If this method is
75 * invoked while the instance is in a state that does not allow access
76 * to this method.
77 *
78 * @exception javax.ejb.NoSuchObjectLocalException If invoked on a timer
79 * that has expired or has been cancelled.
80 *
81 * @exception javax.ejb.EJBException If this method could not complete due
82 * to a system-level failure.
83 */
84 public long getTimeRemaining() throws java.lang.IllegalStateException, javax.ejb.NoSuchObjectLocalException, javax.ejb.EJBException;
85
86 /**
87 * Get the point in time at which the next timer expiration is scheduled
88 * to occur.
89 *
90 * @return the point in time at which the next timer expiration is
91 * scheduled to occur.
92 *
93 * @exception java.lang.IllegalStateException If this method is
94 * invoked while the instance is in a state that does not allow access
95 * to this method.
96 *
97 * @exception javax.ejb.NoSuchObjectLocalException If invoked on a timer
98 * that has expired or has been cancelled.
99 *
100 * @exception javax.ejb.EJBException If this method could not complete due
101 * to a system-level failure.
102 */
103 public Date getNextTimeout() throws java.lang.IllegalStateException, javax.ejb.NoSuchObjectLocalException, javax.ejb.EJBException;
104
105 /**
106 * Get the information associated with the timer at the time of creation.
107 *
108 * @return The Serializable object that was passed in at timer creation, or
109 * null if the info argument passed in at timer creation was null.
110 *
111 * @exception java.lang.IllegalStateException If this method is
112 * invoked while the instance is in a state that does not allow access
113 * to this method.
114 *
115 * @exception javax.ejb.NoSuchObjectLocalException If invoked on a timer
116 * that has expired or has been cancelled.
117 *
118 * @exception javax.ejb.EJBException If this method could not complete due
119 * to a system-level failure.
120 */
121 public Serializable getInfo() throws java.lang.IllegalStateException, javax.ejb.NoSuchObjectLocalException, javax.ejb.EJBException;
122
123
124 /**
125 * Get a serializable handle to the timer. This handle can
126 * be used at a later time to re-obtain the timer reference.
127 *
128 * @return a serializable handle to the timer.
129 *
130 * @exception java.lang.IllegalStateException If this method is
131 * invoked while the instance is in a state that does not allow access
132 * to this method.
133 *
134 * @exception javax.ejb.NoSuchObjectLocalException If invoked on a timer
135 * that has expired or has been cancelled.
136 *
137 * @exception javax.ejb.EJBException If this method could not complete due
138 * to a system-level failure.
139 */
140 public TimerHandle getHandle() throws java.lang.IllegalStateException, javax.ejb.NoSuchObjectLocalException, javax.ejb.EJBException;
141
142 }