org.apache.pluto.portalImpl.services
Class ServiceManager

java.lang.Object
  extended by org.apache.pluto.portalImpl.services.ServiceManager

public class ServiceManager
extends java.lang.Object

Manages the life-time of services registered during servlet startup. A service has to derive from ContainerService and implement the init() and destroy() methods as appropriate.

By registering the service and its implementation in the file /config/services.properties, the service will become available to the portal engine. The format of the file is simple:

   org.apache.pluto.portalImpl.services.log.LogService = org.apache.pluto.portalImpl.services.log.LogServicesImpl
 
Each entry represents one service. The left-hand side is the abstract service class, the right-hand side is the implementation of this service. The services are initialized in the order of appearance.

Each service can have its own configuration file, located in /config/services. It has to have the name of either implementation or abstract class of the service, without the leading package name. For example, the service manager looks for LogServiceImpl.properties. This allows a special implementation to provide different configuration than the general (abstract) service requires.

If present, one of the services configuration files is loaded and passed to the service as Properties object. Not providing a service configuration file is okay too, in that case the properties are empty.

See Also:
ContainerService

Constructor Summary
ServiceManager()
           
 
Method Summary
static void destroy(javax.servlet.ServletConfig aConfig)
          Destroys all services.
static org.apache.pluto.portalImpl.services.Service getService(java.lang.Class aClass)
          Returns the service implementation for the given service class, or null if no such service is registered.
static void init(javax.servlet.ServletConfig aConfig)
          Initializes all services specified in services.properties.
static void init(javax.servlet.ServletConfig config, java.lang.String serviceConfigFile)
          Initializes all services specified in services.properties.
static void postInit(javax.servlet.ServletConfig aConfig)
          Calls post init for all services
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceManager

public ServiceManager()
Method Detail

init

public static void init(javax.servlet.ServletConfig aConfig)
                 throws java.lang.Exception
Initializes all services specified in services.properties. By specifying a different implementation of the service the behaviour of the portal can be modified.

Parameters:
aConfig - the servlet configuration
Throws:
java.lang.Exception - if loading services.properties or initializing any of its contained services fails

init

public static void init(javax.servlet.ServletConfig config,
                        java.lang.String serviceConfigFile)
                 throws ContainerInitLutecePlutoException
Initializes all services specified in services.properties. By specifying a different implementation of the service the behaviour of the portal can be modified.

Parameters:
config - the servlet configuration
serviceConfigFile - The location of services.properties (relative to classpath)
Throws:
java.lang.Exception - if loading services.properties or initializing any of its contained services fails
ContainerInitLutecePlutoException

postInit

public static void postInit(javax.servlet.ServletConfig aConfig)
                     throws ContainerInitLutecePlutoException
Calls post init for all services

Parameters:
aConfig - the servlet configuration
Throws:
ContainerInitLutecePlutoException

destroy

public static void destroy(javax.servlet.ServletConfig aConfig)
Destroys all services.

Parameters:
aConfig - the servlet configuration

getService

public static org.apache.pluto.portalImpl.services.Service getService(java.lang.Class aClass)
Returns the service implementation for the given service class, or null if no such service is registered.

Parameters:
aClass - the service class
Returns:
the service implementation


Copyright © 2008 Mairie de Paris. All Rights Reserved.