org.apache.cocoon.bean
Class CocoonWrapper

java.lang.Object
  extended by org.apache.cocoon.bean.CocoonWrapper
Direct Known Subclasses:
CocoonBean, XSPPrecompileWrapper

public class CocoonWrapper
extends Object

The Cocoon Wrapper simplifies usage of the Cocoon object. Allows to create, configure Cocoon instance and process single requests.

Version:
$Id: CocoonWrapper.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Stefano Mazzocchi, Nicola Ken Barozzi, Vadim Gritsenko, Upayavira

Field Summary
protected  String accept
           
protected  CommandLineContext cliContext
           
protected  Cocoon cocoon
           
protected  File context
           
protected static String DEFAULT_ACCEPT
           
protected static String DEFAULT_USER_AGENT
           
protected  Logger log
           
protected  String logger
           
protected  String logLevel
           
protected  String userAgent
           
 
Constructor Summary
CocoonWrapper()
           
 
Method Summary
 void addLoadedClass(String className)
           
 void addLoadedClasses(List classList)
           
 void dispose()
           
protected  void finalize()
           
protected  String getClassPath(String context)
          This builds the important ClassPath used by this class.
protected  ExcaliburComponentManager getComponentManager()
           
protected  Collection getLinks(String deparameterizedURI, Map parameters)
          Samples an URI for its links.
 String getLoggerName()
           
protected  int getPage(String deparameterizedURI, long lastModified, Map parameters, Map headers, Map links, List gatheredLinks, ContentHandler handler)
          Processes an URI for its content.
protected  int getPage(String deparameterizedURI, long lastModified, Map parameters, Map headers, Map links, List gatheredLinks, OutputStream stream)
          Processes an URI for its content.
protected  String getType(String deparameterizedURI, Map parameters)
          Analyze the type of content for an URI.
 void initialize()
           
protected  void loadClasses(List classList)
           
 void processURI(String uri, ContentHandler handler)
          Process single URI into given content handler, skipping final serializer
 void processURI(String uri, OutputStream outputStream)
          Process single URI into given output stream.
 void setAcceptOptions(String accept)
           
 void setAgentOptions(String userAgent)
           
 void setConfigFile(String configFile)
           
 void setContextDir(String contextDir)
          Set context directory
 void setLogger(String logger)
          Set logger category as default logger for the Cocoon engine
 void setLogKit(String logKit)
          Set LogKit configuration file name
 void setLogLevel(String logLevel)
          Set log level.
 void setUseExistingCocoon(boolean useExistingCocoon)
           
 void setWorkDir(String workDir)
          Set working directory
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_USER_AGENT

protected static final String DEFAULT_USER_AGENT

DEFAULT_ACCEPT

protected static final String DEFAULT_ACCEPT
See Also:
Constant Field Values

logger

protected String logger

logLevel

protected String logLevel

userAgent

protected String userAgent

accept

protected String accept

context

protected File context

cliContext

protected CommandLineContext cliContext

cocoon

protected Cocoon cocoon

log

protected Logger log
Constructor Detail

CocoonWrapper

public CocoonWrapper()
Method Detail

initialize

public void initialize()
                throws Exception
Throws:
Exception

getComponentManager

protected ExcaliburComponentManager getComponentManager()

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

loadClasses

protected void loadClasses(List classList)

setLogKit

public void setLogKit(String logKit)
Set LogKit configuration file name

Parameters:
logKit - LogKit configuration file

setLogLevel

public void setLogLevel(String logLevel)
Set log level. Default is DEBUG.

Parameters:
logLevel - log level

setLogger

public void setLogger(String logger)
Set logger category as default logger for the Cocoon engine

Parameters:
logger - logger category

getLoggerName

public String getLoggerName()

setContextDir

public void setContextDir(String contextDir)
Set context directory

Parameters:
contextDir - context directory

setWorkDir

public void setWorkDir(String workDir)
Set working directory

Parameters:
workDir - working directory

setConfigFile

public void setConfigFile(String configFile)

setAgentOptions

public void setAgentOptions(String userAgent)

setAcceptOptions

public void setAcceptOptions(String accept)

addLoadedClass

public void addLoadedClass(String className)

addLoadedClasses

public void addLoadedClasses(List classList)

setUseExistingCocoon

public void setUseExistingCocoon(boolean useExistingCocoon)

processURI

public void processURI(String uri,
                       OutputStream outputStream)
                throws Exception
Process single URI into given output stream.

Parameters:
uri - to process
outputStream - to write generated contents into
Throws:
Exception

processURI

public void processURI(String uri,
                       ContentHandler handler)
                throws Exception
Process single URI into given content handler, skipping final serializer

Parameters:
uri - to process
handler - to write generated contents into
Throws:
Exception

dispose

public void dispose()

getLinks

protected Collection getLinks(String deparameterizedURI,
                              Map parameters)
                       throws Exception
Samples an URI for its links.

Parameters:
deparameterizedURI - a String value of an URI to start sampling from
parameters - a Map value containing request parameters
Returns:
a Collection of links
Throws:
Exception - if an error occurs

getPage

protected int getPage(String deparameterizedURI,
                      long lastModified,
                      Map parameters,
                      Map headers,
                      Map links,
                      List gatheredLinks,
                      OutputStream stream)
               throws Exception
Processes an URI for its content.

Parameters:
deparameterizedURI - a String value of an URI to start sampling from
parameters - a Map value containing request parameters
links - a Map value
stream - an OutputStream to write the content to
Returns:
a String value for the content
Throws:
Exception - if an error occurs

getPage

protected int getPage(String deparameterizedURI,
                      long lastModified,
                      Map parameters,
                      Map headers,
                      Map links,
                      List gatheredLinks,
                      ContentHandler handler)
               throws Exception
Processes an URI for its content.

Parameters:
deparameterizedURI - a String value of an URI to start sampling from
parameters - a Map value containing request parameters
links - a Map value
handler - an ContentHandler to send the content to
Returns:
a String value for the content
Throws:
Exception - if an error occurs

getType

protected String getType(String deparameterizedURI,
                         Map parameters)
                  throws Exception
Analyze the type of content for an URI.

Parameters:
deparameterizedURI - a String value to analyze
parameters - a Map value for the request
Returns:
a String value denoting the type of content
Throws:
Exception - if an error occurs

getClassPath

protected String getClassPath(String context)
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:
context - The context path
Returns:
a String value


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