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