public final class ETimer extends java.lang.Object implements EReplier
Timer
class. This eBus interface
provides applications a uniform event interface: objects
receive events as messages from the eBus API. If the Java
timer interface is used directly, then timer events must be
manually integrated into the event-processing logic.
This interface is not to be preferred if timer tasks are used
autonomously rather than as events delivered to an eBus
client. In that case, the Java TimerTask
should be used directly.
ETimer
service must be started by an application by
calling one of the startETimer
methods before
application objects can successfully subscribe to the timer
server. ETimer
service is local to the JVM only.
Requestors cannot access a remote eBus timer service.
See net.sf.eBusx.util
package documentation for sample
code.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_TIMER_NAME
The default timer name is "ETimer".
|
static EMessageKey |
TIMER_KEY
The advertised request message key is
TimerRequest:/eBusTimer.
|
static java.lang.String |
TIMER_SUBJECT
The advertised request message subject is "/eBusTimer".
|
NAME_NOT_SET
Modifier and Type | Method and Description |
---|---|
void |
cancelRequest(EReplyFeed.ERequest request,
boolean mayRespond)
Cancels the timer task associated with this request and
sends a cancel complete reply.
|
static boolean |
isETimerRunning()
Returns
true if the ETimer instance is
running and false otherwise. |
boolean |
isRunning()
Returns
true if this ETimer is running
and false if not. |
java.lang.String |
name()
Returns
ETimer name . |
void |
request(EReplyFeed.ERequest request)
Starts a timer task based on the given request.
|
void |
shutdown()
Cancels all running timers, stops the timer thread and
retracts the timer service advertisement.
|
static void |
startETimer()
Starts the eBus timer service using the default
timer name and the timer thread is
not run as a daemon. |
static void |
startETimer(boolean isDaemon)
Starts the eBus timer service using the default
timer name and the given daemon
flag. |
static void |
startETimer(java.lang.String name)
Starts the eBus timer service for the given timer thread
name.
|
static void |
startETimer(java.lang.String name,
boolean isDaemon)
Starts the eBus timer service for the given timer thread
name and daemon flag.
|
void |
startup()
Puts the timer service request advertisement in place.
|
static void |
stopETimer()
Stops the eBus timer service, if running.
|
public static final java.lang.String DEFAULT_TIMER_NAME
public static final java.lang.String TIMER_SUBJECT
public static final EMessageKey TIMER_KEY
public java.lang.String name()
ETimer name
.public void startup()
startup
in interface EObject
EObject.shutdown()
public void shutdown()
shutdown
in interface EObject
EObject.startup()
public void request(EReplyFeed.ERequest request)
Do not call this method. This method is
part of the EReplier
interface and is accessed by
the eBus API only.
request
in interface EReplier
request
- the eBus request instance.EReplier.cancelRequest(EReplyFeed.ERequest, boolean)
public void cancelRequest(EReplyFeed.ERequest request, boolean mayRespond)
Do not call this method. This method is
part of the EReplier
interface and is accessed by
the eBus API only.
cancelRequest
in interface EReplier
request
- timer request being canceled.mayRespond
- if true
then send back a
response.EReplier.request(EReplyFeed.ERequest)
public boolean isRunning()
true
if this ETimer
is running
and false
if not.true
if eBus timer is running.public static boolean isETimerRunning()
true
if the ETimer
instance is
running and false
otherwise.true
if the ETimer
instance is
running.public static void startETimer()
timer name
and the timer thread is
not run as a daemon.java.lang.IllegalStateException
- if the eBus timer service is already running.public static void startETimer(boolean isDaemon)
timer name
and the given daemon
flag.isDaemon
- true
means that the timer thread
is run as a daemon.java.lang.IllegalStateException
- if the eBus timer service is already running.public static void startETimer(java.lang.String name)
name
- the timer thread name.java.lang.IllegalArgumentException
- if name
is either null
or empty.java.lang.IllegalStateException
- if the eBus timer service is already running.public static void startETimer(java.lang.String name, boolean isDaemon)
name
- timer thread name.isDaemon
- if true
, then the timer is a
daemon thread.java.lang.IllegalArgumentException
- if name
is either null
or empty.java.lang.IllegalStateException
- if the eBus timer service is already running.public static void stopETimer()
Does nothing if the timer service is not running.
Copyright © 2001 - 2024. Charles W. Rapp. All rights reserved.