public class ToolManager extends Object
FactoryConfiguration
as well as configuration via a tools.xml or tools.properties file in
either the classpath or the local file system.Modifier and Type | Field and Description |
---|---|
protected ToolboxFactory |
factory |
protected org.slf4j.Logger |
log |
protected org.apache.velocity.app.VelocityEngine |
velocity |
Constructor and Description |
---|
ToolManager()
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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addToolboxes(ToolContext context)
Add toolboxes to contex
|
void |
autoConfigure(boolean includeDefaults)
Autoconfiguration using the configuration file potentially found
in the
org.apache.velocity.tools system property. |
void |
configure(FactoryConfiguration config)
Configure the tool manager with this toolbox factory config
|
void |
configure(String path)
Configure the tool manager with the provided configuration file
|
ToolContext |
createContext()
create new context with configured toolboxes tools
|
ToolContext |
createContext(Map<String,Object> toolProps)
create new context with configured toolboxes tools,
using the provided tools properties
|
protected Toolbox |
createToolbox(String scope)
Create a toolbox for the given scope
|
protected FactoryConfiguration |
findConfig(String path)
Find a configuration file
|
Toolbox |
getApplicationToolbox()
Get the toolbox for application scoped tools
|
org.slf4j.Logger |
getLog()
Get logger
|
Toolbox |
getRequestToolbox()
Get the toolbox for request scoped tools
|
ToolboxFactory |
getToolboxFactory()
Returns the underlying
ToolboxFactory being used. |
boolean |
getUserCanOverwriteTools()
Get whether template user can overwrite tools keys
|
org.apache.velocity.app.VelocityEngine |
getVelocityEngine()
Get the underlying VelocityEngine being used.
|
boolean |
hasApplicationTools()
Check whether this tool manager has application scoped tools
|
boolean |
hasRequestTools()
Check whether this tool manager has request scoped tools
|
protected boolean |
hasTools(String scope)
Check for the presence of tools in a given scope
|
protected void |
initLog()
init logger
|
protected void |
prepareContext(ToolContext context)
Prepare context
|
void |
setToolboxFactory(ToolboxFactory factory)
Sets the underlying ToolboxFactory being used.
|
void |
setUserCanOverwriteTools(boolean overwrite)
Set whether template user can overwrite tools keys
|
void |
setVelocityEngine(org.apache.velocity.app.VelocityEngine engine)
Sets the underlying VelocityEngine being used.
|
protected org.apache.velocity.app.VelocityEngine velocity
protected ToolboxFactory factory
protected org.slf4j.Logger log
public ToolManager()
public ToolManager(boolean includeDefaults)
includeDefaults
- whether to include default toolspublic ToolManager(boolean autoConfig, boolean includeDefaults)
autoConfig
- whether to use configuration file specified
in the org.apache.velocity.tools
system propertyincludeDefaults
- whether to include default toolspublic void autoConfigure(boolean includeDefaults)
org.apache.velocity.tools
system property.includeDefaults
- whether to include default toolspublic void configure(FactoryConfiguration config)
config
- toolbox factory configpublic void configure(String path)
path
- path to configuration fileprotected FactoryConfiguration findConfig(String path)
path
- path to a configuration filepublic ToolboxFactory getToolboxFactory()
ToolboxFactory
being used.public void setToolboxFactory(ToolboxFactory factory)
factory
- toolbox factorypublic void setVelocityEngine(org.apache.velocity.app.VelocityEngine engine)
engine
- VelocityEngine instancepublic org.apache.velocity.app.VelocityEngine getVelocityEngine()
public void setUserCanOverwriteTools(boolean overwrite)
overwrite
- flag valuepublic boolean getUserCanOverwriteTools()
public org.slf4j.Logger getLog()
protected void initLog()
public ToolContext createContext()
public ToolContext createContext(Map<String,Object> toolProps)
toolProps
- tools propertiesprotected void prepareContext(ToolContext context)
context
- tool contextprotected void addToolboxes(ToolContext context)
context
- contextprotected boolean hasTools(String scope)
scope
- scope to checkprotected Toolbox createToolbox(String scope)
scope
- scopepublic boolean hasRequestTools()
true
if this tool manager has request scoped tools,
false
otherwisepublic Toolbox getRequestToolbox()
public boolean hasApplicationTools()
true
if this tool manager has application scoped tools,
false
otherwisepublic Toolbox getApplicationToolbox()
Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.