Class PluginAwareVelocityManager

java.lang.Object
com.atlassian.crowd.plugin.PluginAwareVelocityManager
All Implemented Interfaces:
org.apache.struts2.views.velocity.VelocityManagerInterface

public class PluginAwareVelocityManager extends Object implements org.apache.struts2.views.velocity.VelocityManagerInterface
Manages the environment for Velocity result type.
Since:
7.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The default context objects that are available to all templates.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.velocity.context.Context
    buildContext(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
     
    org.apache.velocity.context.Context
    createContext(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
    This method is responsible for creating the standard VelocityContext used by all Struts Velocity views.
    org.apache.velocity.app.VelocityEngine
     
    void
    init(javax.servlet.ServletContext context)
    Initializes the VelocityManager.
    protected org.apache.velocity.app.VelocityEngine
    newVelocityEngine(javax.servlet.ServletContext context)
    Instantiates a new VelocityEngine.
    protected List<org.apache.velocity.VelocityContext>
    prepareChainedContexts(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, Map<String,Object> extraContext)
    constructs contexts for chaining on this request.
    void
    Allows users to specify via the struts.properties file a set of additional VelocityContexts to chain to the the StrutsVelocityContext.
    void
    setContainer(com.opensymphony.xwork2.inject.Container container)
     
    void
     
    void
    setObjectFactory(com.opensymphony.xwork2.ObjectFactory fac)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • PluginAwareVelocityManager

      public PluginAwareVelocityManager()
  • Method Details

    • setObjectFactory

      public void setObjectFactory(com.opensymphony.xwork2.ObjectFactory fac)
    • setContainer

      public void setContainer(com.opensymphony.xwork2.inject.Container container)
    • getVelocityEngine

      public org.apache.velocity.app.VelocityEngine getVelocityEngine()
      Specified by:
      getVelocityEngine in interface org.apache.struts2.views.velocity.VelocityManagerInterface
      Returns:
      a reference to the VelocityEngine used by all Struts Velocity results except directly accessed *.vm pages (unless otherwise configured)
    • createContext

      public org.apache.velocity.context.Context createContext(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
      This method is responsible for creating the standard VelocityContext used by all Struts Velocity views. It adds EscapeTool as 'esc' to the context.
      Specified by:
      createContext in interface org.apache.struts2.views.velocity.VelocityManagerInterface
      Parameters:
      stack - the current ValueStack
      req - the current HttpServletRequest
      res - the current HttpServletResponse
      Returns:
      a new StrutsVelocityContext
    • buildContext

      protected org.apache.velocity.context.Context buildContext(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
    • prepareChainedContexts

      protected List<org.apache.velocity.VelocityContext> prepareChainedContexts(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, Map<String,Object> extraContext)
      constructs contexts for chaining on this request. This method does not perform any initialization of the contexts. All that must be done in the context itself.
      Parameters:
      servletRequest - the servlet request object
      servletResponse - the servlet response object
      extraContext - map with extra context
      Returns:
      a List of contexts to chain or an empty list
    • init

      public void init(javax.servlet.ServletContext context)
      Initializes the VelocityManager. this should be called during the initialization process, say by ServletDispatcher. this may be called multiple times safely although calls beyond the first won't do anything
      Specified by:
      init in interface org.apache.struts2.views.velocity.VelocityManagerInterface
      Parameters:
      context - the current servlet context
    • setCustomConfigFile

      public void setCustomConfigFile(String val)
    • setChainedContexts

      public void setChainedContexts(String contexts)
      Allows users to specify via the struts.properties file a set of additional VelocityContexts to chain to the the StrutsVelocityContext. The intent is to allow these contexts to store helper objects that the ui developer may want access to. Examples of reasonable VelocityContexts would be an IoCVelocityContext, a SpringReferenceVelocityContext, and a ToolboxVelocityContext
      Parameters:
      contexts - comma separated velocity context's
    • newVelocityEngine

      protected org.apache.velocity.app.VelocityEngine newVelocityEngine(javax.servlet.ServletContext context)

      Instantiates a new VelocityEngine.

      The following is the default Velocity configuration

        resource.loader = file, class
        file.resource.loader.path = real path of webapp
        class.resource.loader.description = Velocity Classpath Resource Loader
        class.resource.loader.class = org.apache.struts2.views.velocity.StrutsResourceLoader
       

      this default configuration can be overridden by specifying a struts.velocity.configfile property in the struts.properties file. the specified config file will be searched for in the following order:

      • relative to the servlet context path
      • relative to the WEB-INF directory
      • on the classpath
      Parameters:
      context - the current ServletContext. may not be null
      Returns:
      the new velocity engine