Package org.apache.velocity.tools
Class ToolManager
- java.lang.Object
-
- org.apache.velocity.tools.ToolManager
-
- Direct Known Subclasses:
ViewToolManager
public class ToolManager extends java.lang.Object
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 aFactoryConfiguration
as well as configuration via a tools.xml or tools.properties file in either the classpath or the local file system.- Version:
- $Id: ToolManager.java 511959 2007-02-26 19:24:39Z nbubna $
- Author:
- Nathan Bubna
-
-
Field Summary
Fields Modifier and Type Field Description private Toolbox
application
protected ToolboxFactory
factory
private boolean
userOverwrite
protected org.apache.velocity.app.VelocityEngine
velocity
-
Constructor Summary
Constructors Constructor Description ToolManager()
Constructs an instance already configured to use theConfigurationUtils.getAutoLoaded()
configuration and any configuration specified via a "org.apache.velocity.tools" system property.ToolManager(boolean includeDefaults)
ToolManager(boolean autoConfig, boolean includeDefaults)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addToolboxes(ToolContext context)
void
autoConfigure(boolean includeDefaults)
void
configure(java.lang.String path)
void
configure(FactoryConfiguration config)
ToolContext
createContext()
ToolContext
createContext(java.util.Map<java.lang.String,java.lang.Object> toolProps)
protected Toolbox
createToolbox(java.lang.String scope)
protected void
debug(java.lang.String msg, java.lang.Object... args)
protected FactoryConfiguration
findConfig(java.lang.String path)
protected Toolbox
getApplicationToolbox()
org.apache.velocity.runtime.log.Log
getLog()
protected Toolbox
getRequestToolbox()
ToolboxFactory
getToolboxFactory()
Returns the underlyingToolboxFactory
being used.boolean
getUserCanOverwriteTools()
org.apache.velocity.app.VelocityEngine
getVelocityEngine()
protected boolean
hasApplicationTools()
protected boolean
hasRequestTools()
protected boolean
hasTools(java.lang.String scope)
protected void
prepareContext(ToolContext context)
void
setToolboxFactory(ToolboxFactory factory)
Sets the underlying ToolboxFactory being used.void
setUserCanOverwriteTools(boolean overwrite)
void
setVelocityEngine(org.apache.velocity.app.VelocityEngine engine)
Sets the underlying VelocityEngine being used.
-
-
-
Field Detail
-
velocity
protected org.apache.velocity.app.VelocityEngine velocity
-
factory
protected ToolboxFactory factory
-
application
private Toolbox application
-
userOverwrite
private boolean userOverwrite
-
-
Constructor Detail
-
ToolManager
public ToolManager()
Constructs an instance already configured to use theConfigurationUtils.getAutoLoaded()
configuration and any configuration specified via a "org.apache.velocity.tools" system property.
-
ToolManager
public ToolManager(boolean includeDefaults)
-
ToolManager
public ToolManager(boolean autoConfig, boolean includeDefaults)
-
-
Method Detail
-
autoConfigure
public void autoConfigure(boolean includeDefaults)
-
configure
public void configure(FactoryConfiguration config)
-
configure
public void configure(java.lang.String path)
-
findConfig
protected FactoryConfiguration findConfig(java.lang.String path)
-
getToolboxFactory
public ToolboxFactory getToolboxFactory()
Returns the underlyingToolboxFactory
being used.
-
setToolboxFactory
public void setToolboxFactory(ToolboxFactory factory)
Sets the underlying ToolboxFactory being used. If you use this, be sure that your ToolboxFactory is already properly configured.
-
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.
-
getVelocityEngine
public org.apache.velocity.app.VelocityEngine getVelocityEngine()
-
setUserCanOverwriteTools
public void setUserCanOverwriteTools(boolean overwrite)
-
getUserCanOverwriteTools
public boolean getUserCanOverwriteTools()
-
getLog
public org.apache.velocity.runtime.log.Log getLog()
-
debug
protected final void debug(java.lang.String msg, java.lang.Object... args)
-
createContext
public ToolContext createContext()
-
createContext
public ToolContext createContext(java.util.Map<java.lang.String,java.lang.Object> toolProps)
-
prepareContext
protected void prepareContext(ToolContext context)
-
addToolboxes
protected void addToolboxes(ToolContext context)
-
hasTools
protected boolean hasTools(java.lang.String scope)
-
createToolbox
protected Toolbox createToolbox(java.lang.String scope)
-
hasRequestTools
protected boolean hasRequestTools()
-
getRequestToolbox
protected Toolbox getRequestToolbox()
-
hasApplicationTools
protected boolean hasApplicationTools()
-
getApplicationToolbox
protected Toolbox getApplicationToolbox()
-
-