Timer MBeans
JMX provides a standard timer service API, which can be used to generate notifications at set times or intervals. WebLogic 8.1 implements this service by extending the standard JMX timer service, enabling it to run with WebLogic execute threads and any associated security context.
To use this service, you must use an instance of the
weblogic.management.timer.Timer class. The
following example illustrates how to create an instance, register a
listener, register a notification for when an event should be
emitted, and start the timer:
Timer timer= new Timer( );
// Register a standard notification listener
timer.addNotificationListener(someListener,
null, "handback object");
// Start in one second
Date start =
new Date((new Date( )).getTime( ) + 1000L);
// Repeat every minute, please
notificationId = timer.addNotification("eggTimer",
"someString", this, start, 3*Timer.ONE_MINUTE
);
// Start the timer
timer.start( );Note that you may register any standard notification listener that we
have already encountered. The type of the notification is
TimerNotification. The only tricky bit is the call
to the addNotification( ) method, which lets you
set up the timer schedule. You can invoke this method as many times
as you like to add multiple schedules to the timer. One of the method
signatures looks like this:
Integer addNotification (java.lang.String type, java.lang.String message,
java.lang.Object userData,java.util.Date startTime,
long period, long numOccurences)Other versions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access