org.apache.jetspeed.velocity
Class JetspeedVelocityViewServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.apache.velocity.tools.view.servlet.VelocityViewServlet
              extended byorg.apache.portals.bridges.velocity.BridgesVelocityViewServlet
                  extended byorg.apache.jetspeed.velocity.JetspeedVelocityViewServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class JetspeedVelocityViewServlet
extends org.apache.portals.bridges.velocity.BridgesVelocityViewServlet

Version:
$Id: JetspeedVelocityViewServlet.java 233226 2005-08-17 18:05:20Z weaver $
See Also:
Serialized Form

Nested Class Summary
private  class JetspeedVelocityViewServlet.VelocityEngineConfig
          velocity engine configuration caching object
private static class JetspeedVelocityViewServlet.VelocityEngineLogger
          velocity engine logging adapter
 
Field Summary
private static String CACHE_SIZE_PARAMETER
          default cache validation interval
private static String CACHE_VALIDATION_INTERVAL_PARAMETER
          default cache validation interval
private  long cacheValidationInterval
          cache validation interval
private  org.apache.jetspeed.locator.TemplateLocator decorationLocator
          decoration locators
private static long DEFAULT_CACHE_SIZE
          default cache size
private static long DEFAULT_CACHE_VALIDATION_INTERVAL
          default cache validation interval
private static ThreadLocal handlingRequestContext
          TLS for Context propagation
private static org.apache.commons.logging.Log log
          logging
private  Map velocityEngineCache
          VelocityEngine cache by macros locators
private  Map velocityEngineConfigCache
          VelocityEngine configuration cache by decoration
 
Fields inherited from class org.apache.portals.bridges.velocity.BridgesVelocityViewServlet
PORTLET_CONFIG, PORTLET_REQUEST, PORTLET_RESPONSE, VELOCITY_CONTEXT_ATTR, VELOCITY_WRITER_ATTR
 
Fields inherited from class org.apache.velocity.tools.view.servlet.VelocityViewServlet
CONTENT_TYPE, DEFAULT_CONTENT_TYPE, DEFAULT_OUTPUT_ENCODING, INIT_PROPS_KEY, SERVLET_CONTEXT_KEY, TOOLBOX_KEY, toolboxManager
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Constructor Summary
JetspeedVelocityViewServlet()
           
 
Method Summary
private  long getLongInitParameter(javax.servlet.ServletConfig config, String name, long defaultValue)
          Utility to get long init parameters.
 org.apache.velocity.Template getTemplate(String name)
          Retrieves the requested template.
 org.apache.velocity.Template getTemplate(String name, String encoding)
          Retrieves the requested template with the specified character encoding.
private  org.apache.velocity.app.VelocityEngine getVelocityEngine(org.apache.velocity.context.Context ctx)
          Get VelocityEngine for template access.
protected  org.apache.velocity.Template handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.velocity.context.Context ctx)
          Handle the template processing request.
 void init(javax.servlet.ServletConfig config)
          Initialize servlet, BridgesVelocityViewServlet, and VelocityViewServlet.
private  org.apache.velocity.app.VelocityEngine initVelocity(org.apache.jetspeed.locator.TemplateDescriptor macros)
          Initialize new velocity instance using specified macros template.
protected  org.apache.commons.collections.ExtendedProperties loadConfiguration(javax.servlet.ServletConfig config)
          Loads Velocity configuration information and returns that information as an ExtendedProperties, which will be used to initialize the Velocity runtime.
 
Methods inherited from class org.apache.portals.bridges.velocity.BridgesVelocityViewServlet
mergeTemplate
 
Methods inherited from class org.apache.velocity.tools.view.servlet.VelocityViewServlet
createContext, doGet, doPost, doRequest, error, getResponseWriter, initToolbox, initVelocity, requestCleanup, setContentType
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log
logging


DEFAULT_CACHE_SIZE

private static final long DEFAULT_CACHE_SIZE
default cache size

See Also:
Constant Field Values

CACHE_SIZE_PARAMETER

private static final String CACHE_SIZE_PARAMETER
default cache validation interval

See Also:
Constant Field Values

DEFAULT_CACHE_VALIDATION_INTERVAL

private static final long DEFAULT_CACHE_VALIDATION_INTERVAL
default cache validation interval

See Also:
Constant Field Values

CACHE_VALIDATION_INTERVAL_PARAMETER

