Class ToolInfo
java.lang.Object
org.apache.velocity.tools.ToolInfo
- All Implemented Interfaces:
Serializable
Manages data needed to create instances of a tool. New instances
are returned for every call to create(obj).
- Version:
- $Id: ToolInfo.java 511959 2007-02-26 19:24:39Z nbubna $
- Author:
- Nathan Bubna, Henning P. Schmiedehausen
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProperties(Map<String, Object> parentProps) Adds a map of properties from a parent scope to the properties for this tool.Combine several property mapsprotected voidActually performs configuration of the newly instantiated tool using the combined final set of configuration properties.Returns a new instance of the tool.Get tool class nameprotected MethodTry to find aconfigure()method.Get factory classgetKey()Get tool keyGet tool propertiesgetProps()Get tools property (synchronized version)Get tool classbooleanGet whether this tool has aconfigure()methodbooleanhasPermission(String path) protected voidInvoke a single argument method on a toolbooleanGet whether setters are to be skippedprotected ObjectCreates a new instance for this tool.putProperty(String name, Object value) Puts a new property for this tool.voidrestrictTo(String path) voidSet the tool classvoidsetFactory(Class factory) Set the factory class used to create tool instances.voidSet the tool keyprotected voidsetProperty(Object tool, String name, Object value) Set a property on a tool instancevoidsetSkipSetters(boolean cfgOnly) Set whether or not to skip setters.
-
Field Details
-
CONFIGURE_METHOD_NAME
- See Also:
-
-
Constructor Details
-
ToolInfo
-
ToolInfo
-
-
Method Details
-
setKey
-
setClass
Set the tool class- Parameters:
clazz- the java.lang.Class of the tool
-
setFactory
Set the factory class used to create tool instances.
The factory is supposed to have one of those three methods:
- createToolClassName()
- newToolClassName()
- getToolClassName()
where ToolClassName is the tool's class name.
If this method takes one
java.util.Mapargument, it will be given the tool's configuration map.- Parameters:
factory- factory class
-
restrictTo
- Parameters:
path- the full or partial request path restriction of the tool
-
setSkipSetters
public void setSkipSetters(boolean cfgOnly) Set whether or not to skip setters.- Parameters:
cfgOnly- flag value
-
addProperties
-
putProperty
-
getProps
-
getKey
-
getClassname
-
getToolClass
-
getFactory
-
getProperties
-
hasConfigure
public boolean hasConfigure()Get whether this tool has aconfigure()method- Returns:
trueif the tool has aconfigure()method,falseotherwise
-
isSkipSetters
public boolean isSkipSetters()Get whether setters are to be skipped- Returns:
- whether to skip setters
-
hasPermission
- Parameters:
path- the path of a template requesting this tool- Returns:
trueif the specified request path matches the restrictions of this tool. If there is no request path restriction for this tool, it will always returntrue.
-
create
Returns a new instance of the tool. If the tool has an configure(Map) method, the new instance will be initialized using the given properties combined with whatever "constant" properties have been put into this ToolInfo.- Parameters:
dynamicProperties- map of dynamic properties- Returns:
- newly created and configured object
-
configure
Actually performs configuration of the newly instantiated tool using the combined final set of configuration properties. First, if the class lacks theSkipSettersannotation, then any specific setters matching the configuration keys are called, then the general configure(Map) method (if any) is called.- Parameters:
tool- newly created tool to be configuredconfiguration- properties
-
getConfigure
Try to find aconfigure()method.- Returns:
configure()method if found,nullotherwise.
-
newInstance
Creates a new instance for this tool.- Returns:
- newly created tool
- Throws:
IllegalStateException- if creation failed
-
invoke
Invoke a single argument method on a tool- Parameters:
method- the method to invoketool- the tool on which to invoke the methodparam- the method argument- Throws:
IllegalStateException- if invocation failed
-
setProperty
-
combine
-