org.apache.jetspeed.velocity
Class JetspeedVelocityViewServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.velocity.tools.view.servlet.VelocityViewServlet
              extended by org.apache.portals.bridges.velocity.BridgesVelocityViewServlet
                  extended by org.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 550655 2007-06-26 01:41:35Z taylor $
See Also:
Serialized Form

Nested Class Summary
private  class JetspeedVelocityViewServlet.VelocityEngineConfig
          velocity engine configuration caching object
 
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  org.apache.velocity.app.VelocityEngine defaultVelocityEngine
          default velocity engine
(package private)  org.apache.velocity.app.event.EventCartridge eventCartridge
          Velocity EventCartridge for handling event
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, DEFAULT_PROPERTIES_PATH, DEFAULT_TOOLBOX_PATH, DEFAULT_TOOLS_PROPERTIES, INIT_PROPS_KEY, SERVLET_CONTEXT_KEY, TOOLBOX_KEY, toolboxManager
 
Constructor Summary
JetspeedVelocityViewServlet()
           
 
Method Summary
protected  void error(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception e)
           
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.
protected  void initVelocity(javax.servlet.ServletConfig config)
          overriding VelocityViewServlet initialization of global Velocity to properly provide our own velocity.properties so to prevent an ERROR logging for not finding the default global VM_global_library.vm (which isn't available).
private  org.apache.velocity.app.VelocityEngine initVelocity(org.apache.jetspeed.locator.TemplateDescriptor macros)
          Initialize new velocity instance using specified macros template.
 
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, findInitParameter, getResponseWriter, getVelocityEngine, getVelocityProperty, initToolbox, loadConfiguration, performMerge, requestCleanup, setContentType, setVelocityEngine
 
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


defaultVelocityEngine

private org.apache.velocity.app.VelocityEngine defaultVelocityEngine
default velocity engine


eventCartridge

org.apache.velocity.app.event.EventCartridge eventCartridge
Velocity EventCartridge for handling event

Constructor Detail

JetspeedVelocityViewServlet

public JetspeedVelocityViewServlet()
Method Detail

init

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

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class org.apache.velocity.tools.view.servlet.VelocityViewServlet
Parameters:
config - servlet configuation
Throws:
javax.servlet.ServletException
See Also:
org.apache.velocity.tools.view.servlet.VelocityViewServlet.init()

initVelocity

protected void initVelocity(javax.servlet.ServletConfig config)
                     throws javax.servlet.ServletException
overriding VelocityViewServlet initialization of global Velocity to properly provide our own velocity.properties so to prevent an ERROR logging for not finding the default global VM_global_library.vm (which isn't available).

Overrides:
initVelocity in class org.apache.velocity.tools.view.servlet.VelocityViewServlet
Throws:
javax.servlet.ServletException

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.

Overrides:
handleRequest in class org.apache.portals.bridges.velocity.BridgesVelocityViewServlet
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.

Overrides:
getTemplate in class org.apache.velocity.tools.view.servlet.VelocityViewServlet
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.

Overrides:
getTemplate in class org.apache.velocity.tools.view.servlet.VelocityViewServlet
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()

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

error

protected void error(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     Exception e)
              throws javax.servlet.ServletException
Overrides:
error in class org.apache.velocity.tools.view.servlet.VelocityViewServlet
Throws:
javax.servlet.ServletException


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