cgl.narada.service.time.ntptime
Class TimeServiceImpl

java.lang.Object
  extended by cgl.narada.service.time.ntptime.TimeServiceImpl
All Implemented Interfaces:
TimeService

public class TimeServiceImpl
extends Object
implements TimeService

This class is a singleton class and should be used to retun the adjusted time value. NTP protocol implementation receives time from this class. The only method implemented in this class is getTime(), which should be used to get the adjusted current time.


Method Summary
 long getDelta()
          Gets the last change in the offset value
static TimeServiceImpl getInstance()
          Gets the only instance of TimeServiceImpl.
 long getOffset()
          Gets offset value between the local computer's time and the computed time from NTP protocol.
 ServiceException getServiceException()
          Returns ServiceException
 long getTimestamp()
          Gets adjusted time
 void setOffset(long offDelta)
          Adjusts the offset value by delta.
 void setServiceException(ServiceException serviceException)
          Sets exception
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static TimeServiceImpl getInstance()
Gets the only instance of TimeServiceImpl.

Returns:
TimeServiceImpl - this object

getDelta

public long getDelta()
Gets the last change in the offset value

Returns:
long - last change in the offset value

setOffset

public void setOffset(long offDelta)
Adjusts the offset value by delta. If the new time value would be less than the last time value provided, it is not updated.

Parameters:
offDelta - - adjustment to be made to offset

getOffset

public long getOffset()
Gets offset value between the local computer's time and the computed time from NTP protocol.

Specified by:
getOffset in interface TimeService
Returns:
long - offset value

setServiceException

public void setServiceException(ServiceException serviceException)
Sets exception

Parameters:
serviceException -

getServiceException

public ServiceException getServiceException()
Returns ServiceException

Returns:
ServiceException

getTimestamp

public long getTimestamp()
                  throws ServiceException
Gets adjusted time

Specified by:
getTimestamp in interface TimeService
Returns:
long - adjusted time in milliseconds
Throws:
ServiceException


For comments and suggestions please send e-mail to The NaradaBrokering Project