org.apache.cocoon.environment.wrapper
Class EnvironmentWrapper

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.environment.AbstractEnvironment
          extended by org.apache.cocoon.environment.wrapper.EnvironmentWrapper
All Implemented Interfaces:
LogEnabled, Environment, SourceResolver

public class EnvironmentWrapper
extends AbstractEnvironment

This is a wrapper class for the Environment object. It has the same properties except that the object model contains a RequestWrapper object.

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

Field Summary
protected  String contentType
           
protected  Environment environment
          The wrapped environment
protected  boolean internalRedirect
           
protected  Map objectModel
          The object model
protected  OutputStream outputStream
          The stream to output to
protected  String redirectURL
          The redirect url
protected  Request request
          The request object
 
Fields inherited from class org.apache.cocoon.environment.AbstractEnvironment
action, avalonToCocoonSourceWrapper, context, initializedComponents, manager, prefix, rootContext, secureOutputStream, sourceResolver, uris, view
 
Fields inherited from interface org.apache.excalibur.source.SourceResolver
METHOD, ROLE, URI_ENCODING, URI_PARAMETERS
 
Constructor Summary
EnvironmentWrapper(Environment env, ComponentManager manager, String uri, Logger logger, boolean wrapResponse)
           
EnvironmentWrapper(Environment env, String requestURI, String queryString, Logger logger)
          Constructs an EnvironmentWrapper object from a Request and Response objects
EnvironmentWrapper(Environment env, String requestURI, String queryString, Logger logger, boolean rawMode)
          Constructs an EnvironmentWrapper object from a Request and Response objects
EnvironmentWrapper(Environment env, String requestURI, String queryString, Logger logger, ComponentManager manager, boolean rawMode)
          Constructs an EnvironmentWrapper object from a Request and Response objects
EnvironmentWrapper(Environment env, String requestURI, String queryString, Logger logger, ComponentManager manager, boolean rawMode, String view)
          Constructs an EnvironmentWrapper object from a Request and Response objects
EnvironmentWrapper(Environment env, String requestURI, String queryString, Logger logger, ComponentManager manager, boolean rawMode, String view, boolean wrapResponse)
          Constructs an EnvironmentWrapper object from a Request and Response objects
 
Method Summary
 void commitResponse()
          Commit the response
 Object getAttribute(String name)
          Lookup an attribute in this instance, and if not found search it in the wrapped environment.
 String getContentType()
          Get the ContentType
 Map getObjectModel()
          Get the underlying object model
 OutputStream getOutputStream(int bufferSize)
          Get the output stream
 String getRedirectURL()
          if a redirect should happen this returns the url, otherwise null is returned
 void globalRedirect(boolean sessionmode, String newURL)
          Redirect in the first non-wrapped environment
 boolean isExternal()
          Always return false.
 boolean isInternalRedirect()
          Is this an internal redirect?
 void redirect(boolean sessionmode, String newURL)
          Redirect the client to a new URL is not allowed
 void reset()
           
 void setContentLength(int length)
          Set the length of the generated content
 void setContentType(String contentType)
          Set the ContentType
 void setInternalRedirect(boolean flag)
           
 void setOutputStream(OutputStream stream)
          Set the output stream for this environment.
 void setStatus(int statusCode)
          Set the StatusCode
 void setURI(String prefix, String uris)
          Set a new URI for processing.
 boolean tryResetResponse()
          Reset the response if possible.
 
Methods inherited from class org.apache.cocoon.environment.AbstractEnvironment
changeContext, extractAction, extractView, finishingProcessing, getAction, getAttributeNames, getContext, getOutputStream, getRootContext, getURI, getURIPrefix, getView, hasAttribute, initComponents, isResponseModified, release, removeAttribute, resolve, resolveURI, resolveURI, setAction, setAttribute, setContext, setContext, setResponseIsNotModified, setURIPrefix, setView, startingProcessing
 
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

environment

protected Environment environment
The wrapped environment


objectModel

protected Map objectModel
The object model


redirectURL

protected String redirectURL
The redirect url


request

protected Request request
The request object


outputStream

protected OutputStream outputStream
The stream to output to


contentType

protected String contentType

internalRedirect

protected boolean internalRedirect
Constructor Detail

EnvironmentWrapper

public EnvironmentWrapper(Environment env,
                          String requestURI,
                          String queryString,
                          Logger logger)
                   throws MalformedURLException
Constructs an EnvironmentWrapper object from a Request and Response objects

Throws:
MalformedURLException

EnvironmentWrapper

