org.apache.pluto.portalImpl.services
Class ServiceManager

java.lang.Object
  extended byorg.apache.pluto.portalImpl.services.ServiceManager

public class ServiceManager
extends java.lang.Object

Manages the life-time of services registered during servlet startup. There are two types of services: Services required by the container, and Services used for the portal driver configuration and execution. All services required by the container have to derive from ContainerService and implement the init() and destroy() methods as appropriate. All services must derive from the Service interface if they are to be used with the portal driver.

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.Logger = 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 LoggerImpl .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 emptyemptySessionPath .

See Also:
ContainerService

Constructor Summary
ServiceManager()
           
 
Method Summary
static void destroy(javax.servlet.ServletConfig aConfig)
          Destroys all services.
static 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 hotInit(javax.servlet.ServletConfig aConfig, java.lang.String theService)
           
static void hotInit(javax.servlet.ServletConfig aConfig, java.lang.String aServiceConfigFile, java.lang.String aServiceConfigDir, java.lang.String theService)
           
static void init(javax.servlet.ServletConfig aConfig)
          Initializes all services specified in services.properties.
static void init(javax.servlet.ServletConfig aConfig, java.lang.String aServiceConfigFile, java.lang.String aServiceConfigDir)
          Initializes all services specified in services.properties.
static void postHotInit(javax.servlet.ServletConfig aConfig, java.lang.String theService)
           
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 aConfig,
                        java.lang.String aServiceConfigFile,
                        java.lang.String aServiceConfigDir)
                 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
aServiceConfigFile - The location of services.properties (relative to classpath)
aServiceConfigDir - The direcory with the services' properties files (relative to classpath)
Throws:
java.lang.Exception - if loading services.properties or initializing any of its contained services fails

postInit

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

Parameters:
aConfig - the servlet configuration

destroy

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

Parameters:
aConfig - the servlet configuration

getService

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

hotInit

public static void hotInit(javax.servlet.ServletConfig aConfig,
                           java.lang.String theService)
                    throws java.lang.Exception
Throws:
java.lang.Exception

hotInit

public static void hotInit(javax.servlet.ServletConfig aConfig,
                           java.lang.String aServiceConfigFile,
                           java.lang.String aServiceConfigDir,
                           java.lang.String theService)
                    throws java.lang.Exception
Throws:
java.lang.Exception

postHotInit

public static void postHotInit(javax.servlet.ServletConfig aConfig,
                               java.lang.String theService)


Copyright © 2003-2006 . All Rights Reserved.