org.apache.commons.digester3.plugins.strategies
Class LoaderFromClass

java.lang.Object
  extended by org.apache.commons.digester3.plugins.RuleLoader
      extended by 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

Constructor Summary
LoaderFromClass(Class<?> rulesClass, Method rulesMethod)
          Constructor.
LoaderFromClass(Class<?> rulesClass, String methodName)
          Constructor.
 
Method Summary
 void addRules(Digester d, String path)
          Configures the digester with custom rules for some plugged-in class.
static Method locateMethod(Class<?> rulesClass, 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);.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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


Copyright © 2001-2011 The Apache Software Foundation. All Rights Reserved.