Class FinderFromResource
- java.lang.Object
-
- org.apache.commons.digester3.plugins.RuleFinder
-
- org.apache.commons.digester3.plugins.strategies.FinderFromResource
-
public class FinderFromResource extends RuleFinder
A rule-finding algorithm which expects the user to specify a resource name (ie a file in the classpath). The file is expected to contain Digester rules in xmlrules format.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DFLT_RESOURCE_ATTR
Default name of xml attribute on the plugin declaration which is used to configure rule-loading for that declaration.private java.lang.String
resourceAttr
-
Constructor Summary
Constructors Constructor Description FinderFromResource()
Constructor.FinderFromResource(java.lang.String resourceAttr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RuleLoader
findLoader(Digester d, java.lang.Class<?> pluginClass, java.util.Properties p)
If there exists a property with the name matching constructor param resourceAttr, then load that file, run it through the xmlrules module and return an object encapsulating those rules.static RuleLoader
loadRules(Digester d, java.lang.Class<?> pluginClass, java.io.InputStream is, java.lang.String resourceName)
Open the specified resource file (ie a file in the classpath, including being within a jar in the classpath), run it through the xmlrules module and return an object encapsulating those rules.
-
-
-
Field Detail
-
DFLT_RESOURCE_ATTR
private static final java.lang.String DFLT_RESOURCE_ATTR
Default name of xml attribute on the plugin declaration which is used to configure rule-loading for that declaration.- See Also:
- Constant Field Values
-
resourceAttr
private final java.lang.String resourceAttr
-
-
Method Detail
-
findLoader
public RuleLoader findLoader(Digester d, java.lang.Class<?> pluginClass, java.util.Properties p) throws PluginException
If there exists a property with the name matching constructor param resourceAttr, then load that file, run it through the xmlrules module and return an object encapsulating those rules.If there is no matching property provided, then just return null.
The returned object (when non-null) will add the selected rules to the digester whenever its addRules method is invoked.
- Specified by:
findLoader
in classRuleFinder
- Parameters:
d
- The digester instance where locating plugin classespluginClass
- The plugin Java classp
- 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:
- a source of digester rules for the specified plugin class.
- Throws:
PluginException
- if the algorithm finds a source of rules, but there is something invalid about that source.
-
loadRules
public static RuleLoader loadRules(Digester d, java.lang.Class<?> pluginClass, java.io.InputStream is, java.lang.String resourceName) throws PluginException
Open the specified resource file (ie a file in the classpath, including being within a jar in the classpath), run it through the xmlrules module and return an object encapsulating those rules.- Parameters:
d
- is the digester into which rules will eventually be loaded.pluginClass
- is the class whose xml params the rules are parsing.is
- is where the xmlrules will be read from, and must be non-null.resourceName
- is a string describing the source of the xmlrules, for use in generating error messages.- Returns:
- a source of digester rules for the specified plugin class.
- Throws:
PluginException
- if any error occurs
-
-