Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

WebLogic Server 5.1.0sp9 API Reference

## weblogic.time.common
Interface Schedulable

All Known Subinterfaces:
  ScheduleDef

All Known Implementing Classes:
  TimeRepeat

public interface Schedulable

Interface for user-written schedulers. The Schedulable object differs from a ScheduleDef object in that it cannot be initialized and has no access to WebLogic services. Schedulers that require access to WebLogic Services or have initialization parameters should implement `ScheduleDef` rather that Schedulable.

Here's an example of how this interface is used. This example illustrates a recurring trigger that is scheduled and executed on the client.

    class myclient implements Schedulable, Triggerable {

       public myclient() throws TimeTriggerException {
         // Create a T3Client
         T3Client t3 = new T3Client("t3://host:port");
         t3.connect();

         // Set up a scheduled trigger, using this object for
         // scheduling and execution
         ScheduledTriggerDef std =
           t3.services.time().getScheduledTrigger(this, this);

         std.schedule(); // start the ball rolling
         .
         .
         std.cancel();  // cancel the trigger
       }

       public long schedule(long time) {
         return time+5000;  // 5 seconds
       }

       public void trigger() {
         System.out.println("trigger called");
       }
     }

A Scheduler object -- one that implements either Schedulable or ScheduleDef -- is used to schedule recurring actions (triggers) and in calls to the `TimeServicesDef.getScheduledTrigger()` method. The Scheduler is passed the current time, in milliseconds since the epoch, with your implementation of the `schedule()` method from this interface. To schedule execution for delta milliseconds in the future, the `schedule()` method should simply return `time + delta`. To schedule the callback for a specific future time, the `schedule()` method may perform date arithmetic using the standard java classes such as `java.util.Date`, and methods like `Date.getTime()` to return the millisecond representation of a specific time.

If the `schedule()` method returns a value less than or equal to 0, then the trigger is unscheduled from future execution. Returning 0 is probably more efficient, in fact, than calling `cancel()`.

Author:
  Copyright (c) 1996-97, WebLogic, Inc. All Rights Reserved., Copyright (c) 1999 by BEA WebXpress. All Rights Reserved.
  Copyright © 2001 BEA Systems, Inc. All Rights Reserved.
See Also:
  `TimeServicesDef`, `ScheduleDef`, `Triggerable`, `TriggerDef`, `TimeRepeat`

Method Summary
`long` | `schedule(long time)` Schedules an object for the specified time.

Method Detail

### schedule

    public long schedule(long time)

  Schedules an object for the specified time.

  Parameters:
    `time` - Time in milliseconds
  Returns:
    Scheduled time

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://www.weblogic.com/docs51
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD