de.janrufmonitor.service
Class AbstractConfigurableService

java.lang.Object
  extended by de.janrufmonitor.service.AbstractConfigurableService
All Implemented Interfaces:
IConfigurable, IService
Direct Known Subclasses:
AbstractReceiverConfigurableService

public abstract class AbstractConfigurableService
extends Object
implements IService, IConfigurable

This abstract class can be used as base class for a new service implementation which is supporting configuration.

Author:
Thilo Brandt

Field Summary
protected  String CFG_ENABLED
           
protected  String CFG_PRIORITY
           
protected  Properties m_configuration
           
protected  Logger m_logger
           
 
Constructor Summary
AbstractConfigurableService()
          Default constructor.
 
Method Summary
 String getConfigurableID()
          Gets the ID of the configurable object.
 List getDependencyServices()
          Gets a list of IDs (java.lang.String) of services which have to be started before this service is started.
abstract  String getID()
          Gets the ID of the new service.
abstract  String getNamespace()
          Gets the namespace of the configurable object.
 int getPriority()
          Gets the priority of the service within the framework. 0 = hight priority, 999 = low priority.
abstract  IRuntime getRuntime()
          Gets the runtime objects.
 String getServiceID()
          Gets the ID of the service.
 boolean isEnabled()
          Checks if the service is enabled.
 boolean isRunning()
          Checks if the service is running.
 void restart()
          Restarts the service.
 void setConfiguration(Properties configuration)
          Sets the configuration in the configurable object.
 void setEnabled(boolean enabled)
          Sets the status of a service.
 void shutdown()
          Shuts down the service.
 void startup()
          Starts up the service.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CFG_ENABLED

protected String CFG_ENABLED

CFG_PRIORITY

protected String CFG_PRIORITY

m_logger

protected Logger m_logger

m_configuration

protected Properties m_configuration
Constructor Detail

AbstractConfigurableService

public AbstractConfigurableService()
Default constructor. Creates a new instance and initializes the logging capabilities.

Method Detail

getServiceID

public String getServiceID()
Description copied from interface: IService
Gets the ID of the service.

Specified by:
getServiceID in interface IService
Returns:
a valid service ID

getConfigurableID

public String getConfigurableID()
Description copied from interface: IConfigurable
Gets the ID of the configurable object.

Specified by:
getConfigurableID in interface IConfigurable
Returns:
a valid and unique ID

isEnabled

public boolean isEnabled()
Description copied from interface: IService
Checks if the service is enabled.

Specified by:
isEnabled in interface IService
Returns:
true if enabled, false if not

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: IService
Sets the status of a service.

Specified by:
setEnabled in interface IService
Parameters:
enabled - true if enabled, false if not.

getPriority

public int getPriority()
Description copied from interface: IService
Gets the priority of the service within the framework. 0 = hight priority, 999 = low priority.

Specified by:
getPriority in interface IService
Returns:
priority of the service.

setConfiguration

public void setConfiguration(Properties configuration)
Description copied from interface: IConfigurable
Sets the configuration in the configurable object. This method is called by the configuration notifier to interact with its registered components.

Specified by:
setConfiguration in interface IConfigurable
Parameters:
configuration - the configuration for the given namespace

restart

public void restart()
Description copied from interface: IService
Restarts the service.

Specified by:
restart in interface IService

startup

public void startup()
Description copied from interface: IService
Starts up the service. Can be used for initialization.

Specified by:
startup in interface IService

shutdown

public void shutdown()
Description copied from interface: IService
Shuts down the service. Can be used for cleanup.

Specified by:
shutdown in interface IService

isRunning

public boolean isRunning()
Description copied from interface: IService
Checks if the service is running.

Specified by:
isRunning in interface IService
Returns:
true if running, false if not

getDependencyServices

public List getDependencyServices()
Description copied from interface: IService
Gets a list of IDs (java.lang.String) of services which have to be started before this service is started.

Specified by:
getDependencyServices in interface IService
Returns:
a list of service IDs

getNamespace

public abstract String getNamespace()
Description copied from interface: IConfigurable
Gets the namespace of the configurable object.

Specified by:
getNamespace in interface IConfigurable
Returns:
a valid and unique namespace

getID

public abstract String getID()
Gets the ID of the new service. The ID is taken for registration at service factory and at the configurable notifier.

Returns:
service ID

getRuntime

public abstract IRuntime getRuntime()
Gets the runtime objects.

Returns:
the current runtime object.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010 by Thilo Brandt. All Rights Reserved.