|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.orderlysoftware.orderlycalls.base.Service
public abstract class Service
Service is the base class for all OrderlyCalls Named Services.
OrderlyCalls translates entries in its XML configuration file into running
Service objects. The XML settings for each Service in the file are translated
into Settings
objects which are passed to the Service on creation.
You can extend the Service class to implement your own Service classes, and
the Settings
object to define your own initialisation settings for
your Services.
You should read the
ExampleService
code
and documentation if you intend to write your own Services.
Field Summary | |
---|---|
ServiceLogger |
log
|
protected Settings |
settings
|
Constructor Summary | |
---|---|
Service()
Default constructor. |
|
Service(Settings settings)
Creates a Service with the specified Settings. |
Method Summary | |
---|---|
static java.util.concurrent.ExecutorService |
getExecutorService()
Returns a general-purpose thread execution service. |
static Service |
getInstance(java.lang.Class serviceClass,
Settings settings,
boolean reuse)
Gets an initialised Service instance. |
static Service |
getInstance(Settings settings)
Gets an initialised Service instance. |
static Service |
getInstance(Settings settings,
boolean reuse)
Gets an initialised Service instance. |
static Service |
getInstanceByName(java.lang.String name)
Gets an initialised Service instance by the name of the Settings
object. |
java.lang.String |
getLogName()
Gets a string to identify this service for logging. |
java.lang.String |
getName()
Gets the name of the Settings object used to create this instance. |
Settings |
getSettings()
Gets the Settings object. |
abstract void |
init()
Initialise the service based on the given Settings object. |
abstract boolean |
isRunning()
Determines whether this service is active. |
static void |
setExecutorService(java.util.concurrent.ExecutorService executorService)
|
abstract void |
shutdown()
Shutdown this Service |
static void |
shutdownAll()
Subclasses SHOULD override this method to shutdown only services of a particular subclass. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public ServiceLogger log
protected Settings settings
Constructor Detail |
---|
public Service()
Subclasses MUST define a zero-argument constructor in order to work with the OrderlyCalls system.
public Service(Settings settings)
Subclasses MUST call this constructor using super(settings)
.
Subclasses MUST NOT perform service initialisation from within this constructor.
settings
- The settings object to use.Method Detail |
---|
public static Service getInstance(java.lang.Class serviceClass, Settings settings, boolean reuse)
This method creates an instance of the given class (which MUST subclass
Service) using the passed Settings
object.
If reuse is true, and a Service has already been created with the given Settings, then the pre-existing service is called.
If a new Service object is created, its init() method is then called.
This method MUST NOT be overridden/hidden by subclasses.
serviceClass
- the class of Service to createsettings
- the Settings
object to usereuse
- whether or not to reuse an existing Service object.
public static Service getInstance(Settings settings)
All descendant services MUST override this method in order to get a service of the appropriate subclass.
settings
- The settings to use in creating the service.
public static Service getInstance(Settings settings, boolean reuse)
All descendant services MUST override this method in order to get a service of the appropriate subclass.
settings
- The settings to use in creating the service.reuse
- Whether or not to reuse an existing Service object.
public static Service getInstanceByName(java.lang.String name)
Settings
object.
Subclasses SHOULD NOT override this method; instead create a new method:
public static void MyService getInstance(String name) { return (MyService)getInstanceByName(name); }
settings
- The settings to use in creating the service.reuse
- Whether or not to reuse an existing Service object.
public abstract void init()
Settings
object.
public abstract void shutdown()
public Settings getSettings()
Settings
object.
Settings
object used to initialise this Service.public abstract boolean isRunning()
public java.lang.String getName()
Settings
object).public java.lang.String getLogName()
public static void shutdownAll()
public static java.util.concurrent.ExecutorService getExecutorService()
public static void setExecutorService(java.util.concurrent.ExecutorService executorService)
executorService
- The executorService to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |