SRJRCFrames
v0.1.296

de.schwarzrot.app.domain
Class ServiceDefinition

java.lang.Object
  extended by com.jgoodies.binding.beans.Model
      extended by de.schwarzrot.data.support.AbstractEntity
          extended by de.schwarzrot.app.domain.ServiceDefinition
All Implemented Interfaces:
com.jgoodies.binding.beans.Observable, Entity, Serializable, Comparable<Entity>

public class ServiceDefinition
extends AbstractEntity

bean used to store the definition of a java system service. Java system services are applications that could be started by ServiceManager. Each system service is bound to the hostname of the machine, it is installed to.

Life cycle of a service is defined by Status. A java system service can be enriched by a command, executed before the service will be started and a command, that gets executed after the service has been stopped. Primary intention of the wrapper commands was to handle the start of a fileserver via wakeOnLan.

The life cycle of a service:

Start requested
this is the trigger set by the command center
Starting
the ServiceManager has started to start the service. If the service is enriched by wrapper commands, the ScriptPreStart will be executed. The time of execution is stored, so the ServiceManager is able to wait waitPreStart time before trying to start the service itself. If a startTrigger is defined, the ServiceManager checks the existance of the trigger file. The serivce will not get startet, until the trigger file exists.
Started
the ServiceManager has started the real java system service.
Running
the ServiceManager has verified the running service, so it is really up and running
Stop requested
the trigger from command center to stop a service
Stopping
the ServiceManager hast started to stop the service
Stopped
the ServiceManager has verified, that the service is stopped. If the service is enriched by wrapper commands, the ServiceManager waits waitPostEnd time, before the ScriptPostEnd will be executed. If a startTrigger is defined, the ScriptPostEnd should ensure, that the trigger file does not exists any more.

Author:
Reinhard Mantey
See Also:
Serialized Form

Nested Class Summary
static class ServiceDefinition.Status
           
 
Field Summary
static int REQUEST_SHUTDOWN
           
static int REQUEST_STARTUP
           
 
Constructor Summary
ServiceDefinition()
           
 
Method Summary
 String getComment()
          returns the comment of this service definition
 List<SortInfo> getDefaultOrder()
          returns a list of SortInfo, that build the order for default list-queries.
 Date getDtStarted()
          returns the timestamp when the service has been started
 Date getDtStopped()
          returns the timestamp when the service has been stopped
 String getHostName()
          returns the hostname of the machine, the service has been installed to
 File getLogConfig()
          returns the path of a java properties file, used to configure java logging
 Map<String,String> getMappings()
          returns a map with mappings of logical property names to physical property names (column names in database terms).
 String getName()
          returns the name of the defined service
 String getPersistenceName()
          returns the name of the entity for persistance.
 int getPid()
          returns the process id of the running service. 0 signals a stopped service
 File getScriptPostEnd()
           
 File getScriptPreStart()
           
 String getServiceClassname()
          returns the classname of the service
 File getServicePath()
          returns the path of the service archive.
 int getSleepTime()
          returns the time to sleep between consecutive jobs.
 String getStartTrigger()
          returns the path of a file, that must exist, to enable the ServiceManager to start the service
 String getStartupArgs()
          returns all startup parameters joined together into one String.
 ServiceDefinition.Status getStatus()
          returns the status of a java system service
 List<String> getUniqColumnNames()
          returns a list of property names, which serve to detect a uniq instance without the usage of the primary key.
 String getUserName()
          returns the username, that is used to run the service.
 int getWaitPostEnd()
          returns the wait time in seconds to wait after service has ended, before starting the PostEnd-script
 int getWaitPreStart()
          returns the wait time in seconds to wait after executing the PreStart-script before starting the service
 boolean isAutoStart()
          returns true, if the service should be startet automatically.
 void setAutoStart(boolean autoStart)
          sets the autostart flag of a service.
 void setComment(String comment)
          sets the comment of a service definition
 void setDtStarted(Date dtStarted)
          sets the startup time of a service
 void setDtStopped(Date dtStopped)
          sets the timestamp when the service has been stopped
 void setHostName(String hostName)
          sets the hostname, where the service has been installed to.
 void setLogConfig(File logConfig)
          sets the path of the java properties file, used to configure java logging
 void setName(String name)
          sets the name of a service
 void setPid(int pid)
          sets the process id of a running service. 0 signals a service that is not running
 void setScriptPostEnd(File scriptPostEnd)
          sets the command, that should be executed after the service has been stopped
 void setScriptPreStart(File scriptPreStart)
          sets the command, that should be executed before the service will be started
 void setServiceClassname(String serviceClassname)
          sets the classname of the service
 void setServicePath(File servicePath)
          sets the path of the services archive.
 void setSleepTime(int sleepTime)
          sets the time (in seconds) the service should sleep in idle mode
 void setStartTrigger(String startTrigger)
          sets the path of a trigger file.
 void setStartupArgs(String startupArgs)
          sets the startup parameters for the service.
 void setStatus(ServiceDefinition.Status status)
          sets the status of a service
 void setUserName(String userName)
          sets the system user, that should be used to run the service
 void setWaitPostEnd(int waitPostEnd)
          sets the time to wait (in seconds) after the service has been stopped, before executing the post-end-script
 void setWaitPreStart(int waitPreStart)
          sets the time to wait (in seconds) after execution of pre-start-script, before starting the service
 
Methods inherited from class de.schwarzrot.data.support.AbstractEntity
adoptChildren, adoptChildren, adoptGroupedChildren, compareTo, equals, getCModified, getCode, getDtCreated, getDtModified, getId, getLogger, getSchemaName, getSkipList, getSystemClass, getUCreated, getUModified, getUserAttributes, getVariantColumnName, getVariantTypeMap, hashCode, isDirty, isUserType, isVirtual, setCModified, setDirty, setDtCreated, setDtModified, setId, setSchemaName, setUCreated, setUModified, toString, validate
 
Methods inherited from class com.jgoodies.binding.beans.Model
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jgoodies.binding.beans.Observable
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

REQUEST_SHUTDOWN

public static final int REQUEST_SHUTDOWN
See Also:
Constant Field Values

REQUEST_STARTUP

public static final int REQUEST_STARTUP
See Also:
Constant Field Values
Constructor Detail

ServiceDefinition

public ServiceDefinition()
Method Detail

getComment

public final String getComment()
returns the comment of this service definition

Returns:
- comment of a service

getDefaultOrder

public List<SortInfo> getDefaultOrder()
Description copied from interface: Entity
returns a list of SortInfo, that build the order for default list-queries.

Specified by:
getDefaultOrder in interface Entity
Overrides:
getDefaultOrder in class AbstractEntity
Returns:
a list of property names

getDtStarted

public final Date getDtStarted()
returns the timestamp when the service has been started

Returns:
- time of system start

getDtStopped

public final Date getDtStopped()
returns the timestamp when the service has been stopped

Returns:
the dtStopped

getHostName

public final String getHostName()
returns the hostname of the machine, the service has been installed to

Returns:
the hostName

getLogConfig

public final File getLogConfig()
returns the path of a java properties file, used to configure java logging

Returns:
- path of log configuration

getMappings

public Map<String,String> getMappings()
Description copied from interface: Entity
returns a map with mappings of logical property names to physical property names (column names in database terms).

Every implementation should respect the parents mappings. The following sample shows different mapping types:

 public Map<String, String> getMappings() {
     Map<String, String> mappings = super.getMappings();
     mappings.put("title", "name");
     mappings.put("streams", Stream.class.getName());
     mappings.put("pageDefinitions", "pageType|" + ThemeElement.class.getName());
     return mappings;
 }
 
The mappings explained:
"title" -> "name"
the logical "title"-attribute is stored to persistence with a physical name "name"
"streams" -> Stream.class.getName()
the "streams" property holds related children. Unknown children are hold in a List, known (named) children are hold in a Map. The mapped value is used as classname to create child instances.
"pageDefinitions" -> "pageType|" + ThemeElement.class.getName()
pageDefinitions is a property of type Map, that holds grouped children. Known children are hold by a Map, unknown children by a List, so "pageDefinitions" may contain elements of type Map, or List. pageType, a property of ThemeElement, is used to group the children. The word before the '|' is the property name used as key value for grouping and the type after '|' is used to create instances.

Specified by:
getMappings in interface Entity
Overrides:
getMappings in class AbstractEntity
Returns:
a Map with property names as keys and column names as values.

getName

public final String getName()
returns the name of the defined service

Returns:
- the name of the service

getPersistenceName

public final String getPersistenceName()
Description copied from interface: Entity
returns the name of the entity for persistance. Normally it would be the same result as getClass().getSimpleName(), but some storage may have size limitations, or don't support case sensitive names, so this call is to deal with that kind of limitations.

Specified by:
getPersistenceName in interface Entity
Overrides:
getPersistenceName in class AbstractEntity
Returns:
the entity-name used for persistence

getPid

public final int getPid()
returns the process id of the running service. 0 signals a stopped service

Returns:
- the process id of a running service

getScriptPostEnd

public final File getScriptPostEnd()
Returns:
the scriptname to execute after service has terminated

getScriptPreStart

public final File getScriptPreStart()
Returns:
the scriptname to execute before starting the service

getServiceClassname

public final String getServiceClassname()
returns the classname of the service

Returns:
the classname of the service

getServicePath

public final File getServicePath()
returns the path of the service archive. This will be the absolute path of a jar-file

Returns:
- the path of the service jarfile

getSleepTime

public final int getSleepTime()
returns the time to sleep between consecutive jobs. Typically a service performs jobs. If there is no job to perform, the service signals 'idle'. A service in 'idle' state is going to sleep that time, until it rechecks for new jobs.

