org.jwarp.service
Class AService

java.lang.Object
  |
  +--org.jwarp.service.AService
All Implemented Interfaces:
IConfigurable, IExceptionProvider, IReferenceable, IService
Direct Known Subclasses:
CacheService, ConfigurationService, EJBService, IdService, LocalizationService, LogService, MailService, ObjectPoolService, ParamService, PersistenceService, PoolService, ReferenceResolver, SecurityService, ThreadPoolService, WebService, WorkService

public abstract class AService
extends java.lang.Object
implements IService, IReferenceable

Basic implementation of a JWeb service.

Version:
1.0
Author:
ORCA Systems GmbH, Martin Schäfer, ORCA Systems GmbH, Anatole Tresch

Field Summary
protected  IContext context
           
protected  java.util.Date createdDate
           
protected  java.lang.String[] dependencies
           
protected static java.util.Properties emptyProperties
          Additional or noirmal service properties that are also settable during service run.
protected  java.util.List exceptionListeners
           
protected  ILogWriter log
           
protected  java.util.Date resumedDate
           
protected  java.lang.String serviceName
          The service's name
protected  int serviceStatus
          The current service status
protected  java.lang.String serviceType
          The service's type identifier
protected  java.util.Date startedDate
           
protected  java.util.Date stoppedDate
           
protected  java.util.Date suspendedDate
           
protected  ITicket systemTicket
           
 
Fields inherited from interface org.jwarp.service.IService
SERVICE_STATUS_CREATED, SERVICE_STATUS_NOT_AVAILABLE, SERVICE_STATUS_READY, SERVICE_STATUS_RESUMING, SERVICE_STATUS_RUNNING, SERVICE_STATUS_STARTING, SERVICE_STATUS_STOPPED, SERVICE_STATUS_STOPPING, SERVICE_STATUS_SUSPENDED
 
Constructor Summary
protected AService(java.lang.String type)
          Creates a new service
protected AService(java.lang.String type, IContext context)
          Creates a new service
protected AService(java.lang.String type, java.lang.String name)
          Creates a new service
protected AService(java.lang.String type, java.lang.String name, IContext context)
           
 
Method Summary
 void addExceptionListener(IExceptionListener handler)
           
 void checkContext(IContext context)
          This checks if the given context is a valid context for the service.
 void configure(org.jdom.Element config)
          Pass the Configuration to the Configurable class.
 ILogWriter createLogFromXML(org.jdom.Element writer)
          This method reads in and initialized a log writer object.
 IContext getContext()
          Return the services context.
 java.util.Date getCreationDate()
           
 java.lang.String[] getDependencies()
           
 java.util.Iterator getExceptionListeners()
           
 ILogWriter getLog()
           
 int getLogLevel()
          This method returns if the application actually is running in debugging mode and so printing more detailed information on errors
 java.lang.String getName()
          Get the service's name
 java.lang.String getReference()
          Get the reference for registering within the context resolver.
 java.util.Date getResumedDate()
           
 java.util.Date getShutDownDate()
           
 java.util.Date getStartDate()
           
 int getStatus(ITicket ticket)
          Returns the current status of the service
 java.util.Date getSuspendedDate()
           
 java.lang.String getType()
          Get the service type identifier.
 void removeAllExceptionListeners()
           
 void removeExceptionListener(IExceptionListener listener)
           
 void resume(ITicket ticket)
          Resume the service
protected  void sendExceptionEvent(java.lang.Exception e, java.lang.Object o)
           
 void setContext(IContext context, ITicket user)
          Change the service's context.
 void setDependencies(java.lang.String[] dependencies)
           
 void setLogLevel(int level)
          With this method debugging mode can be switched on and off
protected  void setName(java.lang.String name)
          Reset the service's name.
 void shutdown(ITicket ticket)
          Shutdown the service
 void start(ITicket ticket)
          Start the service with the given configuration.
 void suspend(ITicket ticket)
          Suspend the service
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emptyProperties

protected static final java.util.Properties emptyProperties
Additional or noirmal service properties that are also settable during service run.

context

protected IContext context

systemTicket

protected ITicket systemTicket

log

protected ILogWriter log

createdDate

protected java.util.Date createdDate

startedDate

protected java.util.Date startedDate

stoppedDate

protected java.util.Date stoppedDate

resumedDate

protected java.util.Date resumedDate

suspendedDate

protected java.util.Date suspendedDate

serviceStatus

protected int serviceStatus
The current service status

serviceName

protected java.lang.String serviceName
The service's name

serviceType

protected java.lang.String serviceType
The service's type identifier

dependencies

protected java.lang.String[] dependencies

exceptionListeners

protected java.util.List exceptionListeners
Constructor Detail

AService

protected AService(java.lang.String type,
                   IContext context)
Creates a new service

AService

protected AService(java.lang.String type,
                   java.lang.String name,
                   IContext context)

AService

protected AService(java.lang.String type)
Creates a new service

AService

