org.jwarp.service
Class ServiceFactory

java.lang.Object
  |
  +--org.jwarp.service.ServiceFactory
All Implemented Interfaces:
IServiceFactory

public class ServiceFactory
extends java.lang.Object
implements IServiceFactory

Class implementing a context's service factory.

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

Field Summary
static int STATUS_FACTORY_CREATED
          Run status
static int STATUS_FACTORY_READY
           
static int STATUS_FACTORY_RUNNING
           
 
Constructor Summary
ServiceFactory(IContext context)
          Creates a new service factory
 
Method Summary
 IService addService(org.jdom.Element config)
          Add dynamically a new service.
 void addService(IService service, java.lang.String name)
          Add dynamically a new service.
protected  void assureSecurityObjects(java.lang.String[][] secObjects)
           
 void configure(org.jdom.Element servicesRoot)
          Start the service with the given root configuration
 java.lang.String[][] getSecurityObjects()
          Returns the system object entities defined by this system instance.
 IService getService(java.lang.String serviceName)
          Return the service with the given name
 java.util.Iterator getServices()
          Returns all services.
protected  IService initService(java.lang.String implClass, java.lang.String name, org.jdom.Element config)
          Initialize a service.
 void removeService(java.lang.String serviceName)
          Remove dynamically a new service.
 void resumeService(java.lang.String serviceName, ITicket ticket)
          Resume a suspended service with the given root configuration
 void shutdownService(java.lang.String serviceName, ITicket ticket)
          Shut down a service with the given root configuration
protected  void shutdownServices(ITicket ticket)
          Shutdown all services
 void start(ITicket systemTicket)
          Initialize the factory's status, init the systemTicket and try to start all services.
 void startService(java.lang.String serviceName, ITicket ticket)
          Start a service with the given root configuration
protected  void startServices(ITicket ticket)
          Start the services found in the given configuration
 void stop(ITicket ticket)
          Tries to start the configured services.
 void suspendService(java.lang.String serviceName, ITicket ticket)
          Suspend a service with the given root configuration
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_FACTORY_CREATED

public static final int STATUS_FACTORY_CREATED
Run status

STATUS_FACTORY_READY

public static final int STATUS_FACTORY_READY

STATUS_FACTORY_RUNNING

public static final int STATUS_FACTORY_RUNNING
Constructor Detail

ServiceFactory

public ServiceFactory(IContext context)
Creates a new service factory
Method Detail

getSecurityObjects

public java.lang.String[][] getSecurityObjects()
Returns the system object entities defined by this system instance. Returnins an array of two element arrays (first elem: identifier string, secnod elem: description).
Specified by:
getSecurityObjects in interface IServiceFactory
Returns:
The security object string arrays (2 elems)

start

public void start(ITicket systemTicket)
           throws ServiceInitializationException,
                  ServiceRuntimeException
Initialize the factory's status, init the systemTicket and try to start all services. This method also tries to figure out and configure the factory's security context.
Specified by:
start in interface IServiceFactory
Parameters:
systemTicket - The system ticket.
Throws:
ServiceInitializationException - thrown when starting of a subprocess failed.

stop

public void stop(ITicket ticket)
          throws ServiceRuntimeException,
                 java.lang.SecurityException
Description copied from interface: IServiceFactory
Tries to start the configured services. Only the services should be started that are defined to be started per default thus also services can be configured that start on their first use or even must be started manually.
Specified by:
stop in interface IServiceFactory
Following copied from interface: org.jwarp.service.IServiceFactory
Throws:
ServiceInitializationException - One or more services are initialized well. Well initialize services should all be started.

startServices

protected void startServices(ITicket ticket)
Start the services found in the given configuration
Parameters:
configuration - the configuration containing other service configurations

shutdownServices

protected void shutdownServices(ITicket ticket)
                         throws ServiceRuntimeException,
                                java.lang.SecurityException
Shutdown all services
Parameters:
The - user

startService

public void startService(java.lang.String serviceName,
                         ITicket ticket)
                  throws ServiceInitializationException,
                         ServiceNotFoundException
Start a service with the given root configuration
Specified by:
startService in interface IServiceFactory
Parameters:
serviceRoot - the configuration root for this service

shutdownService

public void shutdownService(java.lang.String serviceName,
                            ITicket ticket)
                     throws ServiceRuntimeException,
                            ServiceNotFoundException
Shut down a service with the given root configuration
Specified by:
shutdownService in interface IServiceFactory
Parameters:
serviceRoot - the configuration root for this service

resumeService

public void resumeService(java.lang.String serviceName,
                          ITicket ticket)
                   throws ServiceRuntimeException,
                          ServiceNotFoundException
Resume a suspended service with the given root configuration
Specified by:
resumeService in interface IServiceFactory
Parameters:
serviceRoot - the configuration root for this service

suspendService

public void suspendService(java.lang.String serviceName,
                           ITicket ticket)
                    throws ServiceRuntimeException,
                           ServiceNotFoundException
Suspend a service with the given root configuration
Specified by:
suspendService in interface IServiceFactory
Parameters:
serviceRoot - the configuration root for this service

configure

public void configure(org.jdom.Element servicesRoot)
               throws ConfigurationException
Start the service with the given root configuration
Specified by:
configure in interface IServiceFactory
Parameters:
serviceRoot - the configuration root for this service

addService

public IService addService(org.jdom.Element config)
Add dynamically a new service.
Specified by:
addService in interface IServiceFactory
Parameters:
config - The XML config subtree for the service
Returns:
The newly created service instance

initService

protected IService initService(java.lang.String implClass,
                               java.lang.String name,
                               org.jdom.Element config)
                        throws ConfigurationException
Initialize a service. An instance of the given class is istantiated. This instance must implement the IService interface. For intilializing the methods setContext and configure are called.
Parameters:
serviceClass - Full qualified service class name.
name - The name under which the service should initialised
config - The configuration subtree for the service
Returns:
The service instance created or null if something failed

assureSecurityObjects

protected void assureSecurityObjects(java.lang.String[][] secObjects)
                              throws java.lang.SecurityException

getService

public IService getService(java.lang.String serviceName)
                    throws java.lang.SecurityException
Return the service with the given name
Specified by:
getService in interface IServiceFactory
Parameters:
serviceName - The name of the service to return

getServices

public java.util.Iterator getServices()
Returns all services. By default no security check is made thus making available all services directly to all users of the context.
Specified by:
getServices in interface IServiceFactory
Returns:
The services

addService

public void addService(IService service,
                       java.lang.String name)
                throws java.lang.SecurityException
Add dynamically a new service.
Specified by:
addService in interface IServiceFactory
Parameters:
service - The new service
serviceName - The service name under which the service should registered
ticket - The system user who must WRITE access to the factory
Throws:
java.lang.SecurityException - If access was denied or a service with the same name is running yet

removeService

public void removeService(java.lang.String serviceName)
                   throws java.lang.SecurityException,
                          ServiceNotFoundException
Remove dynamically a new service.
Specified by:
removeService in interface IServiceFactory
Parameters:
service - The new service
serviceName - The service name under which the service should registered
ticket - The system user who must WRITE access to the factory
Throws:
java.lang.SecurityException - If access was denied or a service with the same name is running yet

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