Returns:
- the time to sleep in seconds

getStartTrigger

public final String getStartTrigger()
returns the path of a file, that must exist, to enable the ServiceManager to start the service

Returns:
- the path of a file

getStartupArgs

public final String getStartupArgs()
returns all startup parameters joined together into one String.

Returns:
- the startup parameters

getStatus

public final ServiceDefinition.Status getStatus()
returns the status of a java system service

Returns:
- a status of a java system service

getUniqColumnNames

public List<String> getUniqColumnNames()
Description copied from interface: Entity
returns a list of property names, which serve to detect a uniq instance without the usage of the primary key. In database context this list is used to decide, whether a save operation needs an update or an insert.

Specified by:
getUniqColumnNames in interface Entity
Overrides:
getUniqColumnNames in class AbstractEntity
Returns:
a list of property names

getUserName

public final String getUserName()
returns the username, that is used to run the service. Each service process is changed to a user environment. The username must be an existing system user from the host, that runs the services. The ServiceManager is intended to run in superuser mode, to be able to change the user of the java services.

Returns:
the user of this service

getWaitPostEnd

public final int getWaitPostEnd()
returns the wait time in seconds to wait after service has ended, before starting the PostEnd-script

Returns:
the wait time in seconds

getWaitPreStart

public final int getWaitPreStart()
returns the wait time in seconds to wait after executing the PreStart-script before starting the service

Returns:
- the wait time in seconds

isAutoStart

public final boolean isAutoStart()
returns true, if the service should be startet automatically. The autostart is processed as soon as the service has the Status stopped.

Returns:
the autoStart

setAutoStart

public final void setAutoStart(boolean autoStart)
sets the autostart flag of a service. A service marked as 'autostart' will be started without requests from command center. The autostart trigger is processed when the service is in status stopped.

Parameters:
autoStart - - true if the service should be started automatically, false for services that should be started an requests from command center only

setComment

public final void setComment(String comment)
sets the comment of a service definition

Parameters:
comment - - the comment of this definition

setDtStarted

public final void setDtStarted(Date dtStarted)
sets the startup time of a service

Parameters:
dtStarted - - the timestamp when the service has been started

setDtStopped

public final void setDtStopped(Date dtStopped)
sets the timestamp when the service has been stopped

Parameters:
dtStopped - - the timestamp when the service has been stopped

setHostName

public final void setHostName(String hostName)
sets the hostname, where the service has been installed to.

Parameters:
hostName - - the name of the machine that hosts the service

setLogConfig

public final void setLogConfig(File logConfig)
sets the path of the java properties file, used to configure java logging

Parameters:
logConfig - - path of the log configuration

setName

public final void setName(String name)
sets the name of a service

Parameters:
name - - the name of the service

setPid

public final void setPid(int pid)
sets the process id of a running service. 0 signals a service that is not running

Parameters:
pid - - the process id of the service

setScriptPostEnd

public final void setScriptPostEnd(File scriptPostEnd)
sets the command, that should be executed after the service has been stopped

Parameters:
scriptPostEnd - - the path to a system command

setScriptPreStart

public final void setScriptPreStart(File scriptPreStart)
sets the command, that should be executed before the service will be started

Parameters:
scriptPreStart - - the path of a system command

setServiceClassname

public final void setServiceClassname(String serviceClassname)
sets the classname of the service

Parameters:
serviceClassname - - the classname of the service

setServicePath

public final void setServicePath(File servicePath)
sets the path of the services archive. That path is the absolute path of a jar file.

Parameters:
servicePath - - path of the services jar

setSleepTime

public final void setSleepTime(int sleepTime)
sets the time (in seconds) the service should sleep in idle mode

Parameters:
sleepTime - - time to sleep

setStartTrigger

public final void setStartTrigger(String startTrigger)
sets the path of a trigger file. The existance of the trigger file is checked by the ServiceManager before starting the service

Parameters:
startTrigger - - the path of a file that must exists before the service will be started

setStartupArgs

public final void setStartupArgs(String startupArgs)
sets the startup parameters for the service. All parameters are joined together to form a single string.

Parameters:
startupArgs - - the arguments of a service

setStatus

public final void setStatus(ServiceDefinition.Status status)
sets the status of a service

Parameters:
status - - the status of the service

setUserName

public final void setUserName(String userName)
sets the system user, that should be used to run the service

Parameters:
userName - - a name of a system user

setWaitPostEnd

public final void setWaitPostEnd(int waitPostEnd)
sets the time to wait (in seconds) after the service has been stopped, before executing the post-end-script

Parameters:
waitPostEnd - - the time to wait

setWaitPreStart

public final void setWaitPreStart(int waitPreStart)
sets the time to wait (in seconds) after execution of pre-start-script, before starting the service

Parameters:
waitPreStart - - the time to wait

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.