SRJRCFrames
v0.1.296

de.schwarzrot.app
Interface Service<C extends ServiceConfig>

Type Parameters:
C - - service configuration entity
All Superinterfaces:
MainEntry<C>, Runnable, UserNameProvider
All Known Implementing Classes:
AbstractService, SampleService, ServiceManager

public interface Service<C extends ServiceConfig>
extends MainEntry<C>, UserNameProvider

provides the operating system view of a background-task/system service. A Service will be startet by a ServiceStarter, which cares about the interface to operating system. The Service itself can focus on the view, what should be done.

setup is an asynchronous initialization entry, which will be called independant of the services constructor. When setup gets called, the service is already daemonized and running.

The ServiceStarter provides property-parsing, as well as the services main loop. So the service implementation should not contain a loop. run should be sequential processing, which can be executed cyclically.

Author:
Reinhard Mantey

Method Summary
 boolean isIdle()
          will be used by the ServiceLauncher to determine, whether it should sleep between the calls to Service.run().
 boolean isShutdownRequested()
          will be used by the ServiceStarter, which has the service main loop.
 void setShutdownRequested(boolean shutdown)
          setter to request a shutdown of the service from inside.
 void setupEarly()
          first stage of initialization.
 void setupLate()
          second stage of initialization.
 
Methods inherited from interface de.schwarzrot.app.MainEntry
getAppArgs, getAppInfo, getApplicationDefaults, getApplicationName, getConfig, setAppArgs, setConfig, usage
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface de.schwarzrot.data.access.UserNameProvider
getUserName
 

Method Detail

isIdle

boolean isIdle()
will be used by the ServiceLauncher to determine, whether it should sleep between the calls to Service.run().

Returns:
true if the Service was idle, otherwise false

isShutdownRequested

boolean isShutdownRequested()
will be used by the ServiceStarter, which has the service main loop. A request to terminate a service may be come from inside (the service itself) or from outside (the os-user). The ServiceStarter cares about the outside world and the service may trigger a shutdown by setting shutdownRequested to true.

Returns:
true if shutdown was requested, false if not

setShutdownRequested

void setShutdownRequested(boolean shutdown)
setter to request a shutdown of the service from inside. The service should not use System.exit, but set the shutdownRequested flag. The ServiceStarter then cares about shutdown and cleanup.

Parameters:
shutdown - - set to true if the service should stop

setupEarly

void setupEarly()
first stage of initialization. Will be called right after daemonizing the service. This step of initialization happens before loading other jarfiles, right after processing of application context.


setupLate

void setupLate()
second stage of initialization. Will be called after loading all referenced external jars, right before starting the service loop.


SRJRCFrames
v0.1.296

hosted at
Find SRJRCFrames at SourceForge.net. Fast, secure and free:
           Open Source Software download
Submit a bug or request a feature

SRJRCFrames is published according to the GNU General Public License
Copyright 2005-2012 Reinhard Mantey - some rights reserved.