Java Dynamic Management Kit 3.2 Programming Guide | ||||
---|---|---|---|---|
![]() | ![]() | Chapter 15. Event Handling, Alarm Clock, and Monitoring Services | ![]() | ![]() |
The alarm clock service activates (or "wakes up") alarm clock event listeners when the timeout elapses. The alarm clock service is not manageable as no MO stubs are provided, therefore it must be used locally. To add an alarm clock, create an instance of the com.sun.jaw.impl.agent.services.alarm.AlarmClock class.
All events sent by an alarm clock are instances of the class com.sun.jaw.impl.agent.services.alarm.AlarmClockEvent. To enable an application to receive alarm clock events, make sure that the application implements the com.sun.jaw.impl.agent.services.alarm.AlarmClockListener interface. This interface contains a single method for handling alarm clock events. The prototype of this method is defined in Example 15-7.
Example 15-7. Prototype of the handleAlarmClockEvent() Method
public abstract void handleAlarmClock(AlarmClockEvent event); |
To set an alarm clock timeout, use the setTimeout() method specifying the required elapsed time, in milliseconds, after which the alarm clock event will be sent. Example 15-8 shows the instantiation of an an alarm clock and use of the setTimeout() method to set the timeout for the alarm clock.
Example 15-8. Instantiating and Setting the Alarm Clock
// Instantiate an alarm clock AlarmClock alarm= new AlarmClock(); // Set timeout in milliseconds alarm.setTimeoutAsLong(new Long(30000)); |
Example 15-9 shows how to get the timeout for the alarm clock service that was instantiated in Example 15-8.
Example 15-9. Getting the Alarm Clock Timeout
// Get timeout in milliseconds Long value= alarm.getTimeoutAsLong(); |
The alarm clock service is used by the scheduler service and the monitoring service.
![]() | ![]() | ![]() |
Event Handling Service | ![]() | Scheduler Service |