protected AService(java.lang.String type,
                   java.lang.String name)
Creates a new service
Method Detail

configure

public void configure(org.jdom.Element config)
               throws ConfigurationException
Description copied from interface: IConfigurable
Pass the Configuration to the Configurable class. This method must always be called after the constructor and before any other method.
Specified by:
configure in interface IConfigurable
Following copied from interface: org.jwarp.service.configuration.IConfigurable
Parameters:
configuration - the class configurations.

getDependencies

public java.lang.String[] getDependencies()
Specified by:
getDependencies in interface IService

setDependencies

public void setDependencies(java.lang.String[] dependencies)
Specified by:
setDependencies in interface IService

getLog

public ILogWriter getLog()

getType

public java.lang.String getType()
Get the service type identifier. This is not modifiable since it is initialised at creation time of the service.
Specified by:
getType in interface IService
Returns:
The service dentifier

getContext

public IContext getContext()
Return the services context.

setContext

public final void setContext(IContext context,
                             ITicket user)
                      throws java.lang.SecurityException
Description copied from interface: IService
Change the service's context. This is an admin and initialization method only.
Specified by:
setContext in interface IService
Following copied from interface: org.jwarp.service.IService
Parameters:
context - The context
user - The user
Throws:
java.lang.SecurityException - If the context is invalid

getName

public java.lang.String getName()
Get the service's name
Specified by:
getName in interface IService
Returns:
The service's name

getReference

public java.lang.String getReference()
Get the reference for registering within the context resolver.
Specified by:
getReference in interface IReferenceable

setName

protected void setName(java.lang.String name)
Reset the service's name. Attention by default no security check is done here.
Parameters:
ticket - The user
name - The new name

start

public void start(ITicket ticket)
           throws ServiceInitializationException,
                  java.lang.SecurityException
Start the service with the given configuration.
Specified by:
start in interface IService
Throws:
ServiceInitializationException - If the service could not started
java.lang.SecurityException - If access was denied.

shutdown

public void shutdown(ITicket ticket)
              throws ServiceRuntimeException,
                     java.lang.SecurityException
Shutdown the service
Specified by:
shutdown in interface IService
Parameters:
ticket - The user ticket
Throws:
ServiceRuntimeException - If the service could not be shut own
java.lang.SecurityException - If access was denied.

suspend

public void suspend(ITicket ticket)
             throws ServiceRuntimeException,
                    java.lang.SecurityException
Suspend the service
Specified by:
suspend in interface IService
Parameters:
ticket - The user ticket
Throws:
ServiceRuntimeException - If the service could not be suspended
java.lang.SecurityException - If access was denied.

resume

public void resume(ITicket ticket)
            throws ServiceRuntimeException,
                   java.lang.SecurityException
Resume the service
Specified by:
resume in interface IService
Parameters:
ticket - The user ticket
Throws:
ServiceRuntimeException - If the service could not be resumed
java.lang.SecurityException - If access was denied.

getStatus

public int getStatus(ITicket ticket)
              throws java.lang.SecurityException
Returns the current status of the service
Specified by:
getStatus in interface IService
Parameters:
ticket - The user ticket
Throws:
java.lang.SecurityException - If access was denied.

addExceptionListener

public void addExceptionListener(IExceptionListener handler)
Specified by:
addExceptionListener in interface IExceptionProvider

getExceptionListeners

public java.util.Iterator getExceptionListeners()
Specified by:
getExceptionListeners in interface IExceptionProvider

removeAllExceptionListeners

public void removeAllExceptionListeners()
Specified by:
removeAllExceptionListeners in interface IExceptionProvider

removeExceptionListener

public void removeExceptionListener(IExceptionListener listener)
Specified by:
removeExceptionListener in interface IExceptionProvider

sendExceptionEvent

protected void sendExceptionEvent(java.lang.Exception e,
                                  java.lang.Object o)

checkContext

public void checkContext(IContext context)
                  throws java.lang.SecurityException
This checks if the given context is a valid context for the service.
Specified by:
checkContext in interface IService
Parameters:
The - context
Throws:
java.lang.SecurityException - If the context is invalid

getStartDate

public java.util.Date getStartDate()

getShutDownDate

public java.util.Date getShutDownDate()

getSuspendedDate

public java.util.Date getSuspendedDate()

getResumedDate

public java.util.Date getResumedDate()

getCreationDate

public java.util.Date getCreationDate()

getLogLevel

public int getLogLevel()
This method returns if the application actually is running in debugging mode and so printing more detailed information on errors
Specified by:
getLogLevel in interface IService

setLogLevel

public void setLogLevel(int level)
With this method debugging mode can be switched on and off
Specified by:
setLogLevel in interface IService

createLogFromXML

public ILogWriter createLogFromXML(org.jdom.Element writer)
This method reads in and initialized a log writer object. This method is used to initialize the log service's log and the individual service's logs. If an error occurred null is returned.
Parameters:
The - XML log subtree

©   O R C A   S y s t e m s