org.apache.cocoon.ant
Class CocoonTask.CocoonFactory

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.ant.CocoonTask.CocoonFactory
All Implemented Interfaces:
Configurable, Contextualizable, LogEnabled
Enclosing class:
CocoonTask

public static class CocoonTask.CocoonFactory
extends AbstractLogEnabled
implements Contextualizable, Configurable

A factory creating Cocoon objects. This class encapsulates creation, disposing of Cocoon objects, and creating of classes for using Cocoon in some task, subtask execution

Author:
huber@apache.org

Constructor Summary
CocoonTask.CocoonFactory()
          Constructor for the CocoonFactory object
 
Method Summary
 void configure(Configuration configuration)
          Configure the Cocoon factory
 void contextualize(Context context)
          contextualize the CocoonFactory Expecting at least following context entries context-root CONTEXT_CLASSPATH CONTEXT_CLASS_LOADER CONTEXT_ENVIRONMENT_CONTEXT CONTEXT_WORK_DIR CONTEXT_CONFIG_URL
 Cocoon createCocoon()
          create a new Cocoon instance
 CocoonProcessorDelegate createCocoonProcessorDelegate(Cocoon cocoon, Configuration configuration)
          Create a CocoonProcessorDelegate for performing some Cocoon relevant operations.
 void disposeCocoon(Cocoon cocoon)
          Dispose a cocoon instance.
protected  String getClassPath(File contextDir)
          This builds the important ClassPath used by this class.
 
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
 

Constructor Detail

CocoonTask.CocoonFactory

public CocoonTask.CocoonFactory()
Constructor for the CocoonFactory object

Method Detail

contextualize

public void contextualize(Context context)
                   throws ContextException
contextualize the CocoonFactory Expecting at least following context entries

Specified by:
contextualize in interface Contextualizable
Parameters:
context - parent context
Throws:
ContextException - thrown if parent context fails to provide mandadory context entries

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Configure the Cocoon factory

Specified by:
configure in interface Configurable
Parameters:
configuration - Cocoon factory configuration
Throws:
ConfigurationException - thrown if configuration fails

createCocoon

public Cocoon createCocoon()
                    throws Exception,
                           ContextException,
                           ConfigurationException
create a new Cocoon instance

Returns:
Cocoon the Cocoon instance
Throws:
ContextException - thrown if configuring of Cocoon instance fails
ConfigurationException - thrown if contextualizing of Cocoon instance fails
Exception - thrown if initializing of Cocoon instance fails

disposeCocoon

public void disposeCocoon(Cocoon cocoon)
Dispose a cocoon instance. Don't forget to invoke this method if you have retrieved a Cocoon instance via createCocoon().

Parameters:
cocoon - the Cocoon instance

createCocoonProcessorDelegate

public CocoonProcessorDelegate createCocoonProcessorDelegate(Cocoon cocoon,
                                                             Configuration configuration)
                                                      throws Exception
Create a CocoonProcessorDelegate for performing some Cocoon relevant operations.

Parameters:
cocoon - Cocoon instance
configuration - of the CocoonProcessorDelegate
Returns:
CocoonProcessorDelegate instance
Throws:
Exception - thrown if contextualizing, configuring, or creating of CocoonProcessorDelegate instance fails.

getClassPath

protected String getClassPath(File contextDir)
This builds the important ClassPath used by this class. It does so in a neutral way. It iterates in alphabetical order through every file in the lib directory and adds it to the classpath. Also, we add the files to the ClassLoader for the Cocoon system. In order to protect ourselves from skitzofrantic classloaders, we need to work with a known one.

Parameters:
contextDir - Description of Parameter
Returns:
a String value


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