util
Class ObjectRefresh

java.lang.Object
  extended by util.ObjectRefresh

public class ObjectRefresh
extends Object

A class that allows Refreshing objects to be scheduled. It provides only static methods for adding Refreshing instances and removing them from a single, static Timer. On VM exit, the timer, if existant, is canceled.


Nested Class Summary
protected static class ObjectRefresh.RefreshTask
          A timer tasks that runs a Refreshing instance.
 
Field Summary
private static List<ObjectRefresh.RefreshTask> tasks
          The list of ObjectRefresh.RefreshTasks currently scheduled.
private static Timer timer
          The timer to schedule Refreshing tasks.
 
Constructor Summary
ObjectRefresh()
           
 
Method Summary
static boolean addRefresh(Refreshing schedule)
          Adds a new Refreshing instance.
static boolean addRefresh(Refreshing schedule, Date first)
          Adds a new Refreshing instance.
static boolean addRefresh(Refreshing schedule, long initwait)
          Adds a new Refreshing instance.
private static void createTimer()
          Creates a timer instance.
static Timer getTimer()
          Returns a timer for adding tasks to it.
static boolean removeRefresh(Refreshing schedule)
          Removes a Refreshing instance permanently from scheduling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

private static Timer timer
The timer to schedule Refreshing tasks.


tasks

private static List<ObjectRefresh.RefreshTask> tasks
The list of ObjectRefresh.RefreshTasks currently scheduled.

Constructor Detail

ObjectRefresh

public ObjectRefresh()
Method Detail

addRefresh

public static boolean addRefresh(Refreshing schedule)
Adds a new Refreshing instance. If this is the first instance to be refreshed, the timer is constructed and a shutdown-hook is added. The scheduling is delayed for the refreshing interval.

Returns:
True, if this is a newly scheduled object.

addRefresh

public static boolean addRefresh(Refreshing schedule,
                                 Date first)
Adds a new Refreshing instance. If this is the first instance to be refreshed, the timer is constructed and a shutdown-hook is added. The scheduling is delayed for the refreshing interval.

Returns:
True, if this is a newly scheduled object.

addRefresh

public static boolean addRefresh(Refreshing schedule,
                                 long initwait)
Adds a new Refreshing instance. If this is the first instance to be refreshed, the timer is constructed and a shutdown-hook is added.

Returns:
True, if this is a newly scheduled object.

createTimer

private static void createTimer()
Creates a timer instance.


getTimer

public static Timer getTimer()
Returns a timer for adding tasks to it.


removeRefresh

public static boolean removeRefresh(Refreshing schedule)
Removes a Refreshing instance permanently from scheduling.

Returns:
True, if the Refreshing instance was scheduled.