org.apache.cocoon.environment
Class AbstractEnvironment

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.environment.AbstractEnvironment
All Implemented Interfaces:
Environment, org.apache.avalon.framework.logger.Loggable, SourceResolver
Direct Known Subclasses:
AbstractCommandLineEnvironment, EnvironmentWrapper, HttpEnvironment

public abstract class AbstractEnvironment
extends org.apache.avalon.framework.logger.AbstractLoggable
implements Environment

Base class for any environment

Version:
CVS $Id: AbstractEnvironment.java,v 1.12.2.5 2002/08/04 04:11:52 vgritsenko Exp $
Author:
Giacomo Pati, Carsten Ziegeler

Field Summary
protected  java.lang.String action
          The Action requested
protected  java.net.URL context
          The Context path
protected  org.apache.avalon.framework.component.ComponentManager manager
          The current manager
protected  java.util.HashMap objectModel
          The servlet object model
protected  java.lang.StringBuffer prefix
          The current prefix to strip off from the request uri
protected  java.net.URL rootContext
          The root context path
protected  SourceHandler sourceHandler
          The source handler for the current environment
protected  java.lang.String uris
          The current uri in progress
protected  java.lang.String view
          The View requested
 
Constructor Summary
AbstractEnvironment(java.lang.String uri, java.lang.String view, java.io.File file)
          Constructs the abstract environment
AbstractEnvironment(java.lang.String uri, java.lang.String view, java.io.File file, java.lang.String action)
          Constructs the abstract environment
AbstractEnvironment(java.lang.String uri, java.lang.String view, java.lang.String file)
          Constructs the abstract environment
AbstractEnvironment(java.lang.String uri, java.lang.String view, java.lang.String file, java.lang.String action)
          Constructs the abstract environment
AbstractEnvironment(java.lang.String uri, java.lang.String view, java.net.URL context, java.lang.String action)
          Constructs the abstract environment
 
Method Summary
 void changeContext(java.lang.String prefix, java.lang.String newContext)
          Adds an prefix to the overall stripped off prefix from the request uri
 java.lang.String getAction()
          Returns the request action
 java.lang.Object getAttribute(java.lang.String name)
          Returns the object bound with the specified name, or null if no object is bound under the name.
 java.util.Enumeration getAttributeNames()
          Returns an Enumeration of String objects containing the names of all the objects bound to this environment.
 org.apache.avalon.framework.component.ComponentManager getComponentManager()
          The sitemap processor sets up new managers per sitemap.
 java.net.URL getContext()
          Get the current Context
 java.util.Map getObjectModel()
          Returns a Map containing environment specific objects
 java.net.URL getRootContext()
          Get the Root Context
 SourceHandler getSourceHandler()
          Get the SourceHandler for the current request
 java.lang.String getURI()
          Returns the uri in progress.
 java.lang.String getURIPrefix()
          Get the prefix of the URI in progress
 java.lang.String getView()
          Returns the request view
 void globalRedirect(boolean sessionmode, java.lang.String newURL)
           
 boolean isResponseModified(long lastModified)
          Check if the response has been modified since the same "resource" was requested.
abstract  void redirect(boolean sessionmode, java.lang.String newURL)
          Redirect the client to a new URL
 void removeAttribute(java.lang.String name)
          Removes the object bound with the specified name from this environment.
 Source resolve(java.lang.String systemId)
          Resolve an entity.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Binds an object to this environment, using the name specified.
 void setComponentManager(org.apache.avalon.framework.component.ComponentManager manager)
          The sitemap sets up new managers per sitemap.
 void setContext(java.lang.String prefix, java.lang.String uri)
          Set the context.
protected  void setContext(java.net.URL context)
          Set the context.
 void setResponseIsNotModified()
          Mark the response as not modified.
 void setSourceHandler(SourceHandler sourceHandler)
          Set the SourceHandler for the current request
 void setStatus(int statusCode)
          Set a status code
protected  void setURIPrefix(java.lang.String prefix)
          Set the prefix of the URI in progress
 boolean tryResetResponse()
          Reset the response if possible.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.environment.Environment
getContentType, getOutputStream, setContentLength, setContentType
 

Field Detail

uris

protected java.lang.String uris
The current uri in progress

prefix

protected java.lang.StringBuffer prefix
The current prefix to strip off from the request uri

view

protected java.lang.String view
The View requested

action

protected java.lang.String action
The Action requested

context

protected java.net.URL context
The Context path

rootContext

protected java.net.URL rootContext
The root context path

objectModel

protected java.util.HashMap objectModel
The servlet object model

sourceHandler

protected SourceHandler sourceHandler
The source handler for the current environment

manager

protected org.apache.avalon.framework.component.ComponentManager manager
The current manager
Constructor Detail

AbstractEnvironment

public AbstractEnvironment(java.lang.String uri,
                           java.lang.String view,
                           java.lang.String file)
                    throws java.net.MalformedURLException
Constructs the abstract environment

AbstractEnvironment

public AbstractEnvironment(java.lang.String uri,
                           java.lang.String view,
                           java.lang.String file,
                           java.lang.String action)
                    throws java.net.MalformedURLException
