SRJRCFrames
v0.1.296

de.schwarzrot.app.support
Class AbstractService<C extends ServiceConfig>

java.lang.Object
  extended by de.schwarzrot.app.support.AbstractService<C>
Type Parameters:
C - - type of configuration
All Implemented Interfaces:
MainEntry<C>, Service<C>, UserNameProvider, Runnable
Direct Known Subclasses:
SampleService, ServiceManager

public abstract class AbstractService<C extends ServiceConfig>
extends Object
implements Service<C>

implements the common stuff for services

Author:
Reinhard Mantey

Constructor Summary
protected AbstractService(C config)
           
protected AbstractService(C config, SystemDefault applicationDefaults)
           
 
Method Summary
 Map<String,String> getAppArgs()
          provide access to the expanded arguments of main(String[] args)
 String getAppInfo()
          print initial startup information
 String getAppInfo(String appName)
           
 SystemDefault getApplicationDefaults()
          access the application defaults.
 String getApplicationName()
          print the application name - may be localized.
 C getConfig()
          access application starters configuration instance
protected  org.apache.commons.logging.Log getLogger()
           
 String getUserName()
          return the name of the applications user.
 boolean isShutdownRequested()
          will be used by the ServiceStarter, which has the service main loop.
 void setAppArgs(Map<String,String> appArgs)
          set expanded arguments of main(String[] args)
 void setConfig(C config)
          set application starters configuration instance
 void setShutdownRequested(boolean shutdown)
          setter to request a shutdown of the service from inside.
 void setupEarly()
          first stage of initialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.schwarzrot.app.Service
isIdle, setupLate
 
Methods inherited from interface de.schwarzrot.app.MainEntry
usage
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

AbstractService

protected AbstractService(C config)

AbstractService

protected AbstractService(C config,
                          SystemDefault applicationDefaults)
Method Detail

getAppArgs

public Map<String,String> getAppArgs()
Description copied from interface: MainEntry
provide access to the expanded arguments of main(String[] args)

Specified by:
getAppArgs in interface MainEntry<C extends ServiceConfig>
Returns:
- given arguments (if any)

getAppInfo

public String getAppInfo()
Description copied from interface: MainEntry
print initial startup information

Specified by:
getAppInfo in interface MainEntry<C extends ServiceConfig>
Returns:
- the message to print at application start

getAppInfo

public String getAppInfo(String appName)

getApplicationDefaults

public final SystemDefault getApplicationDefaults()
Description copied from interface: MainEntry
access the application defaults. As the framework provides parts of application contexts, its essential to be able to change the settings of the placeholderConfigurer. So the SystemDefaults can't be coded as static class. This call will return an instance, that is provided by the framework, but can be overwritten by user applications.

Specified by:
getApplicationDefaults in interface MainEntry<C extends ServiceConfig>
Returns:
an instance that provides the system defaults

getApplicationName

public String getApplicationName()
Description copied from interface: MainEntry
print the application name - may be localized. For identifying purpose consider using SystemDefault.applicationID

Specified by:
getApplicationName in interface MainEntry<C extends ServiceConfig>
Returns:
- the applications name

getConfig

public C getConfig()
Description copied from interface: MainEntry
access application starters configuration instance

Specified by:
getConfig in interface MainEntry<C extends ServiceConfig>
Returns:
the configuration instance

getUserName

public String getUserName()
Description copied from interface: UserNameProvider
return the name of the applications user. That username does not need to be the same as the operating system user.

Specified by:
getUserName in interface UserNameProvider
Returns:
a username

isShutdownRequested

public final boolean isShutdownRequested()
Description copied from interface: Service
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.

Specified by:
isShutdownRequested in interface Service<C extends ServiceConfig>
Returns:
true if shutdown was requested, false if not

setAppArgs

public void setAppArgs(Map<String,String> appArgs)
Description copied from interface: MainEntry
set expanded arguments of main(String[] args)

Specified by:
setAppArgs in interface MainEntry<C extends ServiceConfig>
Parameters:
appArgs - arguments from main expanded to key/value pairs

setConfig

public void setConfig(C config)
Description copied from interface: MainEntry
set application starters configuration instance

Specified by:
setConfig in interface MainEntry<C extends ServiceConfig>
Parameters:
config - the configuration instance

setShutdownRequested

public void setShutdownRequested(boolean shutdown)
Description copied from interface: Service
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.

Specified by:
setShutdownRequested in interface Service<C extends ServiceConfig>
Parameters:
shutdown - - set to true if the service should stop

setupEarly

public void setupEarly()
Description copied from interface: Service
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.

Specified by:
setupEarly in interface Service<C extends ServiceConfig>

getLogger

protected final org.apache.commons.logging.Log getLogger()

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.