Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.util.schedule
Class Schedule

    java.lang.Object
      org.hyperic.util.schedule.Schedule

    public class Schedule

extends java.lang.Object

A generic scheduler object which keeps track of events, when they should be executed, deletion after invocation, etc. The basetime used when doing any arithmetic with times is the epoch. The scheduler is synchronized. Scheduled events have an interval property -- how often the event should execute (in milliseconds).

Constructor Summary
`Schedule()`

Method Summary
`java.util.List` | `consumeNextItems()` Get the next item (or items) to be executed.
`int` | `getNumItems()` Get the number of items in the schedule.
`ScheduledItem[]` | `getScheduledItems()` Get a list of all the currently scheduled items.
`long` | `getTimeOfNext()` Get the time that the next scheduled item is to be executed.
`static void` | `main(java.lang.String[] args)`
`long` | `scheduleItem(java.lang.Object item, long interval)` Add an item to the internal schedule, with the repeat flag set to true.
`long` | `scheduleItem(java.lang.Object item, long interval, boolean repeat)` Add an item to the internal schedule.
`long` | `scheduleItem(java.lang.Object item, long interval, boolean prev, boolean repeat)` Add an item to the internal schedule.
`ScheduledItem` | `unscheduleItem(long id)` Remove an item from the schedule.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Schedule

    public Schedule()

Method Detail

### scheduleItem

    public long scheduleItem(java.lang.Object item,
                             long interval,
                             boolean prev,
                             boolean repeat)
                      throws ScheduleException

  Add an item to the internal schedule.

  Parameters:
    `item` - the object to schedule
    `interval` - the number of seconds between invocations of the item
    `prev` - true if the item should be scheduled in the past to force immediate firing.
    `repeat` - true if the item should stay in the schedule even after its time has expired
  Returns:
    a global identifier for the scheduled item
  Throws:
    `UnscheduledItemException` - If the given schedule interval is <= 0
    `ScheduleException`

### scheduleItem

    public long scheduleItem(java.lang.Object item,
                             long interval,
                             boolean repeat)
                      throws ScheduleException

  Add an item to the internal schedule.

  Parameters:
    `item` - the object to schedule
    `interval` - the number of seconds between invocations of the item
    `repeat` - true if the item should stay in the schedule even after its time has expired
  Returns:
    a global identifier for the scheduled item
  Throws:
    `ScheduleException`

### scheduleItem

    public long scheduleItem(java.lang.Object item,
                             long interval)
                      throws ScheduleException

  Add an item to the internal schedule, with the repeat flag set to true. See the documentation for scheduleItem for more information.

  Throws:
    `ScheduleException`

### unscheduleItem

    public ScheduledItem unscheduleItem(long id)
                                 throws UnscheduledItemException

  Remove an item from the schedule. Scheduled items which have not been consumed may be unscheduled by using this method.

  Parameters:
    `id` - ID returned by a call to scheduleItem of the item to remove
  Throws:
    `UnscheduledItemException` - indicating the ID was not found.

### getTimeOfNext

    public long getTimeOfNext()
                       throws EmptyScheduleException

  Get the time that the next scheduled item is to be executed. The returned time is in UTC since the epoch (similar to System.currentTimeMillis())

  Returns:
    the absolute the the next event is to be executed
  Throws:
    `EmptyScheduleException` - indicating there is no next item for which the time can be retrieved.

### consumeNextItems

    public java.util.List consumeNextItems()
                                    throws EmptyScheduleException

  Get the next item (or items) to be executed. If more than one item is scheduled for a specific time, they are all returned. Items returned by this function are re-inserted into the schedule, if their repeat flag is set to true -- otherwise they are removed.

  Returns:
    a list of items to execute
  Throws:
    `EmptyScheduleException` - indicating there was no 'next item'

### getNumItems

    public int getNumItems()

  Get the number of items in the schedule.

  Returns:
    the number of items in the schedule.

### getScheduledItems

    public ScheduledItem[] getScheduledItems()

  Get a list of all the currently scheduled items.

  Returns:
    the list of scheduled items.

### main

    public static void main(java.lang.String[] args)
                     throws java.lang.Exception

  Throws:
    `java.lang.Exception`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.