1. /* $Id: RuleFinder.java,v 1.5 2004/05/10 06:36:38 skitching Exp $
  2. *
  3. * Copyright 2004 The Apache Software Foundation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.commons.digester.plugins;
  18. import java.util.Properties;
  19. import org.apache.commons.digester.Digester;
  20. /**
  21. * Each concrete implementation of RuleFinder is an algorithm for
  22. * locating a source of digester rules for a plugin. The algorithm may
  23. * use info explicitly provided by the user as part of the plugin
  24. * declaration, or not (in which case the concrete RuleFinder subclass
  25. * typically has Dflt as part of its name).
  26. * <p>
  27. * Instances of this class can also be regarded as a Factory for RuleLoaders,
  28. * except that an instance of a RuleLoader is only created if the particular
  29. * finder algorithm can locate a suitable source of rules given the plugin
  30. * class and associated properties.
  31. * <p>
  32. * This is an abstract class rather than an interface in order to make
  33. * it possible to enhance this class in future without breaking binary
  34. * compatibility; it is possible to add methods to an abstract class, but
  35. * not to an interface.
  36. *
  37. * @since 1.6
  38. */
  39. public abstract class RuleFinder {
  40. /**
  41. * Apply the finder algorithm to attempt to locate a source of
  42. * digester rules for the specified plugin class.
  43. * <p>
  44. * This method is invoked when a plugin is declared by the user, either
  45. * via an explicit use of PluginDeclarationRule, or implicitly via an
  46. * "inline declaration" where the declaration and use are simultaneous.
  47. * <p>
  48. * If dynamic rules for the specified plugin class are located, then
  49. * the RuleFinder will return a RuleLoader object encapsulating those
  50. * rules, and this object will be invoked each time the user actually
  51. * requests an instance of the declared plugin class, to load the
  52. * custom rules associated with that plugin instance.
  53. * <p>
  54. * If no dynamic rules can be found, null is returned. This is not an
  55. * error; merely an indication that this particular algorithm found
  56. * no matches.
  57. * <p>
  58. * The properties object holds any xml attributes the user may have
  59. * specified on the plugin declaration in order to indicate how to locate
  60. * the plugin rules.
  61. * <p>
  62. * @throws PluginConfigurationException if the algorithm finds a source
  63. * of rules, but there is something invalid about that source.
  64. */
  65. public abstract RuleLoader findLoader(
  66. Digester d, Class pluginClass,
  67. Properties p) throws PluginException;
  68. }