private static final String CACHE_VALIDATION_INTERVAL_PARAMETER
default cache validation interval

See Also:
Constant Field Values

handlingRequestContext

private static ThreadLocal handlingRequestContext
TLS for Context propagation


decorationLocator

private org.apache.jetspeed.locator.TemplateLocator decorationLocator
decoration locators


velocityEngineConfigCache

private Map velocityEngineConfigCache
VelocityEngine configuration cache by decoration


velocityEngineCache

private Map velocityEngineCache
VelocityEngine cache by macros locators


cacheValidationInterval

private long cacheValidationInterval
cache validation interval

Constructor Detail

JetspeedVelocityViewServlet

public JetspeedVelocityViewServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialize servlet, BridgesVelocityViewServlet, and VelocityViewServlet.

Parameters:
config - servlet configuation
Throws:
javax.servlet.ServletException
See Also:
org.apache.velocity.tools.view.servlet.VelocityViewServlet.init()

handleRequest

protected org.apache.velocity.Template handleRequest(javax.servlet.http.HttpServletRequest request,
                                                     javax.servlet.http.HttpServletResponse response,
                                                     org.apache.velocity.context.Context ctx)
                                              throws Exception
Handle the template processing request.

Parameters:
request - client request
response - client response
ctx - VelocityContext to fill
Returns:
Velocity Template object or null
Throws:
Exception
See Also:
org.apache.velocity.tools.view.servlet.VelocityViewServlet.handleRequest()

getTemplate

public org.apache.velocity.Template getTemplate(String name)
                                         throws org.apache.velocity.exception.ResourceNotFoundException,
                                                org.apache.velocity.exception.ParseErrorException,
                                                Exception
Retrieves the requested template.

Parameters:
name - The file name of the template to retrieve relative to the template root.
Returns:
The requested template.
Throws:
org.apache.velocity.exception.ResourceNotFoundException - if template not found from any available source.
org.apache.velocity.exception.ParseErrorException - if template cannot be parsed due to syntax (or other) error.
Exception - if an error occurs in template initialization
See Also:
org.apache.velocity.tools.view.servlet.VelocityViewServlet.getTemplate()

getTemplate

public org.apache.velocity.Template getTemplate(String name,
                                                String encoding)
                                         throws org.apache.velocity.exception.ResourceNotFoundException,
                                                org.apache.velocity.exception.ParseErrorException,
                                                Exception
Retrieves the requested template with the specified character encoding.

Parameters:
name - The file name of the template to retrieve relative to the template root.
encoding - the character encoding of the template
Returns:
The requested template.
Throws:
org.apache.velocity.exception.ResourceNotFoundException - if template not found from any available source.
org.apache.velocity.exception.ParseErrorException - if template cannot be parsed due to syntax (or other) error.
Exception - if an error occurs in template initialization
See Also:
org.apache.velocity.tools.view.servlet.VelocityViewServlet.getTemplate()

loadConfiguration

protected org.apache.commons.collections.ExtendedProperties loadConfiguration(javax.servlet.ServletConfig config)
                                                                       throws IOException
Loads Velocity configuration information and returns that information as an ExtendedProperties, which will be used to initialize the Velocity runtime.

Parameters:
config - ServletConfig passed to the servlets init() function.
Returns:
ExtendedProperties loaded with Velocity runtime configuration values.
Throws:
IOException - I/O problem accessing the specified file, if specified.
See Also:
org.apache.velocity.tools.view.servlet.VelocityViewServlet.loadConfiguration()

getVelocityEngine

private org.apache.velocity.app.VelocityEngine getVelocityEngine(org.apache.velocity.context.Context ctx)
Get VelocityEngine for template access.

Parameters:
ctx - the velocity context.
Returns:
The VelocityEngine or null.

initVelocity

private org.apache.velocity.app.VelocityEngine initVelocity(org.apache.jetspeed.locator.TemplateDescriptor macros)
Initialize new velocity instance using specified macros template.

Parameters:
macros - template descriptor.
Returns:
new VelocityEngine instance.
See Also:
org.apache.velocity.tools.view.servlet.VelocityViewServlet.initVelocity()

getLongInitParameter

private long getLongInitParameter(javax.servlet.ServletConfig config,
                                  String name,
                                  long defaultValue)
Utility to get long init parameters.

Parameters:
config - servlet config
name - of init parameter
defaultValue - value
Returns:
parameter value


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