public class ToolInfo extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static String |
CONFIGURE_METHOD_NAME |
Constructor and Description |
---|
ToolInfo(String key,
Class clazz)
Creates a new instance using the minimum required info
necessary for a tool.
|
ToolInfo(String key,
Class clazz,
Class factory)
Creates a new instance using the minimum required info
necessary for a tool.
|
Modifier and Type | Method and Description |
---|---|
void |
addProperties(Map<String,Object> parentProps)
Adds a map of properties from a parent scope to the properties
for this tool.
|
protected Map<String,Object> |
combine(Map<String,Object>... maps)
Combine several property maps
|
protected void |
configure(Object tool,
Map<String,Object> configuration)
Actually performs configuration of the newly instantiated tool
using the combined final set of configuration properties.
|
Object |
create(Map<String,Object> dynamicProperties)
Returns a new instance of the tool.
|
String |
getClassname()
Get tool class name
|
protected Method |
getConfigure()
Try to find a
configure() method. |
Class |
getFactory()
Get factory class
|
String |
getKey()
Get tool key
|
Map<String,Object> |
getProperties()
Get tool properties
|
protected Map<String,Object> |
getProps()
Get tools property (synchronized version)
|
Class |
getToolClass()
Get tool class
|
boolean |
hasConfigure()
Get whether this tool has a
configure() method |
boolean |
hasPermission(String path) |
protected void |
invoke(Method method,
Object tool,
Object param)
Invoke a single argument method on a tool
|
boolean |
isSkipSetters()
Get whether setters are to be skipped
|
protected Object |
newInstance()
Creates a new instance for this tool.
|
Object |
putProperty(String name,
Object value)
Puts a new property for this tool.
|
void |
restrictTo(String path) |
void |
setClass(Class clazz)
Set the tool class
|
void |
setFactory(Class factory)
Set the factory class used to create tool instances.
|
void |
setKey(String key)
Set the tool key
|
protected void |
setProperty(Object tool,
String name,
Object value)
Set a property on a tool instance
|
void |
setSkipSetters(boolean cfgOnly)
Set whether or not to skip setters.
|
public static final String CONFIGURE_METHOD_NAME
public ToolInfo(String key, Class clazz)
key
- tool keyclazz
- tool classpublic void setKey(String key)
key
- tool keypublic void setClass(Class clazz)
clazz
- the java.lang.Class of the toolpublic void setFactory(Class factory)
Set the factory class used to create tool instances.
The factory is supposed to have one of those three methods:
where ToolClassName is the tool's class name.
If this method takes one java.util.Map
argument, it will be given the tool's configuration map.
factory
- factory classpublic void restrictTo(String path)
path
- the full or partial request path restriction of the toolpublic void setSkipSetters(boolean cfgOnly)
cfgOnly
- flag valuepublic void addProperties(Map<String,Object> parentProps)
parentProps
- parent properties mappublic Object putProperty(String name, Object value)
name
- property namevalue
- property valueprotected Map<String,Object> getProps()
public String getKey()
public String getClassname()
public Class getToolClass()
public Class getFactory()
public Map<String,Object> getProperties()
public boolean hasConfigure()
configure()
methodtrue
if the tool has a configure()
method, false
otherwisepublic boolean isSkipSetters()
public boolean hasPermission(String path)
path
- the path of a template requesting this tooltrue
if the specified
request path matches the restrictions of this tool.
If there is no request path restriction for this tool,
it will always return true
.public Object create(Map<String,Object> dynamicProperties)
dynamicProperties
- map of dynamic propertiesprotected void configure(Object tool, Map<String,Object> configuration)
SkipSetters
annotation, then any
specific setters matching the configuration keys are called, then
the general configure(Map) method (if any) is called.tool
- newly created tool to be configuredconfiguration
- propertiesprotected Method getConfigure()
configure()
method.configure()
method if found, null
otherwise.protected Object newInstance()
IllegalStateException
- if creation failedprotected void invoke(Method method, Object tool, Object param)
method
- the method to invoketool
- the tool on which to invoke the methodparam
- the method argumentIllegalStateException
- if invocation failedprotected void setProperty(Object tool, String name, Object value) throws Exception
tool
- tool instancename
- property namevalue
- property valueException
- if setting the property throwedCopyright © 2002–2021 The Apache Software Foundation. All rights reserved.