com.atlassian.jira.util.velocity
Class DefaultVelocityRequestContextFactory

java.lang.Object
  extended by com.atlassian.jira.util.velocity.DefaultVelocityRequestContextFactory
All Implemented Interfaces:
VelocityRequestContextFactory

public class DefaultVelocityRequestContextFactory
extends Object
implements VelocityRequestContextFactory

Return an instance of VelocityRequestContext, depending on whether we are called from a web or non-web context.

The original intention of this class is to get around bugs such as JRA-11038, where velocity fragments are called from both web and non-web contexts. Originally we tried to proxy HttpServletRequest, but it makes more sense to have a specific interface VelocityRequestContext.


Constructor Summary
DefaultVelocityRequestContextFactory()
          Deprecated. Please use DefaultVelocityRequestContextFactory(com.atlassian.jira.config.properties.ApplicationProperties) instead
DefaultVelocityRequestContextFactory(ApplicationProperties applicationProperties)
           
 
Method Summary
static void cacheVelocityRequestContext(javax.servlet.http.HttpServletRequest request)
          Called from a servlet filter.
static void cacheVelocityRequestContext(String baseUrl, javax.servlet.http.HttpServletRequest request)
          Should be called from a servlet filter before the request gets a chance to run
 void cacheVelocityRequestContext(VelocityRequestContext velocityRequestContext)
          Update the threadlocal storage with the given velocityRequestContext.
 void clearVelocityRequestContext()
          Resets the thread local storage as if no request has occurred, effectively nulling out the current thread local velocity request context.
 Map<String,Object> getDefaultVelocityParams(Map<String,Object> startingParams, JiraAuthenticationContext authenticationContext)
          Constructs a map with a number of common parameters used by velocity templates.
 VelocityRequestContext getJiraVelocityRequestContext()
          Get the request context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultVelocityRequestContextFactory

public DefaultVelocityRequestContextFactory(ApplicationProperties applicationProperties)

DefaultVelocityRequestContextFactory

public DefaultVelocityRequestContextFactory()
Deprecated. Please use DefaultVelocityRequestContextFactory(com.atlassian.jira.config.properties.ApplicationProperties) instead

Method Detail

getJiraVelocityRequestContext

public VelocityRequestContext getJiraVelocityRequestContext()
Description copied from interface: VelocityRequestContextFactory
Get the request context.

Specified by:
getJiraVelocityRequestContext in interface VelocityRequestContextFactory
Returns:
The request context

getDefaultVelocityParams

public Map<String,Object> getDefaultVelocityParams(Map<String,Object> startingParams,
                                                   JiraAuthenticationContext authenticationContext)
Description copied from interface: VelocityRequestContextFactory
Constructs a map with a number of common parameters used by velocity templates.

Specified by:
getDefaultVelocityParams in interface VelocityRequestContextFactory
Parameters:
startingParams - Map of parameters that may be used to override any of the parameters set here.
authenticationContext - JiraAuthenticationContext
Returns:
a Map with common velocity parameters

cacheVelocityRequestContext

public static void cacheVelocityRequestContext(javax.servlet.http.HttpServletRequest request)
Called from a servlet filter. Passes the HttpServletRequest.getContextPath() along as the baseUrl.

Parameters:
request - The HttpServletRequest used to construct the RequestContextParameterHolder

cacheVelocityRequestContext

public static void cacheVelocityRequestContext(String baseUrl,
                                               javax.servlet.http.HttpServletRequest request)
Should be called from a servlet filter before the request gets a chance to run

Parameters:
baseUrl - Should pass in HttpServletRequest.getContextPath()
request - The HttpServletRequest used to construct the RequestContextParameterHolder

cacheVelocityRequestContext

public void cacheVelocityRequestContext(VelocityRequestContext velocityRequestContext)
Description copied from interface: VelocityRequestContextFactory
Update the threadlocal storage with the given velocityRequestContext.

Specified by:
cacheVelocityRequestContext in interface VelocityRequestContextFactory
Parameters:
velocityRequestContext - The velocity request context to store

clearVelocityRequestContext

public void clearVelocityRequestContext()
Description copied from interface: VelocityRequestContextFactory
Resets the thread local storage as if no request has occurred, effectively nulling out the current thread local velocity request context.

Specified by:
clearVelocityRequestContext in interface VelocityRequestContextFactory


Copyright © 2002-2011 Atlassian. All Rights Reserved.