Oracle Fusion Middleware
Oracle WebLogic Server API Reference
12c Release 1 (12.1.1)

Part Number E24391-02

weblogic.timers
Interface TimerManager


public interface TimerManager

A facility for threads to schedule future work.

Each time an application calls schedule or scheduledAtAFixedRate a timer is created and returned to the user. The timer can then be queried and used to cancel the timer. When a timer expires its listener is executed. If the timer is a repeating timer, then the timer is rescheduled and the listener will be executed again. This class is thread-safe. Any number of threads may schedule timers without external synchronization. Each timer is guaranteed to execute within only one thread of execution. However, a listener that is associated with multiple timers can be concurrently executed. Repeating timers that have not been cancelled will continue until they are cancelled or until the timer manager is stopped.


Method Summary
 boolean isStopped()
          Returns true if all TimerListeners have completed following stop.
 boolean isStopping()
          Returns true if TimerManager is stopping or has already stopped.
 boolean isSuspended()
          Returns true if all TimerListeners have completed following suspend.
 boolean isSuspending()
          Returns true if TimerManager is suspending or is already suspended.
 void resume()
          Resume the timer manager.
 Timer schedule(TimerListener listener, Date time)
          Schedules the specified task for execution at the specified time.
 Timer schedule(TimerListener listener, Date firstTime, long period)
          Schedules the specified listener for repeated execution starting at the specified date, and then repeatedly with a fixed delay between subsequent executions.
 Timer schedule(TimerListener listener, long delay)
          Schedules the specified listener for execution after the specified delay.
 Timer schedule(TimerListener listener, long delay, long period)
          Schedules the specified listener for repeated execution with an initial delay before the first execution and then repeatedly with a fixed delay between subsequent executions.
 Timer schedule(TimerListener listener, ScheduleExpression schedule)
          Schedules the specified listener for a calendar-based timer.
 Timer scheduleAtFixedRate(TimerListener listener, Date firstTime, long period)
          Schedules the specified listener for repeated execution with an initial delay before the first execution and then repeatedly at a fixed rate.
 Timer scheduleAtFixedRate(TimerListener listener, long delay, long period)
          Schedules the specified listener for repeated execution starting at the specified date, and then repeatedly at a fixed rate.
 void stop()
          Stop the timer manager permanently.
 void suspend()
          Suspend the timer manager.
 boolean waitForStop(long timeout_ms)
          Blocks until all TimerListeners have completed execution after a stop request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
 boolean waitForSuspend(long timeout_ms)
          Blocks until all TimerListeners have completed execution after a suspend request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
 

Method Detail

schedule

Timer schedule(TimerListener listener,
               long delay)
Schedules the specified listener for execution after the specified delay.

Parameters:
listener - listener to be scheduled.
delay - delay in milliseconds before listener is executed
Throws:
IllegalArgumentException - if delay is negative
IllegalStateException - if timer manager is stopped

schedule

Timer schedule(TimerListener listener,
               Date time)
Schedules the specified task for execution at the specified time. If the time is in the past, the task is scheduled for immediate execution.

Parameters:
listener - listener to be scheduled.
time - time at which listener is to be executed.
Throws:
IllegalArgumentException - if time.getTime() is negative.
IllegalStateException - if timer manager is stopped

schedule

Timer schedule(TimerListener listener,
               long delay,
               long period)
Schedules the specified listener for repeated execution with an initial delay before the first execution and then repeatedly with a fixed delay between subsequent executions. In fixed-delay execution, each subsequent execution is scheduled relative to the completion of the previous execution.

Parameters:
listener - listener to be scheduled
delay - delay in milliseconds before listener is executed
period - time in milliseconds between successive executions
Throws:
IllegalArgumentException - if delay is negative
IllegalArgumentException - if period is negative
IllegalStateException - if timer manager stopped

schedule

Timer schedule(TimerListener listener,
               Date firstTime,
               long period)
Schedules the specified listener for repeated execution starting at the specified date, and then repeatedly with a fixed delay between subsequent executions. In fixed-delay execution, each subsequent execution is scheduled relative to the completion of the previous execution.

