org.compass.gps.device
Class ScheduledMirrorGpsDevice

java.lang.Object
  extended by org.compass.gps.device.AbstractGpsDeviceWrapper
      extended by org.compass.gps.device.AbstractMirrorGpsDeviceWrapper
          extended by org.compass.gps.device.ScheduledMirrorGpsDevice
All Implemented Interfaces:
ActiveMirrorGpsDevice, CompassGpsDevice, MirrorDataChangesGpsDevice

public class ScheduledMirrorGpsDevice
extends AbstractMirrorGpsDeviceWrapper
implements ActiveMirrorGpsDevice

For ActiveMirrorGpsDevices, the schedule mirror device can call the ActiveMirrorGpsDevice.performMirroring() in a scheduled manner by wrapping the actual ActiveMirrorGpsDevice.

The schedule mirror gps device implements the ActiveMirrorGpsDevice interface, and provides access to the wrapped gps device using the getWrappedGpsDevice().

For scheduling, the schedule mirror device uses the java.util.Timer, and provides controll over the period, daemon, and fixed rate parameters.

Author:
kimchy

Constructor Summary
ScheduledMirrorGpsDevice()
          Creates a new instance.
ScheduledMirrorGpsDevice(ActiveMirrorGpsDevice gpsDevice)
          Creates a new instance of the scheduled device with the wrapped ActiveMirrorGpsDevice initialized.
 
Method Summary
 long getPeriod()
          The period of the scheduled service in milli-seconds.
 ActiveMirrorGpsDevice getWrappedGpsDevice()
          Returns the wrapped active mirror gps device.
 boolean isDaemon()
          If the scheduled timer whould work as a daemon thread or not.
 void performMirroring()
          Performs the actual mirror operation, delegating the action to the wrapped gps device.
 void setDaemon(boolean daemon)
          Sets if the scheduled timer would work as a daemon thread or not.
 void setGpsDevice(CompassGpsDevice gpsDevice)
          Checks that when setting the wrapped gps device, it is of type ActiveMirrorGpsDevice
 void setPeriod(long period)
          Sets the period of the scheduled service in milli-seconds.
 void setWrappedGpsDevice(ActiveMirrorGpsDevice gpsDevice)
          Sets the wrapped gps device.
 void start()
          Starts the scheduled timer.
 void stop()
          Stops the scheduled timer.
 
Methods inherited from class org.compass.gps.device.AbstractMirrorGpsDeviceWrapper
isMirrorDataChanges, setMirrorDataChanges
 
Methods inherited from class org.compass.gps.device.AbstractGpsDeviceWrapper
checkDeviceSet, getGps, getName, index, injectGps, isPerformingIndexOperation, isRunning, refresh, setName, shouldMirrorDataChanges
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.compass.gps.MirrorDataChangesGpsDevice
isMirrorDataChanges, setMirrorDataChanges
 
Methods inherited from interface org.compass.gps.CompassGpsDevice
getGps, getName, index, injectGps, isPerformingIndexOperation, isRunning, refresh, setName, shouldMirrorDataChanges
 

Constructor Detail

ScheduledMirrorGpsDevice

public ScheduledMirrorGpsDevice()
Creates a new instance. Note that the wrapped gps device must be set by calling the setGpsDevice and it must implement the .


ScheduledMirrorGpsDevice

public ScheduledMirrorGpsDevice(ActiveMirrorGpsDevice gpsDevice)
Creates a new instance of the scheduled device with the wrapped ActiveMirrorGpsDevice initialized.

Parameters:
gpsDevice -
Method Detail

setGpsDevice

public void setGpsDevice(CompassGpsDevice gpsDevice)
Checks that when setting the wrapped gps device, it is of type ActiveMirrorGpsDevice

Overrides:
setGpsDevice in class AbstractGpsDeviceWrapper

start

public void start()
           throws CompassGpsException
Starts the scheduled timer.

Specified by:
start in interface CompassGpsDevice
Overrides:
start in class AbstractGpsDeviceWrapper
Throws:
CompassGpsException

stop

public void stop()
          throws CompassGpsException
Stops the scheduled timer.

Specified by:
stop in interface CompassGpsDevice
Overrides:
stop in class AbstractGpsDeviceWrapper
Throws:
CompassGpsException

getWrappedGpsDevice

public ActiveMirrorGpsDevice getWrappedGpsDevice()
Returns the wrapped active mirror gps device.


setWrappedGpsDevice

public void setWrappedGpsDevice(ActiveMirrorGpsDevice gpsDevice)
Sets the wrapped gps device.


performMirroring

public void performMirroring()
                      throws CompassGpsException
Performs the actual mirror operation, delegating the action to the wrapped gps device.

Specified by:
performMirroring in interface ActiveMirrorGpsDevice
Throws:
CompassGpsException

isDaemon

public boolean isDaemon()
If the scheduled timer whould work as a daemon thread or not.


setDaemon

public void setDaemon(boolean daemon)
Sets if the scheduled timer would work as a daemon thread or not.


getPeriod

public long getPeriod()
The period of the scheduled service in milli-seconds.


setPeriod

public void setPeriod(long period)
Sets the period of the scheduled service in milli-seconds.

Parameters:
period -


Copyright (c) 2004-2008 The Compass Project.