com.ibm.websphere.asynchbeans
Interface Alarm
- public interface Alarm
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:
Method Summary
Modifier and Type | Method and Description |
---|---|
|
cancel()
This cancels the alarm that is currently pending.
|
getAlarmListener()
This returns the application supplied AlarmListener associated
with this alarm.
|
|
|
getContext()
This returns the context object associated with the alarm
when it was created.
|
|
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.