org.apache.cocoon.core.container
Class CoreServiceManager

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.core.container.CoreServiceManager
All Implemented Interfaces:
Configurable, Contextualizable, Disposable, Initializable, LogEnabled, ServiceManager, ThreadSafe
Direct Known Subclasses:
CocoonServiceManager, OSGiCoreServiceManager

public class CoreServiceManager
extends AbstractLogEnabled
implements Contextualizable, ThreadSafe, Disposable, Initializable, ServiceManager, Configurable

Default service manager for Cocoon's components.

Since:
2.2
Version:
$Id: CoreServiceManager.java 328027 2005-10-24 10:38:36Z cziegeler $

Field Summary
protected  ClassLoader classloader
          The classloader to get classes from
protected  ComponentEnvironment componentEnv
           
protected  Map componentHandlers
          Used to map roles to ComponentHandlers.
protected  Map componentMapping
          Static component mapping handlers.
protected  Context context
          The application context for components
protected static Map CONTEXT_PARAMETERS
          Parameter map for the context protocol
protected  boolean disposed
          Is the Manager disposed or not?
static Configuration EMPTY_CONFIGURATION
          An empty configuration object, that can be used when no configuration is known but one is needed.
protected  boolean initialized
          Is the Manager initialized?
protected  String location
          The location where this manager is defined
protected  LoggerManager loggerManager
          LoggerManager.
protected  ServiceManager parentManager
          The parent ServiceManager
protected  RoleManager roleManager
          RoleInfos.
 
Constructor Summary
CoreServiceManager(ServiceManager parent)
          Create the ServiceManager with a parent ServiceManager
CoreServiceManager(ServiceManager parent, ClassLoader classloader)
          Create the ServiceManager with a parent ServiceManager and a ClassLoader
 
Method Summary
 void addComponent(String role, String className, Configuration configuration, ComponentInfo info)
          Add a new component to the manager.
 void addInstance(String role, Object instance)
          Add an existing object to the manager.
 void addRoleAlias(String existingRole, String newRole)
          Add an alias to a role, i.e. define a synonym for the role.
 void configure(Configuration configuration)
           
 void contextualize(Context context)
           
 void dispose()
           
 void enableLogging(Logger logger)
           
 boolean hasService(String role)
           
 void initialize()
           
protected  void initialize(String role, Object component)
          Initialize the component
 Object lookup(String role)
           
 void release(Object component)
           
 void setLoggerManager(LoggerManager manager)
          Configure the LoggerManager.
 void setRoleManager(RoleManager rm)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CONFIGURATION

public static final Configuration EMPTY_CONFIGURATION
An empty configuration object, that can be used when no configuration is known but one is needed.


CONTEXT_PARAMETERS

protected static final Map CONTEXT_PARAMETERS
Parameter map for the context protocol


context

protected Context context
The application context for components


componentMapping

protected final Map componentMapping
Static component mapping handlers.


componentHandlers

protected final Map componentHandlers
Used to map roles to ComponentHandlers.


disposed

protected boolean disposed
Is the Manager disposed or not?


initialized

protected boolean initialized
Is the Manager initialized?


roleManager

protected RoleManager roleManager
RoleInfos.


loggerManager

protected LoggerManager loggerManager
LoggerManager.


componentEnv

protected ComponentEnvironment componentEnv

location

protected String location
The location where this manager is defined


parentManager

protected ServiceManager parentManager
The parent ServiceManager


classloader

protected ClassLoader classloader
The classloader to get classes from

Constructor Detail

CoreServiceManager

public CoreServiceManager(ServiceManager parent)
Create the ServiceManager with a parent ServiceManager


CoreServiceManager

public CoreServiceManager(ServiceManager parent,
                          ClassLoader classloader)
Create the ServiceManager with a parent ServiceManager and a ClassLoader

Method Detail

enableLogging

public void enableLogging(Logger logger)
Specified by:
enableLogging in interface LogEnabled

contextualize

public void contextualize(Context context)
                   throws ContextException
Specified by:
contextualize in interface Contextualizable
Throws:
ContextException

setLoggerManager

public void setLoggerManager(LoggerManager manager)
Configure the LoggerManager.


setRoleManager

public void setRoleManager(RoleManager rm)

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException

initialize

public void initialize()
                throws Exception
Specified by:
initialize in interface Initializable
Throws:
Exception

dispose

public void dispose()
Specified by:
dispose in interface Disposable

hasService

public boolean hasService(String role)
Specified by:
hasService in interface ServiceManager

lookup

public Object lookup(String role)
              throws ServiceException
Specified by:
lookup in interface ServiceManager
Throws:
ServiceException

release

public void release(Object component)
Specified by:
release in interface ServiceManager

addComponent

public void addComponent(String role,
                         String className,
                         Configuration configuration,
                         ComponentInfo info)
                  throws ConfigurationException
Add a new component to the manager.

Parameters:
role - the role name for the new component.
className - the class of this component.
configuration - the configuration for this component.
Throws:
ConfigurationException

addInstance

public void addInstance(String role,
                        Object instance)
                 throws ServiceException
Add an existing object to the manager. The object should be fully configured as no setup lifecycle methods are called. On manager disposal, the Disposable method is considered.

Parameters:
role - the role under which the object will be known
instance - the component instance
Throws:
ServiceException

addRoleAlias

public void addRoleAlias(String existingRole,
                         String newRole)
                  throws ServiceException
Add an alias to a role, i.e. define a synonym for the role.

Parameters:
existingRole - the existing role that will be aliased
newRole - the new role
Throws:
ServiceException - if the existing role could not be found in the current manager and its ancestors

initialize

protected void initialize(String role,
                          Object component)
                   throws ServiceException
Initialize the component

Throws:
ServiceException


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.