public class ToolboxFactory extends Object
This class is the central point of action for VelocityTools.
It manages the configured and scoped ToolInfo
and Data
and is meant to stick around for the life of the application.
It works like this:
FactoryConfiguration
(s)ToolboxFactory
instanceconfigure(org.apache.velocity.tools.config.FactoryConfiguration)
createToolbox(java.lang.String)
to create the Toolbox
for that scope and put that toolbox
somewhere appropriate to that scope.Toolbox
and
ask it for the tool you want (e.g. toolbox.get("math")
).
Of course, most users will not have to do any of this
as much of it is handled for them by some combination of
ToolManager
or org.apache.velocity.tools.view.VelocityView
and a ToolContext
or org.apache.velocity.tools.view.ViewToolContext.
NOTE: While you are free to pass in new configuration info
at any time, that data will only affect Toolbox
es created subsequently.
Any previously created toolboxes will have to be re-created and replaced to
reflect the changes to the configuration.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_SCOPE |
Constructor and Description |
---|
ToolboxFactory() |
Modifier and Type | Method and Description |
---|---|
protected void |
addToolInfo(String scope,
ToolInfo tool) |
void |
configure(FactoryConfiguration config) |
Toolbox |
createToolbox(String scope) |
Map<String,Object> |
getData() |
Object |
getGlobalProperty(String name) |
protected Map<String,ToolInfo> |
getToolInfo(String scope) |
boolean |
hasTools(String scope) |
protected Object |
putData(String key,
Object value) |
protected void |
putGlobalProperties(Map<String,Object> props) |
protected void |
putProperties(String scope,
Map<String,Object> props) |
public static final String DEFAULT_SCOPE
public void configure(FactoryConfiguration config)
public boolean hasTools(String scope)
Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.