类 ToolManager
java.lang.Object
org.apache.velocity.tools.ToolManager
Manages tools for non-web applications. This simplifies the process
of getting a tool-populated Velocity context for merging with templates.
It allows for both direct configuration by passing in a
FactoryConfiguration
as well as configuration via a tools.xml or tools.properties file in
either the classpath or the local file system.- 版本:
- $Id: ToolManager.java 511959 2007-02-26 19:24:39Z nbubna $
- 作者:
- Nathan Bubna
-
字段概要
字段修饰符和类型字段说明protected ToolboxFactoryprotected org.slf4j.Loggerprotected org.apache.velocity.app.VelocityEngine -
构造器概要
构造器构造器说明Constructs an instance already configured to use the default tools and any configuration specified via a "org.apache.velocity.tools" system property.ToolManager(boolean includeDefaults) Constructs an instance that may or not include default tools, and already configured with any configuration specified via a "org.apache.velocity.tools" system property.ToolManager(boolean autoConfig, boolean includeDefaults) Constructs an instance that may or not include default tools, and which may or not be already configured with any configuration specified via a "org.apache.velocity.tools" system property. -
方法概要
修饰符和类型方法说明protected voidaddToolboxes(ToolContext context) Add toolboxes to contexvoidautoConfigure(boolean includeDefaults) Autoconfiguration using the configuration file potentially found in theorg.apache.velocity.toolssystem property.voidConfigure the tool manager with the provided configuration filevoidconfigure(FactoryConfiguration config) Configure the tool manager with this toolbox factory configcreate new context with configured toolboxes toolscreateContext(Map<String, Object> toolProps) create new context with configured toolboxes tools, using the provided tools propertiesprotected ToolboxcreateToolbox(String scope) Create a toolbox for the given scopeprotected FactoryConfigurationfindConfig(String path) Find a configuration fileGet the toolbox for application scoped toolsorg.slf4j.LoggergetLog()Get loggerGet the toolbox for request scoped toolsReturns the underlyingToolboxFactorybeing used.booleanGet whether template user can overwrite tools keysorg.apache.velocity.app.VelocityEngineGet the underlying VelocityEngine being used.booleanCheck whether this tool manager has application scoped toolsbooleanCheck whether this tool manager has request scoped toolsprotected booleanCheck for the presence of tools in a given scopeprotected voidinitLog()init loggerprotected voidprepareContext(ToolContext context) Prepare contextvoidsetToolboxFactory(ToolboxFactory factory) Sets the underlying ToolboxFactory being used.voidsetUserCanOverwriteTools(boolean overwrite) Set whether template user can overwrite tools keysvoidsetVelocityEngine(org.apache.velocity.app.VelocityEngine engine) Sets the underlying VelocityEngine being used.
-
字段详细资料
-
velocity
protected org.apache.velocity.app.VelocityEngine velocity -
factory
-
log
protected org.slf4j.Logger log
-
-
构造器详细资料
-
ToolManager
public ToolManager()Constructs an instance already configured to use the default tools and any configuration specified via a "org.apache.velocity.tools" system property. -
ToolManager
public ToolManager(boolean includeDefaults) Constructs an instance that may or not include default tools, and already configured with any configuration specified via a "org.apache.velocity.tools" system property.- 参数:
includeDefaults- whether to include default tools
-
ToolManager
public ToolManager(boolean autoConfig, boolean includeDefaults) Constructs an instance that may or not include default tools, and which may or not be already configured with any configuration specified via a "org.apache.velocity.tools" system property.- 参数:
autoConfig- whether to use configuration file specified in theorg.apache.velocity.toolssystem propertyincludeDefaults- whether to include default tools
-
-
方法详细资料
-
autoConfigure
public void autoConfigure(boolean includeDefaults) Autoconfiguration using the configuration file potentially found in theorg.apache.velocity.toolssystem property.- 参数:
includeDefaults- whether to include default tools
-
configure
Configure the tool manager with this toolbox factory config- 参数:
config- toolbox factory config
-
configure
Configure the tool manager with the provided configuration file- 参数:
path- path to configuration file
-
findConfig
Find a configuration file- 参数:
path- path to a configuration file- 返回:
- toolbox factory configuration
-
getToolboxFactory
Returns the underlyingToolboxFactorybeing used.- 返回:
- underlying toolbox factory
-
setToolboxFactory
Sets the underlying ToolboxFactory being used. If you use this, be sure that your ToolboxFactory is already properly configured.- 参数:
factory- toolbox factory
-
setVelocityEngine
public void setVelocityEngine(org.apache.velocity.app.VelocityEngine engine) Sets the underlying VelocityEngine being used. If you use this, be sure that your VelocityEngine is already properly configured and initialized.- 参数:
engine- VelocityEngine instance
-
getVelocityEngine
public org.apache.velocity.app.VelocityEngine getVelocityEngine()Get the underlying VelocityEngine being used.- 返回:
- VelocityEngine instance
-
setUserCanOverwriteTools
public void setUserCanOverwriteTools(boolean overwrite) Set whether template user can overwrite tools keys- 参数:
overwrite- flag value
-
getUserCanOverwriteTools
public boolean getUserCanOverwriteTools()Get whether template user can overwrite tools keys- 返回:
- flag value
-
getLog
public org.slf4j.Logger getLog()Get logger- 返回:
- logger
-
initLog
protected void initLog()init logger -
createContext
create new context with configured toolboxes tools- 返回:
- newly created context
-
createContext
create new context with configured toolboxes tools, using the provided tools properties- 参数:
toolProps- tools properties- 返回:
- newly created context
-
prepareContext
Prepare context- 参数:
context- tool context
-
addToolboxes
Add toolboxes to contex- 参数:
context- context
-
hasTools
Check for the presence of tools in a given scope- 参数:
scope- scope to check- 返回:
- whether this scope contains tools
-
createToolbox
Create a toolbox for the given scope- 参数:
scope- scope- 返回:
- newly created toolbox
-
hasRequestTools
public boolean hasRequestTools()Check whether this tool manager has request scoped tools- 返回:
trueif this tool manager has request scoped tools,falseotherwise
-
getRequestToolbox
Get the toolbox for request scoped tools- 返回:
- toolbox of request scoped tools
-
hasApplicationTools
public boolean hasApplicationTools()Check whether this tool manager has application scoped tools- 返回:
trueif this tool manager has application scoped tools,falseotherwise
-
getApplicationToolbox
Get the toolbox for application scoped tools- 返回:
- toolbox of application scoped tools
-