Class PluginManager
- java.lang.Object
-
- org.apache.commons.digester3.plugins.PluginManager
-
public class PluginManager extends java.lang.Object
Coordinates between PluginDeclarationRule and PluginCreateRule objects, providing a place to share data between instances of these rules.One instance of this class exists per PluginRules instance.
- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<java.lang.String,Declaration>
declarationsByClass
Map of classname->Declarationprivate java.util.HashMap<java.lang.String,Declaration>
declarationsById
Map of id->Declarationprivate PluginManager
parent
the parent manager to which this one may delegate lookups.private PluginContext
pluginContext
The object containing data that should only exist once for each Digester instance.
-
Constructor Summary
Constructors Constructor Description PluginManager(PluginContext r)
Construct a "root" PluginManager, ie one with no parent.PluginManager(PluginManager parent)
Construct a "child" PluginManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDeclaration(Declaration decl)
Add the declaration to the set of known declarations.RuleLoader
findLoader(Digester digester, java.lang.String id, java.lang.Class<?> pluginClass, java.util.Properties props)
Given a plugin class and some associated properties, scan the list of known RuleFinder instances until one detects a source of custom rules for this plugin (aka a RuleLoader).Declaration
getDeclarationByClass(java.lang.String className)
Return the declaration object with the specified class.Declaration
getDeclarationById(java.lang.String id)
Return the declaration object with the specified id.
-
-
-
Field Detail
-
declarationsByClass
private java.util.HashMap<java.lang.String,Declaration> declarationsByClass
Map of classname->Declaration
-
declarationsById
private java.util.HashMap<java.lang.String,Declaration> declarationsById
Map of id->Declaration
-
parent
private PluginManager parent
the parent manager to which this one may delegate lookups.
-
pluginContext
private PluginContext pluginContext
The object containing data that should only exist once for each Digester instance.
-
-
Constructor Detail
-
PluginManager
public PluginManager(PluginContext r)
Construct a "root" PluginManager, ie one with no parent.- Parameters:
r
- The object containing data that should only exist once for each Digester instance.
-
PluginManager
public PluginManager(PluginManager parent)
Construct a "child" PluginManager. When declarations are added to a "child", they are stored within the child and do not modify the parent, so when the child goes out of scope, those declarations disappear. When asking a "child" to retrieve a declaration, it delegates the search to its parent if it does not hold a matching entry itself.- Parameters:
parent
- must be non-null.
-
-
Method Detail
-
addDeclaration
public void addDeclaration(Declaration decl)
Add the declaration to the set of known declarations.TODO: somehow get a reference to a Digester object so that we can really log here. Currently, all logging is disabled from this method.
- Parameters:
decl
- an object representing a plugin class.
-
getDeclarationByClass
public Declaration getDeclarationByClass(java.lang.String className)
Return the declaration object with the specified class. If no such plugin is known, null is returned.- Parameters:
className
- TheDeclaration
class name- Returns:
- The Declaration instance obtained by the input class name
-
getDeclarationById
public Declaration getDeclarationById(java.lang.String id)
Return the declaration object with the specified id. If no such plugin is known, null is returned.- Parameters:
id
- Description of the Parameter- Returns:
- The declaration value
-
findLoader
public RuleLoader findLoader(Digester digester, java.lang.String id, java.lang.Class<?> pluginClass, java.util.Properties props) throws PluginException
Given a plugin class and some associated properties, scan the list of known RuleFinder instances until one detects a source of custom rules for this plugin (aka a RuleLoader).If no source of custom rules can be found, null is returned.
- Parameters:
digester
- The digester instance where locating plugin classesid
- The id that the user associated with a particular plugin declaration in the input xmlpluginClass
- The plugin Java classprops
- The properties object that holds any xml attributes the user may have specified on the plugin declaration in order to indicate how to locate the plugin rules.- Returns:
- The discovered Rule loader instance
- Throws:
PluginException
- if any error occurs while finding the loader
-
-