org.objectweb.jonas.service
Class ServiceManager

java.lang.Object
  |
  +--org.objectweb.jonas.service.ServiceManager

public class ServiceManager
extends java.lang.Object

This class implements a manager of org.objectweb.jonas.service.Service for JOnAS. The services are defined in the jonas.properties files - 'jonas.services' property defines the list of the services, - for each service - 'jonas.service..class' property defines the class of the implementation of the service, - 'jonas.service..XXXX' properties define the configuration of the service

Author:
Helene Joanin Contributor(s): 01/06/15: Regis Le Brettevillois - Libelis 02/06 : Florent Benoit & Ludovic Bert : Ear service/Web Container service Philippe Durieux 03/01/14 Adriana Danes : pass the entire property name (jonas.service..XXXX) in the configuration context at service creation time

Method Summary
protected  javax.naming.Context createServiceContextFor(java.lang.String serviceName)
          Creates and returns the context for the configuration of the service which have the given name.
protected  Service createServiceFrom(java.lang.String serviceName)
          Creates and returns the service which have the given name.
static Service getDataBaseService()
          Return the DataBase service (service's name: 'dbm')
static Service getEarService()
          Return the Ear service (service's name: 'ear')
static Service getEjbService()
          Return the EJB service (service's name: 'ejb')
static ServiceManager getInstance()
          Get the unique instance.
static Service getJmsService()
          Return the JMS service (service's name: 'jms')
static Service getJmxService()
          Return the JMX service (service's name: 'jmx')
static Service getMailService()
          Return the mail service (service's name: 'mail').
static Service getRegistryService()
          Return the Registry service (service's name: 'registry')
static Service getSecurityService()
          Return the Security service (service's name: 'security')
static Service getService(java.lang.String name)
          Get the service which have the given name
 java.lang.String[] getServiceNames()
          return the list of services + registry if needed.
 Service[] getServices()
          Returns the list of the managed services
static Service getTransactionService()
          Return the Transaction service (service's name: 'jtm')
static Service getWebContainerService()
          Return the web service (service's name: 'web').
protected  void readServices()
          For each service, create it and its associated configuration context. (creates services, contextsByService and servicesByName)
 void startJmx()
          Start the jmx service
 void startRegistry()
          Start the mandatory "registry" service
 void startServices()
          Starts the managed services.
 void stopServices()
          Management Method: Stop all services.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ServiceManager getInstance()
                                  throws java.lang.Exception
Get the unique instance. Create it at first call.
Returns:
ServiceManager the unique instance
Throws:
java.lang.Exception - if the ServiceManager can't be built.

getService

public static Service getService(java.lang.String name)
                          throws ServiceException
Get the service which have the given name
Parameters:
name - the given name
Returns:
the service which have the given name
Throws:
ServiceException - if the service can't be retrieved.

getEjbService

public static Service getEjbService()
                             throws ServiceException
Return the EJB service (service's name: 'ejb')
Returns:
the EJB service.
Throws:
ServiceException - if can not get the ejb service.

getEarService

public static Service getEarService()
                             throws ServiceException
Return the Ear service (service's name: 'ear')
Returns:
the EAR service.
Throws:
ServiceException - if can not get the ear service.

getWebContainerService

public static Service getWebContainerService()
                                      throws ServiceException
Return the web service (service's name: 'web').
Returns:
the web service.
Throws:
ServiceException - if can not get the web service.

getMailService

public static Service getMailService()
                              throws ServiceException
Return the mail service (service's name: 'mail').
Returns:
the mail service.
Throws:
ServiceException - if can not get the mail service.

getDataBaseService

public static Service getDataBaseService()
                                  throws ServiceException
Return the DataBase service (service's name: 'dbm')
Returns:
the DBM service.
Throws:
ServiceException - if can not get the dbm service.

getTransactionService

public static Service getTransactionService()
                                     throws ServiceException
Return the Transaction service (service's name: 'jtm')
Returns:
the JTM service.
Throws:
ServiceException - if can not get the jtm service.

getJmsService

public static Service getJmsService()
                             throws ServiceException
Return the JMS service (service's name: 'jms')
Returns:
the JMS service.
Throws:
ServiceException - if can not get the jms service.

getSecurityService

public static Service getSecurityService()
                                  throws ServiceException
Return the Security service (service's name: 'security')
Returns:
the Security service.
Throws:
ServiceException - if can not get the security service.

getJmxService

public static Service getJmxService()
                             throws ServiceException
Return the JMX service (service's name: 'jmx')
Returns:
the JMX service.
Throws:
ServiceException - if can not get the jmx service.

getRegistryService

public static Service getRegistryService()
                                  throws ServiceException
Return the Registry service (service's name: 'registry')
Returns:
the Registry service.
Throws:
ServiceException - if can not get the registry service.

startRegistry

public void startRegistry()
                   throws ServiceException
Start the mandatory "registry" service
Throws:
ServiceException - if the "registry" service can't be started.

startJmx

public void startJmx()
              throws ServiceException
Start the jmx service
Throws:
ServiceException - if the jmx service can't be started.

startServices

public void startServices()
                   throws ServiceException
Starts the managed services.
Throws:
ServiceException - if the services can't be started.

getServices

public Service[] getServices()
                      throws ServiceException
Returns the list of the managed services
Returns:
String[] the name of the managed services.
Throws:
ServiceException - if the list can't be retrieved.

getServiceNames

public java.lang.String[] getServiceNames()
return the list of services + registry if needed.
Returns:
String[] the name of the services.

readServices

protected void readServices()
                     throws ServiceException
For each service, create it and its associated configuration context. (creates services, contextsByService and servicesByName)
Throws:
ServiceException - if the services can't be read.

createServiceFrom

protected Service createServiceFrom(java.lang.String serviceName)
                             throws ServiceException
Creates and returns the service which have the given name. (Uses the 'jonas.service..class' property for that)
Parameters:
serviceName - the name of the service to instanciate.
Returns:
Service the instance of the service.
Throws:
ServiceException - if the service can't be created.

createServiceContextFor

protected javax.naming.Context createServiceContextFor(java.lang.String serviceName)
                                                throws javax.naming.NamingException
Creates and returns the context for the configuration of the service which have the given name. (Uses the 'jonas.service..XXXX' properties for that)
Parameters:
serviceName - the name of the service to obtain the configuration.
Returns:
Context the context for the service.
Throws:
javax.naming.NamingException - if the context can't be built.

stopServices

public void stopServices()
                  throws ServiceException
Management Method: Stop all services. The services are stopped in the reverse order of their starting. (Continue the processing of stopping for the others services, even if there is a problem for one service.)
Throws:
ServiceException - if the service can't be stopped.