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