org.apache.cocoon.components
Class CocoonComponentManager

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.avalon.excalibur.component.AbstractDualLogEnabled
          extended by org.apache.avalon.excalibur.component.ExcaliburComponentManager
              extended by org.apache.cocoon.components.CocoonComponentManager
All Implemented Interfaces:
RoleManageable, LoggerManageable, LogKitManageable, Disposable, Initializable, Component, ComponentManager, Configurable, Contextualizable, LogEnabled, Loggable, Instrumentable, InstrumentManageable, SourceResolver

public final class CocoonComponentManager
extends ExcaliburComponentManager
implements SourceResolver, Component

Cocoon Component Manager. This manager extends the ExcaliburComponentManager by a special lifecycle handling for a RequestLifecycleComponent and by handling the lookup of the SourceResolver. WARNING: This is a "private" Cocoon core class - do NOT use this class directly - and do not assume that a ComponentManager you get via the compose() method is an instance of CocoonComponentManager.

Version:
CVS $Id: CocoonComponentManager.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Björn Lütkemeier, Carsten Ziegeler

Nested Class Summary
static class CocoonComponentManager.AbstractCocoonRunnable
          A runnable wrapper that inherits the environment stack of the thread it is created in.
 
Field Summary
protected static ThreadLocal environmentStack
          The environment information
 
Fields inherited from class org.apache.avalon.excalibur.component.ExcaliburComponentManager
INSTRUMENTABLE_NAME
 
Fields inherited from interface org.apache.excalibur.source.SourceResolver
METHOD, ROLE, URI_ENCODING, URI_PARAMETERS
 
Fields inherited from interface org.apache.excalibur.instrument.Instrumentable
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY
 
Constructor Summary
CocoonComponentManager()
          Create the ComponentManager
CocoonComponentManager(ClassLoader loader)
          Create the ComponentManager with a Classloader
CocoonComponentManager(ComponentManager manager)
          Create the ComponentManager with a parent ComponentManager
CocoonComponentManager(ComponentManager manager, ClassLoader loader)
          Create the ComponentManager with a Classloader and parent ComponentManager
 
Method Summary
 void addComponent(String role, Class clazz, Configuration conf)
           
static void addComponentForAutomaticRelease(ComponentManager manager, Component component)
          Add an automatically released component
static void addComponentForAutomaticRelease(ComponentSelector selector, Component component, ComponentManager manager)
          Add an automatically released component
static void checkEnvironment(int depth, Logger logger)
          INTERNAL METHOD.
static XMLConsumer createEnvironmentAwareConsumer(XMLConsumer consumer)
          Create an environment aware xml consumer for the cocoon protocol
 void dispose()
          Dispose
static void endProcessing(Environment env, Object key)
          This hook has to be called before a request is processed.
static void enterEnvironment(Environment env, ComponentManager manager, Processor processor)
          This hook must be called by the sitemap each time a sitemap is entered This method should never raise an exception, except when the parameters are not set!
static Processor getActiveProcessor(Environment env)
          Return the processor that has actually processed the request
static Environment getCurrentEnvironment()
          Return the current environment (for the cocoon: protocol)
static Processor getCurrentProcessor()
          Return the current processor (for the cocoon: protocol)
static ComponentManager getSitemapComponentManager()
          Get the current sitemap component manager.
 void initialize()
           
static void leaveEnvironment()
          This hook must be called by the sitemap each time a sitemap is left.
static void leaveEnvironment(boolean success)
          This hook must be called by the sitemap each time a sitemap is left.
 Component lookup(String role)
          Return an instance of a component based on a Role.
static int markEnvironment()
          INTERNAL METHOD.
 void release(Component component)
          Release a Component.
 void release(Source source)
          Releases a resolved resource
protected  void releaseRLComponent(Component component)
          Release a RequestLifecycleComponent
static void removeFromAutomaticRelease(Component component)
          Remove from automatically released components
 Source resolveURI(String location)
          Get a Source object.
 Source resolveURI(String location, String baseURI, Map parameters)
          Get a Source object.
 void setInstrumentManager(InstrumentManager iManager)
           
protected  void setParentManager(ComponentManager manager)
           
static Object startProcessing(Environment env)
          This hook has to be called before a request is processed.
 
Methods inherited from class org.apache.avalon.excalibur.component.ExcaliburComponentManager
addComponentInstance, configure, contextualize, getChildInstrumentables, getComponentHandler, getInstrumentableName, getInstruments, hasComponent, setInstrumentableName, setLoggerManager, setLogKitManager, setRoleManager
 
Methods inherited from class org.apache.avalon.excalibur.component.AbstractDualLogEnabled
getLogkitLogger, setLogger
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

environmentStack

protected static final ThreadLocal environmentStack
The environment information

Constructor Detail

CocoonComponentManager

public CocoonComponentManager()
Create the ComponentManager


CocoonComponentManager

public CocoonComponentManager(ClassLoader loader)
Create the ComponentManager with a Classloader


CocoonComponentManager

public CocoonComponentManager(ComponentManager manager,
                              ClassLoader loader)
Create the ComponentManager with a Classloader and parent ComponentManager


CocoonComponentManager

