com.caucho.util
Class WeakAlarm

java.lang.Object
  extended by com.caucho.util.Alarm
      extended by com.caucho.util.WeakAlarm
All Implemented Interfaces:
ClassLoaderListener, ThreadTask, java.lang.Runnable, java.util.EventListener

public class WeakAlarm
extends Alarm

The alarm class provides a lightweight event scheduler. This allows an objects to schedule a timeout without creating a new thread.

A separate thread periodically tests the queue for alarms ready.

You should use Cron for slow requests. Alarm is only appropriate for very short jobs.


Constructor Summary
WeakAlarm(AlarmListener listener)
          Create a new wakeup alarm with a designated listener as a callback.
WeakAlarm(AlarmListener listener, long delta)
          Creates a new alarm and schedules its wakeup.
WeakAlarm(java.lang.String name, AlarmListener listener)
          Create a new wakeup alarm with a designated listener as a callback.
WeakAlarm(java.lang.String name, AlarmListener listener, long delta)
          Creates a named alarm and schedules its wakeup.
 
Method Summary
 java.lang.ClassLoader getContextLoader()
          Sets the alarm's context loader
 AlarmListener getListener()
          Return the alarm's listener.
 void setContextLoader(java.lang.ClassLoader loader)
          Sets the class loader.
 void setListener(AlarmListener listener)
          Sets the alarm's listener.
 
Methods inherited from class com.caucho.util.Alarm
addEnvironmentListener, classLoaderDestroy, classLoaderInit, close, dequeue, getCurrentTime, getCurrentTimeActual, getExactTime, getExactTimeNanoseconds, getName, getWakeTime, isActive, isPriority, isQueued, isTest, queue, queueAt, run, setName, setPriority, setWakeTime, toString, yieldIfTest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WeakAlarm

public WeakAlarm(AlarmListener listener)
Create a new wakeup alarm with a designated listener as a callback. The alarm is not scheduled.


WeakAlarm

public WeakAlarm(java.lang.String name,
                 AlarmListener listener)
Create a new wakeup alarm with a designated listener as a callback. The alarm is not scheduled.


WeakAlarm

public WeakAlarm(java.lang.String name,
                 AlarmListener listener,
                 long delta)
Creates a named alarm and schedules its wakeup.

Parameters:
name - the object prepared to receive the callback
listener - the object prepared to receive the callback
delta - the time in milliseconds to wake up

WeakAlarm

public WeakAlarm(AlarmListener listener,
                 long delta)
Creates a new alarm and schedules its wakeup.

Parameters:
listener - the object prepared to receive the callback
delta - the time in milliseconds to wake up
Method Detail

getListener

public AlarmListener getListener()
Return the alarm's listener.

Overrides:
getListener in class Alarm

setListener

public void setListener(AlarmListener listener)
Sets the alarm's listener.

Overrides:
setListener in class Alarm

getContextLoader

public java.lang.ClassLoader getContextLoader()
Description copied from class: Alarm
Sets the alarm's context loader

Overrides:
getContextLoader in class Alarm

setContextLoader

public void setContextLoader(java.lang.ClassLoader loader)
Sets the class loader.

Overrides:
setContextLoader in class Alarm