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 `ToolInfo` and `Data` and is meant to stick around for the life of the application.

It works like this:

1. Build up your `FactoryConfiguration`(s)
2. Create a `ToolboxFactory` instance
3. Pass the configuration to `configure(org.apache.velocity.tools.config.FactoryConfiguration)`
4. When appropriate for each scope, use `createToolbox(java.lang.String)` to create the `Toolbox` for that scope and put that toolbox somewhere appropriate to that scope.
5. When you want a tool, get that `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.

Version:
  $Id: ToolboxFactory.java 511959 2007-02-26 19:24:39Z nbubna $
Author:
  Nathan Bubna

### Field Summary

Fields
`static String` `DEFAULT_SCOPE`

### Constructor Summary

Constructors
Constructor and Description
`ToolboxFactory()`

### Method Summary

All Methods Instance Methods Concrete Methods
`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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT_SCOPE

    public static final String DEFAULT_SCOPE

See Also:
  Constant Field Values

### Constructor Detail

#### ToolboxFactory

    public ToolboxFactory()

### Method Detail

#### configure

    public void configure(FactoryConfiguration config)

#### putData

    protected Object putData(String key,
                             Object value)

#### addToolInfo

    protected void addToolInfo(String scope,
                               ToolInfo tool)

#### getToolInfo

    protected Map<String,ToolInfo> getToolInfo(String scope)

#### putGlobalProperties

    protected void putGlobalProperties(Map<String,Object> props)

#### putProperties

    protected void putProperties(String scope,
                                 Map<String,Object> props)

#### getGlobalProperty

    public Object getGlobalProperty(String name)

#### getData

    public Map<String,Object> getData()

#### hasTools

    public boolean hasTools(String scope)

#### createToolbox

    public Toolbox createToolbox(String scope)