Class LoaderFromClass
- java.lang.Object
-
- org.apache.commons.digester3.plugins.RuleLoader
-
- org.apache.commons.digester3.plugins.strategies.LoaderFromClass
-
public class LoaderFromClass extends RuleLoader
A RuleLoader which invokes a static method on a target class, leaving that method to actually instantiate and add new rules to a Digester instance.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<?>
rulesClass
private java.lang.reflect.Method
rulesMethod
-
Constructor Summary
Constructors Constructor Description LoaderFromClass(java.lang.Class<?> rulesClass, java.lang.reflect.Method rulesMethod)
Constructor.LoaderFromClass(java.lang.Class<?> rulesClass, java.lang.String methodName)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRules(Digester d, java.lang.String path)
Configures the digester with custom rules for some plugged-in class.static java.lang.reflect.Method
locateMethod(java.lang.Class<?> rulesClass, java.lang.String methodName)
Find a method on the specified class whose name matches methodName, and whose signature is:public static void foo(Digester d, String patternPrefix);
.
-
-
-
Constructor Detail
-
LoaderFromClass
public LoaderFromClass(java.lang.Class<?> rulesClass, java.lang.reflect.Method rulesMethod)
Constructor.- Parameters:
rulesClass
- The target classrulesMethod
- The method has to be invoked
-
LoaderFromClass
public LoaderFromClass(java.lang.Class<?> rulesClass, java.lang.String methodName) throws PluginException
Constructor.- Parameters:
rulesClass
- The target classmethodName
- The method name has to be invoked- Throws:
PluginException
- if input method can't be located inside the given class
-
-
Method Detail
-
addRules
public void addRules(Digester d, java.lang.String path) throws PluginException
Configures the digester with custom rules for some plugged-in class.This method is invoked when the start of an xml tag is encountered which maps to a PluginCreateRule. Any rules added here are removed from the digester when the end of that xml tag is encountered.
- Specified by:
addRules
in classRuleLoader
- Parameters:
d
- The gigester has to be configuredpath
- The path where rule has to be bound- Throws:
PluginException
- if any error occurs
-
locateMethod
public static java.lang.reflect.Method locateMethod(java.lang.Class<?> rulesClass, java.lang.String methodName) throws PluginException
Find a method on the specified class whose name matches methodName, and whose signature is:public static void foo(Digester d, String patternPrefix);
.- Parameters:
rulesClass
- The target classmethodName
- The method name has to be invoked- Returns:
- The method name has to be invoked, or null if no such method exists.
- Throws:
PluginException
- if any error occurs while discovering the method
-
-