类 ServletToolboxManager

java.lang.Object
org.apache.velocity.tools.view.XMLToolboxManager
cn.aradin.spring.velocity.tools.ServletToolboxManager
所有已实现的接口:
org.apache.velocity.tools.view.ToolboxManager

@Deprecated public class ServletToolboxManager extends org.apache.velocity.tools.view.XMLToolboxManager
已过时。
Use XmlFactoryConfiguration

A toolbox manager for the servlet environment.

A toolbox manager is responsible for automatically filling the Velocity context with a set of view tools. This class provides the following features:

  • configurable through an XML-based configuration file
  • assembles a set of view tools (the toolbox) on request
  • handles different tool scopes (request, session, application)
  • supports any class with a public constructor without parameters to be used as a view tool
  • supports adding primitive data values to the context(String,Number,Boolean)

Configuration

The toolbox manager is configured through an XML-based configuration file. The configuration file is passed to the XMLToolboxManager.load(java.io.InputStream input) method. The format is shown in the following example:

 <?xml version="1.0"?>

 <toolbox>
   <tool>
      <key>link</key>
      <scope>request</scope>
      <class>org.apache.velocity.tools.view.tools.LinkTool</class>
   </tool>
   <tool>
      <key>date</key>
      <scope>application</scope>
      <class>org.apache.velocity.tools.generic.DateTool</class>
   </tool>
   <data type="number">
      <key>luckynumber</key>
      <value>1.37</value>
   </data>
   <data type="string">
      <key>greeting</key>
      <value>Hello World!</value>
   </data>
   <xhtml>true</xhtml>
 </toolbox>
 

The recommended location for the configuration file is the WEB-INF directory of the web application.

