Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.digester3.plugins.strategies
Class FinderFromClass

    java.lang.Object
      org.apache.commons.digester3.plugins.RuleFinder
          org.apache.commons.digester3.plugins.strategies.FinderFromClass

    public class FinderFromClass

extends RuleFinder

A rule-finding algorithm which expects the caller to specify a classname and methodname as plugin properties.

Since:
  1.6

Constructor Summary
`FinderFromClass()` See `findLoader(org.apache.commons.digester3.Digester, java.lang.Class, java.util.Properties)`.
`FinderFromClass(String ruleClassAttr, String methodAttr, String dfltMethodName)` Create a rule-finder which invokes a user-specified method on a user-specified class whenever dynamic rules for a plugin need to be loaded.

Method Summary
`RuleLoader` | `findLoader(Digester digester, Class<?> pluginClass, Properties p)` If there exists a property with the name matching constructor param ruleClassAttr, then load the specified class, locate the appropriate rules-adding method on that class, and return an object encapsulating that info.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FinderFromClass

    public FinderFromClass()

  See `findLoader(org.apache.commons.digester3.Digester, java.lang.Class, java.util.Properties)`.

### FinderFromClass

    public FinderFromClass(String ruleClassAttr,
                           String methodAttr,
                           String dfltMethodName)

  Create a rule-finder which invokes a user-specified method on a user-specified class whenever dynamic rules for a plugin need to be loaded. See the findRules method for more info.

  Parameters:
    `ruleClassAttr` - must be non-null.
    `methodAttr` - may be null.
    `dfltMethodName` - may be null.

Method Detail

### findLoader

    public RuleLoader findLoader(Digester digester,
                                 Class<?> pluginClass,
                                 Properties p)
                          throws PluginException

  If there exists a property with the name matching constructor param ruleClassAttr, then load the specified class, locate the appropriate rules-adding method on that class, and return an object encapsulating that info.

  If there is no matching property provided, then just return null.

  The returned object (when non-null) will invoke the target method on the selected class whenever its addRules method is invoked. The target method is expected to have the following prototype: `public static void xxxxx(Digester d, String patternPrefix);`

  The target method can be specified in several ways. If this object's constructor was passed a non-null methodAttr parameter, and the properties defines a value with that key, then that is taken as the target method name. If there is no matching property, or the constructor was passed null for methodAttr, then the dfltMethodName passed to the constructor is used as the name of the method on the target class. And if that was null, then DFLT_METHOD_NAME will be used.

  When the user explicitly declares a plugin in the input xml, the xml attributes on the declaration tag are passed here as properties, so the user can select any class in the classpath (and any method on that class provided it has the correct prototype) as the source of dynamic rules for the plugged-in class.

  Specified by:
    `findLoader` in class `RuleFinder`
  Parameters:
    `digester` - The digester instance where locating plugin classes
    `pluginClass` - The plugin Java class
    `p` - 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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