org.apache.cocoon.generation
Class VelocityGenerator.ChainedContext

java.lang.Object
  extended by org.apache.velocity.context.AbstractContext
      extended by org.apache.velocity.VelocityContext
          extended by org.apache.cocoon.generation.VelocityGenerator.ChainedContext
All Implemented Interfaces:
Serializable, Cloneable, org.apache.velocity.context.Context, org.apache.velocity.context.InternalEventContext
Enclosing class:
VelocityGenerator

public static class VelocityGenerator.ChainedContext
extends org.apache.velocity.VelocityContext

Velocity context implementation specific to the Servlet environment.

It provides the following special features:

The internalGet(String key) method implements the following search order for objects:

  1. servlet request, servlet response, servlet session, servlet context
  2. toolbox
  3. local hashtable of objects (traditional use)
  4. servlet request attribues, servlet session attribute, servlet context attributes

The purpose of this class is to make it easy for web designer to work with Java servlet based web applications. They do not need to be concerned with the concepts of request, session or application attributes and the live time of objects in these scopes.

Note that the put() method always puts objects into the local hashtable.

Acknowledge: the source code is borrowed from the jakarta-velocity-tools project with slight modifications.

Author:
Albert Kwong, Geir Magnusson Jr., Gabe Sidler, Albert Kwong
See Also:
Serialized Form

Field Summary
static String APPLICATION
          Key to the servlet context object.
static String PARAMETERS
          Key to the servlet context object.
static String REQUEST
          Key to the HTTP request object.
static String RESPONSE
          Key to the HTTP response object.
static String SESSION
          Key to the HTTP session object.
 
Constructor Summary
VelocityGenerator.ChainedContext(org.apache.velocity.context.Context ctx, Request request, Response response, Context application, Parameters parameters)
          Default constructor.
 
Method Summary
 org.apache.velocity.app.event.EventCartridge attachEventCartridge(org.apache.velocity.app.event.EventCartridge arg0)
           
 org.apache.velocity.runtime.resource.Resource getCurrentResource()
           
 String getCurrentTemplateName()
           
 org.apache.velocity.app.event.EventCartridge getEventCartridge()
           
 Object[] getTemplateNameStack()
           
 org.apache.velocity.util.introspection.IntrospectionCacheData icacheGet(Object arg0)
           
 void icachePut(Object arg0, org.apache.velocity.util.introspection.IntrospectionCacheData arg1)
           
 Object internalGet(String key)
          Looks up and returns the object with the specified key.
 void popCurrentTemplateName()
           
 void pushCurrentTemplateName(String arg0)
           
 void setCurrentResource(org.apache.velocity.runtime.resource.Resource arg0)
           
 
Methods inherited from class org.apache.velocity.VelocityContext
clone, internalContainsKey, internalGetKeys, internalPut, internalRemove
 
Methods inherited from class org.apache.velocity.context.AbstractContext
containsKey, get, getChainedContext, getKeys, put, remove
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST

public static final String REQUEST
Key to the HTTP request object.

See Also:
Constant Field Values

RESPONSE

public static final String RESPONSE
Key to the HTTP response object.

See Also:
Constant Field Values

SESSION

public static final String SESSION
Key to the HTTP session object.

See Also:
Constant Field Values

APPLICATION

public static final String APPLICATION
Key to the servlet context object.

See Also:
Constant Field Values

PARAMETERS

public static final String PARAMETERS
Key to the servlet context object.

See Also:
Constant Field Values
Constructor Detail

VelocityGenerator.ChainedContext

public VelocityGenerator.ChainedContext(org.apache.velocity.context.Context ctx,
                                        Request request,
                                        Response response,
                                        Context application,
                                        Parameters parameters)
Default constructor.

Method Detail

internalGet

public Object internalGet(String key)

Looks up and returns the object with the specified key.

See the class documentation for more details.

Overrides:
internalGet in class org.apache.velocity.VelocityContext
Parameters:
key - the key of the object requested
Returns:
the requested object or null if not found

pushCurrentTemplateName

public void pushCurrentTemplateName(String arg0)

popCurrentTemplateName

public void popCurrentTemplateName()

getCurrentTemplateName

public String getCurrentTemplateName()

getTemplateNameStack

public Object[] getTemplateNameStack()

icacheGet

public org.apache.velocity.util.introspection.IntrospectionCacheData icacheGet(Object arg0)

icachePut

public void icachePut(Object arg0,
                      org.apache.velocity.util.introspection.IntrospectionCacheData arg1)

setCurrentResource

public void setCurrentResource(org.apache.velocity.runtime.resource.Resource arg0)

getCurrentResource

public org.apache.velocity.runtime.resource.Resource getCurrentResource()

attachEventCartridge

public org.apache.velocity.app.event.EventCartridge attachEventCartridge(org.apache.velocity.app.event.EventCartridge arg0)
Specified by:
attachEventCartridge in interface org.apache.velocity.context.InternalEventContext

getEventCartridge

public org.apache.velocity.app.event.EventCartridge getEventCartridge()
Specified by:
getEventCartridge in interface org.apache.velocity.context.InternalEventContext


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