SunSPOT API V5.0


com.sun.spot.service
Class BasicService

java.lang.Object
  extended by com.sun.spot.service.BasicService
All Implemented Interfaces:
IService
Direct Known Subclasses:
EDemoBoardBlink, LowPan, LowPanSpotRadioHelper, RadioPacketDispatcher, RoutingPolicyManager, SpotBlink

public abstract class BasicService
extends Object
implements IService

A stub class for those simple services that do not run in their own threads.

Author:
Ron Goldman

Field Summary
 
Fields inherited from interface com.sun.spot.service.IService
PAUSED, PAUSING, READY, RESUMING, RUNNING, STARTING, STOPPED, STOPPING
 
Constructor Summary
BasicService()
           
 
Method Summary
 boolean getEnabled()
          Return whether service is started automatically on reboot.
abstract  String getServiceName()
          Return the name of this service.
 int getStatus()
          Return the current status of this service.
 boolean isRunning()
          Return whether the service is currently running.
 boolean pause()
          Pause the service, and return whether successful.
 boolean resume()
          Resume the service, and return whether successful.
 void setEnabled(boolean enable)
          Enable/disable whether service is started automatically.
 void setServiceName(String who)
          Assign a name to this service.
 boolean start()
          Start the service, and return whether successful.
 boolean stop()
          Stop the service, and return whether successful.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicService

public BasicService()
Method Detail

start

public boolean start()
Description copied from interface: IService
Start the service, and return whether successful.

Specified by:
start in interface IService
Returns:
true if the service was successfully started

stop

public boolean stop()
Description copied from interface: IService
Stop the service, and return whether successful. Stops all running threads. Closes any open IO connections.

Specified by:
stop in interface IService
Returns:
true if the service was successfully stopped

pause

public boolean pause()
Description copied from interface: IService
Pause the service, and return whether successful. Preserve any current state, but do not handle new requests. Any running threads should block or sleep. Any open IO connections may be kept open. If there is no particular state associated with this service then pause() can be implemented by calling stop().

Specified by:
pause in interface IService
Returns:
true if the service was successfully paused

resume

public boolean resume()
Description copied from interface: IService
Resume the service, and return whether successful. Picks up from state when service was paused. If there was no particular state associated with this service then resume() can be implemented by calling start().

Specified by:
resume in interface IService
Returns:
true if the service was successfully resumed

getStatus

public int getStatus()
Description copied from interface: IService
Return the current status of this service.

Specified by:
getStatus in interface IService
Returns:
the current status of this service, e.g. STOPPED, STARTING, RUNNING, PAUSED, STOPPING, etc.

isRunning

public boolean isRunning()
Description copied from interface: IService
Return whether the service is currently running.

Specified by:
isRunning in interface IService
Returns:
true if the service is currently running

getServiceName

public abstract String getServiceName()
Description copied from interface: IService
Return the name of this service.

Specified by:
getServiceName in interface IService
Returns:
the name of this service

setServiceName

public void setServiceName(String who)
Description copied from interface: IService
Assign a name to this service. For some fixed services this may not apply and any new name will just be ignored.

Specified by:
setServiceName in interface IService
Parameters:
who - the name for this service

getEnabled

public boolean getEnabled()
Description copied from interface: IService
Return whether service is started automatically on reboot. This may not apply to some services and for those services it will always return false.

Specified by:
getEnabled in interface IService
Returns:
true if the service is started automatically on reboot

setEnabled

public void setEnabled(boolean enable)
Description copied from interface: IService
Enable/disable whether service is started automatically. This may not apply to some services and calls to setEnabled() may be ignored.

Specified by:
setEnabled in interface IService
Parameters:
enable - true if the service should be started automatically on reboot

SunSPOT API V5.0


Copyright � 2006-2008 Sun Microsystems, Inc. All Rights Reserved.