版本:
$Id$
作者:
Gabriel Sidler, Nathan Bubna, Geir Magnusson Jr., Henning P. Schmiedehausen
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    protected static final org.apache.commons.logging.Log
    已过时。
     
    static final String
    已过时。
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    addData(org.apache.velocity.tools.view.ToolInfo info)
    已过时。
    Overrides XMLToolboxManager to put data into appTools map
    void
    addTool(org.apache.velocity.tools.view.ToolInfo info)
    已过时。
    Overrides XMLToolboxManager to separate tools by scope.
    getInstance(javax.servlet.ServletContext servletContext, String toolboxFile)
    已过时。
    ServletToolboxManager factory method.
    protected Object
    getMutex(javax.servlet.http.HttpSession session)
    已过时。
    Returns a mutex (lock object) unique to the specified session to allow for reliable synchronization on the session.
    protected org.apache.commons.digester.RuleSet
    已过时。
    Retrieves the rule set Digester should use to parse and load the toolbox for this manager.
    getToolbox(Object initData)
    已过时。
    Overrides XMLToolboxManager to handle the separate scopes.
    void
    setCreateSession(boolean b)
    已过时。
    Sets whether or not to create a new session when none exists for the current request and session-scoped tools have been defined for this toolbox.
    void
    已过时。
    Sets an application attribute to tell velocimacros and tools (especially the LinkTool) whether they should output XHTML or HTML.
    protected boolean
    validateToolInfo(org.apache.velocity.tools.view.ToolInfo info)
    已过时。
    Ensures that application-scoped tools do not have request path restrictions set for them, as those will not be enforced.

    从类继承的方法 org.apache.velocity.tools.view.XMLToolboxManager

    load, load

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • SESSION_TOOLS_KEY

      public static final String SESSION_TOOLS_KEY
      已过时。
    • LOG

      protected static final org.apache.commons.logging.Log LOG
      已过时。
  • 方法详细资料

    • getInstance

      public static ServletToolboxManager getInstance(javax.servlet.ServletContext servletContext, String toolboxFile)
      已过时。
      ServletToolboxManager factory method. This method will ensure there is exactly one ServletToolboxManager per xml toolbox configuration file.
      参数:
      servletContext - servletContext
      toolboxFile - toolboxFile
      返回:
      ServletToolboxManager
    • setCreateSession

      public void setCreateSession(boolean b)
      已过时。

      Sets whether or not to create a new session when none exists for the current request and session-scoped tools have been defined for this toolbox.

      If true, then a call to getToolbox(Object) will create a new session if none currently exists for this request and the toolbox has one or more session-scoped tools designed.

      If false, then a call to getToolbox(Object) will never create a new session for the current request. This effectively means that no session-scoped tools will be added to the ToolboxContext for a request that does not have a session object.

      参数:
      b - The default value is true.
    • setXhtml

      public void setXhtml(Boolean value)
      已过时。

      Sets an application attribute to tell velocimacros and tools (especially the LinkTool) whether they should output XHTML or HTML.

      参数:
      value - Boolean
      从以下版本开始:
      VelocityTools 1.1
      另请参阅:
      • ViewContext.XHTML
    • getRuleSet

      protected org.apache.commons.digester.RuleSet getRuleSet()
      已过时。

      Retrieves the rule set Digester should use to parse and load the toolbox for this manager.

      The DTD corresponding to the ServletToolboxRuleSet is:

        <?xml version="1.0"?>
        <!ELEMENT toolbox (create-session?,xhtml?,tool*,data*,#PCDATA)>
        <!ELEMENT create-session (#CDATA)>
        <!ELEMENT xhtml          (#CDATA)>
        <!ELEMENT tool           (key,scope?,class,parameter*,#PCDATA)>
        <!ELEMENT data           (key,value)>
            <!ATTLIST data type (string|number|boolean) "string">
        <!ELEMENT key            (#CDATA)>
        <!ELEMENT scope          (#CDATA)>
        <!ELEMENT class          (#CDATA)>
        <!ELEMENT parameter (EMPTY)>
            <!ATTLIST parameter name CDATA #REQUIRED>
            <!ATTLIST parameter value CDATA #REQUIRED>
        <!ELEMENT value          (#CDATA)>
       
      覆盖:
      getRuleSet 在类中 org.apache.velocity.tools.view.XMLToolboxManager
      从以下版本开始:
      VelocityTools 1.1
    • validateToolInfo

      protected boolean validateToolInfo(org.apache.velocity.tools.view.ToolInfo info)
      已过时。
      Ensures that application-scoped tools do not have request path restrictions set for them, as those will not be enforced.
      覆盖:
      validateToolInfo 在类中 org.apache.velocity.tools.view.XMLToolboxManager
      参数:
      info - a ToolInfo object
      返回:
      true if the ToolInfo is valid
      从以下版本开始:
      VelocityTools 1.3
    • addTool

      public void addTool(org.apache.velocity.tools.view.ToolInfo info)
      已过时。
      Overrides XMLToolboxManager to separate tools by scope. For this to work, we obviously override getToolbox(Object) as well.
      指定者:
      addTool 在接口中 org.apache.velocity.tools.view.ToolboxManager
      覆盖:
      addTool 在类中 org.apache.velocity.tools.view.XMLToolboxManager
    • addData

      public void addData(org.apache.velocity.tools.view.ToolInfo info)
      已过时。
      Overrides XMLToolboxManager to put data into appTools map
      指定者:
      addData 在接口中 org.apache.velocity.tools.view.ToolboxManager
      覆盖:
      addData 在类中 org.apache.velocity.tools.view.XMLToolboxManager
    • getToolbox

      public Map getToolbox(Object initData)
      已过时。
      Overrides XMLToolboxManager to handle the separate scopes. Application scope tools were initialized when the toolbox was loaded. Session scope tools are initialized once per session and stored in a map in the session attributes. Request scope tools are initialized on every request.
      指定者:
      getToolbox 在接口中 org.apache.velocity.tools.view.ToolboxManager
      覆盖:
      getToolbox 在类中 org.apache.velocity.tools.view.XMLToolboxManager
      参数:
      initData - the ViewContext for the current servlet request
    • getMutex

      protected Object getMutex(javax.servlet.http.HttpSession session)
      已过时。
      Returns a mutex (lock object) unique to the specified session to allow for reliable synchronization on the session.
      参数:
      session - session
      返回:
      Object Object