org.objectweb.jonas.service
Class ServiceManager

java.lang.Object
  extended by 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.
 Service getDataBaseService()
          Return the DataBase service (service's name: 'dbm')
 Service getDiscoveryService()
          Return the discovery service (service's name: 'discovery')
 Service getEarService()
          Return the Ear service (service's name: 'ear')
 Service getEjbService()
          Return the EJB service (service's name: 'ejb')
static ServiceManager getInstance()
          Get the unique instance.
 Service getJmsService()
          Return the JMS service (service's name: 'jms')
 Service getJmxService()
          Return the JMX service (service's name: 'jmx')
 Service getMailService()
          Return the mail service (service's name: 'mail').
 Service getRarService()
          Return the Rar service (service's name: 'resource')
 Service getRegistryService()
          Return the Registry service (service's name: 'registry')
 Service getResourceService()
          Return the Resource service (service's name: 'resource')
 Service getSecurityService()
          Return the Security service (service's name: 'security')
 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
 Service getTransactionService()
          Return the Transaction service (service's name: 'jtm')
 Service getWebContainerService()
          Return the web service (service's name: 'web').
 Service getWebServicesService()
          Return the WebServices service (service's name: 'ws').
protected  void readServices()
          For each service, create it and its associated configuration context.
 void startJmx(java.lang.String idMBeanServer)
          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()
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 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 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 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.

getRarService

public Service getRarService()
                      throws ServiceException
Return the Rar service (service's name: 'resource')

Returns:
the RAR service.
Throws:
ServiceException - if can not get the rar service.

getWebContainerService

public 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.

getWebServicesService

public Service getWebServicesService()
                              throws ServiceException
Return the WebServices service (service's name: 'ws').

Returns:
the WebServices service.
Throws:
ServiceException - if can not get the WebServices service.

getMailService

public 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 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 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 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 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 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.

getDiscoveryService

public Service getDiscoveryService()
                            throws ServiceException
Return the discovery service (service's name: 'discovery')

Returns:
the discovery service.
Throws:
ServiceException - if can not get the discovery service.

getRegistryService

public 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.

getResourceService

public Service getResourceService()
                           throws ServiceException
Return the Resource service (service's name: 'resource')

Returns:
the Resource service.
Throws:
ServiceException - if can not get the resource 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(java.lang.String idMBeanServer)
              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.