1 17 18 package org.apache.commons.digester.plugins.strategies; 19 20 import java.util.Properties ; 21 import org.apache.commons.digester.Digester; 22 import org.apache.commons.digester.plugins.RuleFinder; 23 import org.apache.commons.digester.plugins.RuleLoader; 24 import org.apache.commons.digester.plugins.PluginException; 25 26 32 33 public class FinderFromDfltClass extends RuleFinder { 34 public static String DFLT_RULECLASS_SUFFIX = "RuleInfo"; 35 public static String DFLT_METHOD_NAME = "addRules"; 36 37 private String rulesClassSuffix; 38 private String methodName; 39 40 41 public FinderFromDfltClass() { 42 this(DFLT_RULECLASS_SUFFIX, DFLT_METHOD_NAME); 43 } 44 45 53 public FinderFromDfltClass(String rulesClassSuffix, String methodName) { 54 this.rulesClassSuffix = rulesClassSuffix; 55 this.methodName = methodName; 56 } 57 58 71 public RuleLoader findLoader(Digester digester, Class pluginClass, Properties p) 72 throws PluginException { 73 74 String rulesClassName = pluginClass.getName() + rulesClassSuffix; 75 76 Class rulesClass = null; 77 try { 78 rulesClass = digester.getClassLoader().loadClass(rulesClassName); 79 } catch(ClassNotFoundException cnfe) { 80 } 82 83 if (rulesClass == null) { 84 return null; 86 } 87 88 if (methodName == null) { 89 methodName = DFLT_METHOD_NAME; 90 } 91 92 return new LoaderFromClass(rulesClass, methodName); 93 } 94 } 95 96 | Popular Tags |