org.apache.cocoon.environment
Interface Environment

All Superinterfaces:
SourceResolver
All Known Implementing Classes:
AbstractCommandLineEnvironment, AbstractEnvironment, BackgroundEnvironment, EnvironmentWrapper, FileSavingEnvironment, HttpEnvironment, LinkSamplingEnvironment, MutableEnvironmentFacade, PortletEnvironment

public interface Environment
extends SourceResolver

Base interface for an environment abstraction

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

Field Summary
 
Fields inherited from interface org.apache.excalibur.source.SourceResolver
METHOD, ROLE, URI_ENCODING, URI_PARAMETERS
 
Method Summary
 void changeContext(String uriprefix, String context)
          Change the context from uriprefix to context
 void commitResponse()
          Commit the response
 void finishingProcessing()
          Notify that the processing is finished This can be used to cleanup the environment object
 String getAction()
          Get the action to process
 Object getAttribute(String name)
          Returns the object bound with the specified name, or null if no object is bound under the name.
 Enumeration getAttributeNames()
          Returns an Enumeration of String objects containing the names of all the objects bound to this environment.
 String getContentType()
          Get the content type of the resource
 String getContext()
          Get current context
 Map getObjectModel()
          Get the underlying object model
 OutputStream getOutputStream()
          Deprecated. Use getOutputStream(int) instead.
 OutputStream getOutputStream(int bufferSize)
          Get the output stream where to write the generated resource.
 String getRootContext()
          Get the Root Context
 String getURI()
          Get the URI to process.
 String getURIPrefix()
          Get the prefix of the URI in progress.
 String getView()
          Get the view to process
 boolean isExternal()
          Is this environment external ?
 boolean isInternalRedirect()
          Is this an internal redirect?
 boolean isResponseModified(long lastModified)
          Check if the response has been modified since the same "resource" was requested.
 void redirect(boolean sessionmode, String url)
          Redirect the client to the given URL
 void removeAttribute(String name)
          Removes the object bound with the specified name from this environment.
 void setAttribute(String name, Object value)
          Binds an object to this environment, using the name specified.
 void setContentLength(int length)
          Set the length of the generated content
 void setContentType(String mimeType)
          Set the content type of the generated resource
 void setContext(String prefix, String uri, String context)
          Set the context.
 void setResponseIsNotModified()
          Mark the response as not modified.
 void setStatus(int statusCode)
          Set the response status code
 void startingProcessing()
          Notify that the processing starts.
 boolean tryResetResponse()
          Reset the response if possible.
 
Methods inherited from interface org.apache.cocoon.environment.SourceResolver
resolve
 
Methods inherited from interface org.apache.excalibur.source.SourceResolver
release, resolveURI, resolveURI
 

Method Detail

getURI

String getURI()
Get the URI to process. The prefix is stripped off.


getURIPrefix

String getURIPrefix()
Get the prefix of the URI in progress.


getRootContext

String getRootContext()
Get the Root Context


getContext

String getContext()
Get current context


getView

String getView()
Get the view to process


getAction

String getAction()
Get the action to process


setContext

void setContext(String prefix,
                String uri,
                String context)
Set the context. This is similar to changeContext() except that it is absolute.


changeContext

void changeContext(String uriprefix,
                   String context)
                   throws Exception
Change the context from uriprefix to context

Throws:
Exception

redirect

void redirect(boolean sessionmode,
              String url)
              throws IOException
Redirect the client to the given URL

Throws:
IOException

setContentType

void setContentType(String mimeType)
Set the content type of the generated resource


getContentType

String getContentType()
Get the content type of the resource


setContentLength

void setContentLength(int length)
Set the length of the generated content


setStatus

void setStatus(int statusCode)
Set the response status code


getOutputStream

OutputStream getOutputStream()
                             throws IOException
Deprecated. Use getOutputStream(int) instead.

Get the output stream where to write the generated resource.

Throws:
IOException

getOutputStream

OutputStream getOutputStream(int bufferSize)
                             throws IOException
Get the output stream where to write the generated resource. The returned stream is buffered by the environment. If the buffer size is -1 then the complete output is buffered. If the buffer size is 0, no buffering takes place. This method replaces getOutputStream().

Throws:
IOException

getObjectModel

Map getObjectModel()
Get the underlying object model


isResponseModified

boolean isResponseModified(long lastModified)
Check if the response has been modified since the same "resource" was requested. The caller has to test if it is really the same "resource" which is requested.

Returns:
true if the response is modified or if the environment is not able to test it

setResponseIsNotModified

void setResponseIsNotModified()
Mark the response as not modified.


setAttribute

void setAttribute(String name,
                  Object value)
Binds an object to this environment, using the name specified. This allows the pipeline assembly engine to store for its own use objects that souldn't be exposed to other components (generators, selectors, etc) and therefore cannot be put in the object model.

If an object of the same name is already bound, the object is replaced.

Parameters:
name - the name to which the object is bound
value - the object to be bound

getAttribute

Object getAttribute(String name)
Returns the object bound with the specified name, or null if no object is bound under the name.

Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name

removeAttribute

void removeAttribute(String name)
Removes the object bound with the specified name from this environment. If the environment does not have an object bound with the specified name, this method does nothing.

Parameters:
name - the name of the object to remove

getAttributeNames

Enumeration getAttributeNames()
Returns an Enumeration of String objects containing the names of all the objects bound to this environment.

Returns:
an Enumeration of Strings.

tryResetResponse

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. If a buffered output stream is used, resetting is always successful.

Returns:
true if the response was successfully reset
Throws:
IOException

commitResponse

void commitResponse()
                    throws IOException
Commit the response

Throws:
IOException

startingProcessing

void startingProcessing()
Notify that the processing starts.


finishingProcessing

void finishingProcessing()
Notify that the processing is finished This can be used to cleanup the environment object


isExternal

boolean isExternal()
Is this environment external ? An external environment is one that is created in response to an external request (http, commandline, etc.). Environments created by the "cocoon:" protocol aren't external.

Returns:
true if this environment is external

isInternalRedirect

boolean isInternalRedirect()
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.



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