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 Details

    • rulesClass

      private final Class<?> rulesClass
    • rulesMethod

      private final Method rulesMethod
  • Constructor Details

    • LoaderFromClass

      public LoaderFromClass(Class<?> rulesClass, Method rulesMethod)
      Constructor.
      Parameters:
      rulesClass - The target class
      rulesMethod - The method has to be invoked
    • LoaderFromClass

      public LoaderFromClass(Class<?> rulesClass, String methodName) throws PluginException
      Constructor.
      Parameters:
      rulesClass - The target class
      methodName - The method name has to be invoked
      Throws:
      PluginException - if input method can't be located inside the given class
  • Method Details

    • addRules

      public void addRules(Digester d, 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 class RuleLoader
      Parameters:
      d - The gigester has to be configured
      path - The path where rule has to be bound
      Throws:
      PluginException - if any error occurs
    • locateMethod

      public static Method locateMethod(Class<?> rulesClass, 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 class
      methodName - 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