Parameters:
listener - listener to be scheduled
firstTime - time at which listener is first to be executed.
period - time in milliseconds between successive executions
Throws:
IllegalArgumentException - if period is negative
IllegalStateException - if timer manager is stopped

schedule

Timer schedule(TimerListener listener,
               ScheduleExpression schedule)
Schedules the specified listener for a calendar-based timer.

Parameters:
listener - listener to be scheduled
schedule - The schedule expression describing the timeouts for this timer.
Throws:
IllegalArgumentException - if the schedule represents an invalid schedule expression
IllegalStateException - if timer manager is stopped
Since:
12.1.1.0

scheduleAtFixedRate

Timer scheduleAtFixedRate(TimerListener listener,
                          Date firstTime,
                          long period)
Schedules the specified listener for repeated execution with an initial delay before the first execution and then repeatedly at a fixed rate. In fixed-rate execution, each subsequent execution is scheduled relative to the scheduled start time of the current execution (as opposed to the actual start time).

Parameters:
listener - listener to be scheduled
firstTime - delay in milliseconds before listener is executed
period - time in milliseconds between successive executions
Throws:
IllegalArgumentException - if delay is negative
IllegalArgumentException - if period is negative
IllegalStateException - if timer manager is stopped

scheduleAtFixedRate

Timer scheduleAtFixedRate(TimerListener listener,
                          long delay,
                          long period)
Schedules the specified listener for repeated execution starting at the specified date, and then repeatedly at a fixed rate. In fixed-rate execution, each subsequent execution is scheduled relative to the scheduled start time of the current execution (as opposed to the actual start time).

Parameters:
listener - listener to be scheduled
delay - delay in milliseconds before listener is executed
period - time in milliseconds between successive executions
Throws:
IllegalArgumentException - if delay is negative
IllegalArgumentException - if period is negative
IllegalStateException - if timer manager is stopped

resume

void resume()
Resume the timer manager. All listener onTimeout methods for timers that expired while the timer manager was suspended are invoked immediately.

Throws:
IllegalStateException - if the timer manager has been stopped

suspend

void suspend()
Suspend the timer manager. All currently executing listeners are permitted to complete and the caller is blocked until they do complete. Invocation of listener methods for timers that expire while the timer manager is suspended is deferred until the timer manager is resumed.

Throws:
IllegalStateException - if the timer manager has been stopped.

stop

void stop()
Stop the timer manager permanently. All currently executing listeners are permitted to complete, and all stop listeners are invoked. The caller is blocked until all listeners have completed.

Attempts to schedule timer, resume, or suspend stopped timer managers will result in an IllegalStateException.


waitForStop

boolean waitForStop(long timeout_ms)
                    throws InterruptedException
Blocks until all TimerListeners have completed execution after a stop request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters:
timeout_ms - the maximum time to wait
Returns:
true if this TimerManager stopped and false if the timeout elapsed before the stop completed
Throws:
InterruptedException - if interrupted while waiting

isStopping

boolean isStopping()
Returns true if TimerManager is stopping or has already stopped.


isStopped

boolean isStopped()
Returns true if all TimerListeners have completed following stop.

Returns:
true if all TimerListeners have completed following stop

waitForSuspend

boolean waitForSuspend(long timeout_ms)
                       throws InterruptedException
Blocks until all TimerListeners have completed execution after a suspend request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters:
timeout_ms - the maximum time to wait
Returns:
true if this TimerManager suspended and false if the timeout elapsed before the suspend completed
Throws:
InterruptedException - if interrupted while waiting

isSuspending

boolean isSuspending()
Returns true if TimerManager is suspending or is already suspended.

Returns:
true if TimerManager is suspending or is suspended.

isSuspended

boolean isSuspended()
Returns true if all TimerListeners have completed following suspend.

Returns:
true if all TimerListeners have completed following suspend

Copyright 1996, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Oracle Fusion Middleware
Oracle WebLogic Server API Reference
12c Release 1 (12.1.1)

Part Number E24391-02