Constructs the abstract environment

AbstractEnvironment

public AbstractEnvironment(java.lang.String uri,
                           java.lang.String view,
                           java.io.File file)
                    throws java.net.MalformedURLException
Constructs the abstract environment

AbstractEnvironment

public AbstractEnvironment(java.lang.String uri,
                           java.lang.String view,
                           java.io.File file,
                           java.lang.String action)
                    throws java.net.MalformedURLException
Constructs the abstract environment

AbstractEnvironment

public AbstractEnvironment(java.lang.String uri,
                           java.lang.String view,
                           java.net.URL context,
                           java.lang.String action)
                    throws java.net.MalformedURLException
Constructs the abstract environment
Method Detail

getComponentManager

public org.apache.avalon.framework.component.ComponentManager getComponentManager()
The sitemap processor sets up new managers per sitemap. Get the "current" one for this environment.

setComponentManager

public void setComponentManager(org.apache.avalon.framework.component.ComponentManager manager)
The sitemap sets up new managers per sitemap. Set the "current" one for this environment.
Specified by:
setComponentManager in interface Environment

getSourceHandler

public SourceHandler getSourceHandler()
Get the SourceHandler for the current request
Specified by:
getSourceHandler in interface Environment

setSourceHandler

public void setSourceHandler(SourceHandler sourceHandler)
Set the SourceHandler for the current request
Specified by:
setSourceHandler in interface Environment

getURI

public java.lang.String getURI()
Returns the uri in progress. The prefix is stripped off
Specified by:
getURI in interface Environment

getRootContext

public java.net.URL getRootContext()
Get the Root Context
Specified by:
getRootContext in interface Environment

getContext

public java.net.URL getContext()
Get the current Context
Specified by:
getContext in interface Environment

getURIPrefix

public java.lang.String getURIPrefix()
Get the prefix of the URI in progress
Specified by:
getURIPrefix in interface Environment

setURIPrefix

protected void setURIPrefix(java.lang.String prefix)
Set the prefix of the URI in progress

setContext

protected void setContext(java.net.URL context)
Set the context.

setContext

public void setContext(java.lang.String prefix,
                       java.lang.String uri)
Set the context. This is similar to changeContext() except that it is absolute.
Specified by:
setContext in interface Environment

changeContext

public void changeContext(java.lang.String prefix,
                          java.lang.String newContext)
                   throws java.net.MalformedURLException
Adds an prefix to the overall stripped off prefix from the request uri
Specified by:
changeContext in interface Environment

redirect

public abstract void redirect(boolean sessionmode,
                              java.lang.String newURL)
                       throws java.io.IOException
Redirect the client to a new URL
Specified by:
redirect in interface Environment

globalRedirect

public void globalRedirect(boolean sessionmode,
                           java.lang.String newURL)
                    throws java.io.IOException

getView

public java.lang.String getView()
Returns the request view
Specified by:
getView in interface Environment

getAction

public java.lang.String getAction()
Returns the request action
Specified by:
getAction in interface Environment

setStatus

public void setStatus(int statusCode)
Set a status code
Specified by:
setStatus in interface Environment

getObjectModel

public java.util.Map getObjectModel()
Returns a Map containing environment specific objects
Specified by:
getObjectModel in interface Environment

resolve

public Source resolve(java.lang.String systemId)
               throws ProcessingException,
                      org.xml.sax.SAXException,
                      java.io.IOException
Resolve an entity.
Specified by:
resolve in interface SourceResolver
Following copied from interface: org.apache.cocoon.environment.SourceResolver
Parameters:
systemID - This is either a system identifier (java.net.URL or a local file.

isResponseModified

public 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.
Specified by:
isResponseModified in interface Environment
Returns:
true if the response is modified or if the environment is not able to test it

setResponseIsNotModified

public void setResponseIsNotModified()
Mark the response as not modified.
Specified by:
setResponseIsNotModified in interface Environment

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface: Environment
Returns the object bound with the specified name, or null if no object is bound under the name.
Specified by:
getAttribute in interface Environment
Following copied from interface: org.apache.cocoon.environment.Environment
Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Description copied from interface: Environment
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.

Specified by:
setAttribute in interface Environment
Following copied from interface: org.apache.cocoon.environment.Environment
Parameters:
name - the name to which the object is bound
value - the object to be bound

removeAttribute

public void removeAttribute(java.lang.String name)
Description copied from interface: Environment
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.
Specified by:
removeAttribute in interface Environment
Following copied from interface: org.apache.cocoon.environment.Environment
Parameters:
name - the name of the object to remove

getAttributeNames

public java.util.Enumeration getAttributeNames()
Description copied from interface: Environment
Returns an Enumeration of String objects containing the names of all the objects bound to this environment.
Specified by:
getAttributeNames in interface Environment
Following copied from interface: org.apache.cocoon.environment.Environment
Returns:
an Enumeration of Strings.

tryResetResponse

public boolean tryResetResponse()
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
Returns:
true if the response was successfully reset


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.