public class Alarm extends java.lang.Object implements ThreadTask, ClassLoaderListener
A separate thread periodically tests the queue for alarms ready.
Modifier | Constructor and Description |
---|---|
protected |
Alarm()
Create a new wakeup alarm with a designated listener as a callback.
|
|
Alarm(AlarmListener listener)
Create a new wakeup alarm with a designated listener as a callback.
|
|
Alarm(AlarmListener listener,
long delta)
Creates a new alarm and schedules its wakeup.
|
protected |
Alarm(java.lang.String name) |
|
Alarm(java.lang.String name,
AlarmListener listener)
Create a new wakeup alarm with a designated listener as a callback.
|
|
Alarm(java.lang.String name,
AlarmListener listener,
java.lang.ClassLoader loader)
Create a new wakeup alarm with a designated listener as a callback.
|
|
Alarm(java.lang.String name,
AlarmListener listener,
long delta)
Creates a named alarm and schedules its wakeup.
|
|
Alarm(java.lang.String name,
AlarmListener listener,
long delta,
java.lang.ClassLoader loader)
Create a new wakeup alarm with a designated listener as a callback.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addEnvironmentListener()
Registers the alarm with the environment listener for auto-close
|
void |
classLoaderDestroy(DynamicClassLoader loader)
Handles the case where a class loader is dropped.
|
void |
classLoaderInit(DynamicClassLoader loader)
Handles the case where a class loader has completed initialization
|
void |
close()
Closes the alarm instance
|
void |
dequeue()
Remove the alarm from the wakeup queue.
|
java.lang.ClassLoader |
getContextLoader()
Sets the alarm's context loader
|
AlarmListener |
getListener()
Return the alarm's listener.
|
java.lang.String |
getName()
Returns the alarm name.
|
long |
getWakeTime()
Returns the wake time of this alarm.
|
boolean |
isPriority()
True for a priority alarm (default)
|
boolean |
isQueued()
Returns true if the alarm is currently queued.
|
void |
queue(long delta)
Queue the alarm for wakeup.
|
void |
queueAt(long wakeTime)
Queue the alarm for wakeup.
|
void |
run()
Runs the alarm.
|
void |
setContextLoader(java.lang.ClassLoader loader)
Sets the alarm's context loader
|
void |
setListener(AlarmListener listener)
Sets the alarm's listener.
|
protected void |
setName(java.lang.String name)
Sets the alarm name.
|
void |
setPriority(boolean isPriority)
True for a priority alarm (default)
|
void |
setWakeTime(long wakeTime) |
java.lang.String |
toString() |
protected Alarm()
protected Alarm(java.lang.String name)
public Alarm(AlarmListener listener)
public Alarm(java.lang.String name, AlarmListener listener)
public Alarm(java.lang.String name, AlarmListener listener, java.lang.ClassLoader loader)
public Alarm(java.lang.String name, AlarmListener listener, long delta, java.lang.ClassLoader loader)
public Alarm(java.lang.String name, AlarmListener listener, long delta)
name
- the object prepared to receive the callbacklistener
- the object prepared to receive the callbackdelta
- the time in milliseconds to wake uppublic Alarm(AlarmListener listener, long delta)
listener
- the object prepared to receive the callbackdelta
- the time in milliseconds to wake uppublic java.lang.String getName()
protected void setName(java.lang.String name)
public long getWakeTime()
public void setWakeTime(long wakeTime)
public AlarmListener getListener()
public void setListener(AlarmListener listener)
public void setContextLoader(java.lang.ClassLoader loader)
public java.lang.ClassLoader getContextLoader()
public boolean isQueued()
public void setPriority(boolean isPriority)
public boolean isPriority()
protected void addEnvironmentListener()
public void queue(long delta)
delta
- time in milliseconds to wakepublic void queueAt(long wakeTime)
delta
- time in milliseconds to wakepublic void dequeue()
public void run()
run
in interface ThreadTask
run
in interface java.lang.Runnable
public void classLoaderInit(DynamicClassLoader loader)
classLoaderInit
in interface ClassLoaderListener
public void classLoaderDestroy(DynamicClassLoader loader)
classLoaderDestroy
in interface ClassLoaderListener
public void close()
public java.lang.String toString()
toString
in class java.lang.Object