Package org.apache.velocity.tools
Class ToolboxFactory
- java.lang.Object
-
- org.apache.velocity.tools.ToolboxFactory
-
public class ToolboxFactory extends Object
This class is the central point of action for VelocityTools. It manages the configured and scoped
ToolInfoandDataand is meant to stick around for the life of the application.It works like this:
- Build up your
FactoryConfiguration(s) - Create a
ToolboxFactoryinstance - Pass the configuration to
configure(org.apache.velocity.tools.config.FactoryConfiguration) - When appropriate for each scope, use
createToolbox(java.lang.String)to create theToolboxfor that scope and put that toolbox somewhere appropriate to that scope. - When you want a tool, get that
Toolboxand 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
ToolManagerorVelocityViewand aToolContextorViewToolContext.NOTE: While you are free to pass in new configuration info at any time, that data will only affect
Toolboxes created subsequently. Any previously created toolboxes will have to be re-created and replaced to reflect the changes to the configuration.- Version:
- $Id: ToolboxFactory.java 511959 2007-02-26 19:24:39Z nbubna $
- Author:
- Nathan Bubna
- Build up your
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_SCOPE
-
Constructor Summary
Constructors Constructor Description ToolboxFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddToolInfo(String scope, ToolInfo tool)voidconfigure(FactoryConfiguration config)ToolboxcreateToolbox(String scope)Map<String,Object>getData()ObjectgetGlobalProperty(String name)protected Map<String,ToolInfo>getToolInfo(String scope)booleanhasTools(String scope)protected ObjectputData(String key, Object value)protected voidputGlobalProperties(Map<String,Object> props)protected voidputProperties(String scope, Map<String,Object> props)
-
-
-
Field Detail
-
DEFAULT_SCOPE
public static final String DEFAULT_SCOPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
public void configure(FactoryConfiguration config)
-
hasTools
public boolean hasTools(String scope)
-
-