public CocoonComponentManager(ComponentManager manager)
Create the ComponentManager with a parent ComponentManager

Method Detail

setParentManager

protected void setParentManager(ComponentManager manager)

setInstrumentManager

public void setInstrumentManager(InstrumentManager iManager)
Specified by:
setInstrumentManager in interface InstrumentManageable
Overrides:
setInstrumentManager in class ExcaliburComponentManager
See Also:
ExcaliburComponentManager.setInstrumentManager(org.apache.excalibur.instrument.InstrumentManager)

enterEnvironment

public static void enterEnvironment(Environment env,
                                    ComponentManager manager,
                                    Processor processor)
This hook must be called by the sitemap each time a sitemap is entered This method should never raise an exception, except when the parameters are not set!


leaveEnvironment

public static void leaveEnvironment()
This hook must be called by the sitemap each time a sitemap is left. It's the counterpart to enterEnvironment(Environment, ComponentManager, Processor).


leaveEnvironment

public static void leaveEnvironment(boolean success)
This hook must be called by the sitemap each time a sitemap is left. It's the counterpart to enterEnvironment(Environment, ComponentManager, Processor).

Parameters:
success - indicates if the request was successfully handled by the environment that's being left

markEnvironment

public static int markEnvironment()
INTERNAL METHOD. Do not use, can be removed without warning or deprecation cycle.


checkEnvironment

public static void checkEnvironment(int depth,
                                    Logger logger)
                             throws Exception
INTERNAL METHOD. Do not use, can be removed without warning or deprecation cycle.

Throws:
Exception

createEnvironmentAwareConsumer

public static XMLConsumer createEnvironmentAwareConsumer(XMLConsumer consumer)
Create an environment aware xml consumer for the cocoon protocol


startProcessing

public static Object startProcessing(Environment env)
This hook has to be called before a request is processed. The hook is called by the Cocoon component and by the cocoon protocol implementation. This method should never raise an exception, except when the environment is not set.

Returns:
A unique key within this thread.

endProcessing

public static void endProcessing(Environment env,
                                 Object key)
This hook has to be called before a request is processed. The hook is called by the Cocoon component and by the cocoon protocol implementation.

Parameters:
key - A unique key within this thread return by startProcessing(Environment).

getCurrentEnvironment

public static Environment getCurrentEnvironment()
Return the current environment (for the cocoon: protocol)


getCurrentProcessor

public static Processor getCurrentProcessor()
Return the current processor (for the cocoon: protocol)


getActiveProcessor

public static Processor getActiveProcessor(Environment env)
Return the processor that has actually processed the request


getSitemapComponentManager

public static ComponentManager getSitemapComponentManager()
Get the current sitemap component manager. This method return the current sitemap component manager. This is the manager that holds all the components of the currently processed (sub)sitemap.


lookup

public Component lookup(String role)
                 throws ComponentException
Return an instance of a component based on a Role. The Role is usually the Interface's Fully Qualified Name(FQN)--unless there are multiple Components for the same Role. In that case, the Role's FQN is appended with "Selector", and we return a ComponentSelector.

Specified by:
lookup in interface ComponentManager
Overrides:
lookup in class ExcaliburComponentManager
Throws:
ComponentException

release

public void release(Component component)
Release a Component. This implementation makes sure it has a handle on the propper ComponentHandler, and let's the ComponentHandler take care of the actual work.

Specified by:
release in interface ComponentManager
Overrides:
release in class ExcaliburComponentManager

releaseRLComponent

protected void releaseRLComponent(Component component)
Release a RequestLifecycleComponent


addComponentForAutomaticRelease

public static void addComponentForAutomaticRelease(ComponentSelector selector,
                                                   Component component,
                                                   ComponentManager manager)
                                            throws ProcessingException
Add an automatically released component

Throws:
ProcessingException

addComponentForAutomaticRelease

public static void addComponentForAutomaticRelease(ComponentManager manager,
                                                   Component component)
                                            throws ProcessingException
Add an automatically released component

Throws:
ProcessingException

removeFromAutomaticRelease

public static void removeFromAutomaticRelease(Component component)
                                       throws ProcessingException
Remove from automatically released components

Throws:
ProcessingException

dispose

public void dispose()
Dispose

Specified by:
dispose in interface Disposable
Overrides:
dispose in class ExcaliburComponentManager

resolveURI

public Source resolveURI(String location)
                  throws MalformedURLException,
                         IOException,
                         SourceException
Get a Source object.

Specified by:
resolveURI in interface SourceResolver
Throws:
MalformedURLException
IOException
SourceException

resolveURI

public Source resolveURI(String location,
                         String baseURI,
                         Map parameters)
                  throws MalformedURLException,
                         IOException,
                         SourceException
Get a Source object.

Specified by:
resolveURI in interface SourceResolver
Throws:
MalformedURLException
IOException
SourceException

release

public void release(Source source)
Releases a resolved resource

Specified by:
release in interface SourceResolver

addComponent

public void addComponent(String role,
                         Class clazz,
                         Configuration conf)
                  throws ComponentException
Overrides:
addComponent in class ExcaliburComponentManager
Throws:
ComponentException

initialize

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


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.