public EnvironmentWrapper(Environment env,
                          String requestURI,
                          String queryString,
                          Logger logger,
                          boolean rawMode)
                   throws MalformedURLException
Constructs an EnvironmentWrapper object from a Request and Response objects

Throws:
MalformedURLException

EnvironmentWrapper

public EnvironmentWrapper(Environment env,
                          String requestURI,
                          String queryString,
                          Logger logger,
                          ComponentManager manager,
                          boolean rawMode)
                   throws MalformedURLException
Constructs an EnvironmentWrapper object from a Request and Response objects

Throws:
MalformedURLException

EnvironmentWrapper

public EnvironmentWrapper(Environment env,
                          String requestURI,
                          String queryString,
                          Logger logger,
                          ComponentManager manager,
                          boolean rawMode,
                          String view)
                   throws MalformedURLException
Constructs an EnvironmentWrapper object from a Request and Response objects

Throws:
MalformedURLException

EnvironmentWrapper

public EnvironmentWrapper(Environment env,
                          String requestURI,
                          String queryString,
                          Logger logger,
                          ComponentManager manager,
                          boolean rawMode,
                          String view,
                          boolean wrapResponse)
                   throws MalformedURLException
Constructs an EnvironmentWrapper object from a Request and Response objects

Throws:
MalformedURLException

EnvironmentWrapper

public EnvironmentWrapper(Environment env,
                          ComponentManager manager,
                          String uri,
                          Logger logger,
                          boolean wrapResponse)
                   throws MalformedURLException
Throws:
MalformedURLException
Method Detail

redirect

public void redirect(boolean sessionmode,
                     String newURL)
              throws IOException
Redirect the client to a new URL is not allowed

Throws:
IOException

globalRedirect

public void globalRedirect(boolean sessionmode,
                           String newURL)
                    throws IOException
Redirect in the first non-wrapped environment

Overrides:
globalRedirect in class AbstractEnvironment
Throws:
IOException

getOutputStream

public OutputStream getOutputStream(int bufferSize)
                             throws IOException
Get the output stream

Specified by:
getOutputStream in interface Environment
Overrides:
getOutputStream in class AbstractEnvironment
Throws:
IOException

setOutputStream

public void setOutputStream(OutputStream stream)
Set the output stream for this environment. It hides the one of the wrapped environment.


tryResetResponse

public boolean tryResetResponse()
                         throws IOException
Reset the response if possible. This allows error handlers to have a higher chance to produce clean output if the pipeline that raised the error has already output some data.

Specified by:
tryResetResponse in interface Environment
Overrides:
tryResetResponse in class AbstractEnvironment
Returns:
true if the response was successfully reset
Throws:
IOException

commitResponse

public void commitResponse()
                    throws IOException
Commit the response

Specified by:
commitResponse in interface Environment
Overrides:
commitResponse in class AbstractEnvironment
Throws:
IOException

getRedirectURL

public String getRedirectURL()
if a redirect should happen this returns the url, otherwise null is returned


reset

public void reset()

setStatus

public void setStatus(int statusCode)
Set the StatusCode

Specified by:
setStatus in interface Environment
Overrides:
setStatus in class AbstractEnvironment

setContentLength

public void setContentLength(int length)
Description copied from interface: Environment
Set the length of the generated content


setContentType

public void setContentType(String contentType)
Set the ContentType


getContentType

public String getContentType()
Get the ContentType


getObjectModel

public Map getObjectModel()
Get the underlying object model

Specified by:
getObjectModel in interface Environment
Overrides:
getObjectModel in class AbstractEnvironment

setURI

public void setURI(String prefix,
                   String uris)
Set a new URI for processing. If the prefix is null the new URI is inside the current context. If the prefix is not null the context is changed to the root context and the prefix is set.


getAttribute

public Object getAttribute(String name)
Lookup an attribute in this instance, and if not found search it in the wrapped environment.

Specified by:
getAttribute in interface Environment
Overrides:
getAttribute in class AbstractEnvironment
Parameters:
name - a String, the name of the attribute to look for
Returns:
an Object, the value of the attribute or null if no such attribute was found.

isExternal

public boolean isExternal()
Always return false.

Returns:
true if this environment is external

setInternalRedirect

public void setInternalRedirect(boolean flag)

isInternalRedirect

public boolean isInternalRedirect()
Description copied from interface: Environment
Is this an internal redirect? An environment is on internal redirect if it is an internal request (via the cocoon: protocol) and used for a redirect.

Specified by:
isInternalRedirect in interface Environment
Overrides:
isInternalRedirect in class AbstractEnvironment


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