IBM WebSphere Application ServerTM
Release 7

com.ibm.websphere.asynchbeans
Interface Alarm


public interface Alarm

An object implementing this interface is returned when an alarm is created. It allows the alarm to be manipulated and allows the alarm to be reset to fire at another time as well as allows the alarm context object to be retrieved.

Alarms are transient and not transactional and run inside the JVM which created them. If a cluster wide scheduled event is required or it needs to be persistent,transactional or recoverable then the Scheduler should be used instead.

See Also:
AlarmManager, AlarmListener, Scheduler

Method Summary
 void cancel()
          This cancels the alarm that is currently pending.
 AlarmListener getAlarmListener()
          This returns the application supplied AlarmListener associated with this alarm.
 java.lang.Object getContext()
          This returns the context object associated with the alarm when it was created.
 void reset(int milliSeconds)
          This cancels the current alarm and reschedules it to fire at a later time.
 

Method Detail

getContext

java.lang.Object getContext()
This returns the context object associated with the alarm when it was created.

Returns:
The object passed to AlarmManager.create or null if none was specified.
Throws:
java.lang.IllegalStateException - If the owner AsynchScope is destroyed.

reset

void reset(int milliSeconds)
This cancels the current alarm and reschedules it to fire at a later time. This is most useful in repeating alarms. When fired is called then the current alarm is provided as a parameter. This alarm should be reset to schedule the next firing as opposed to creating a new alarm. This is more efficient as the alarm is reused rather than making a new one.

Parameters:
milliSeconds - The number of milliseconds from now that the alarm will fire in.
Throws:
java.lang.IllegalStateException - If the owner AsynchScope is destroyed.

cancel

void cancel()
This cancels the alarm that is currently pending. It also can be called during the AlarmListener.fired method and then it returns the alarm to a pool so that it can be reused. This can help optimize memory usage of an application. If cancel isn't called in fired then the alarm is GCed as normal.

Once cancel is called then an application must not use the alarm instance again as it will be reused by a subsequent alarm.

If the owning AsynchScope was destroyed then this method does not throw IllegalState as the alarm is already cancelled.


getAlarmListener

AlarmListener getAlarmListener()
This returns the application supplied AlarmListener associated with this alarm.

Returns:
The AlarmListener associated with the alarm.
Throws:
java.lang.IllegalStateException - If the owner AsynchScope is destroyed.

IBM WebSphere Application ServerTM
Release 7