Holger's
Java API

com.antelmann.calendar
Class AtomicTime

java.lang.Object
  extended by com.antelmann.calendar.AtomicTime
All Implemented Interfaces:
TimeSystem

public class AtomicTime
extends Object
implements TimeSystem

works based on an AtomicClock instance adding reliability by using multiple server if one fails.

Author:
Holger Antelmann
See Also:
AtomicClock

Field Summary
 
Fields inherited from interface com.antelmann.calendar.TimeSystem
systemTime
 
Constructor Summary
AtomicTime()
          immediately activates the instance and schedules updates in the interval given.
AtomicTime(boolean activateNow)
          Interval is 24h.
AtomicTime(boolean activateNow, long updateIntervalMillis)
          immediately activates the instance and schedules updates in the interval given.
AtomicTime(boolean activateNow, long updateIntervalMillis, Logger logger)
           
 
Method Summary
 void activate()
          activates the embedded timer for automatic updates
 long currentTimeMillis()
          returns the current time
 void deactivate()
          deactivates the embedded timer for automatic updates
protected  void finalize()
           
 AtomicClock getAtomicClock()
          returns the clock in use
 Logger getLogger()
          may be null
 Set<String> getServerNames()
          returned set allows to add/remove server names if required
 long getUpdateIntervalMillis()
           
 boolean isActivated()
           
 void setLogger(Logger logger)
          may be set to null
 void setUpdateIntervalMillis(long updateIntervalMillis)
          must be called while the instance is deactivated.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtomicTime

public AtomicTime()
immediately activates the instance and schedules updates in the interval given. Interval is 24h.


AtomicTime

public AtomicTime(boolean activateNow)
Interval is 24h.


AtomicTime

public AtomicTime(boolean activateNow,
                  long updateIntervalMillis)
           throws IllegalArgumentException
immediately activates the instance and schedules updates in the interval given.

Parameters:
updateIntervalMillis - must represent more than a minute
Throws:
IllegalArgumentException - if the interval represents less than a minute

AtomicTime

public AtomicTime(boolean activateNow,
                  long updateIntervalMillis,
                  Logger logger)
           throws IllegalArgumentException
Parameters:
activateNow - if true, the instance is immediately activated
updateIntervalMillis - must represent more than a minute
logger - used to log the scheduled delta updates for the atomic clock
Throws:
IllegalArgumentException - if the interval represents less than 5 minutes
Method Detail

isActivated

public boolean isActivated()

getUpdateIntervalMillis

public long getUpdateIntervalMillis()

setUpdateIntervalMillis

public void setUpdateIntervalMillis(long updateIntervalMillis)
                             throws IllegalStateException,
                                    IllegalArgumentException
must be called while the instance is deactivated.

Throws:
IllegalStateException - if this instance is currently activated
IllegalArgumentException - if the interval represents less than 5 minutes
See Also:
isActivated()

activate

public void activate()
activates the embedded timer for automatic updates


deactivate

public void deactivate()
deactivates the embedded timer for automatic updates


finalize

protected void finalize()
Overrides:
finalize in class Object

currentTimeMillis

public long currentTimeMillis()
returns the current time

Specified by:
currentTimeMillis in interface TimeSystem
Returns:
the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

getAtomicClock

public AtomicClock getAtomicClock()
returns the clock in use


setLogger

public void setLogger(Logger logger)
may be set to null


getLogger

public Logger getLogger()
may be null


getServerNames

public Set<String> getServerNames()
returned set allows to add/remove server names if required



(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads