1 17 18 package org.apache.commons.digester.plugins.strategies; 19 20 import java.io.InputStream ; 21 import java.util.Properties ; 22 23 import org.apache.commons.digester.Digester; 24 import org.apache.commons.digester.plugins.RuleFinder; 25 import org.apache.commons.digester.plugins.RuleLoader; 26 import org.apache.commons.digester.plugins.PluginException; 27 28 37 38 public class FinderFromDfltResource extends RuleFinder { 39 public static String DFLT_RESOURCE_SUFFIX = "RuleInfo.xml"; 40 41 private String resourceSuffix; 42 43 44 public FinderFromDfltResource() { 45 this(DFLT_RESOURCE_SUFFIX); 46 } 47 48 55 public FinderFromDfltResource(String resourceSuffix) { 56 this.resourceSuffix = resourceSuffix; 57 } 58 59 70 public RuleLoader findLoader(Digester d, Class pluginClass, Properties p) 71 throws PluginException { 72 73 String resourceName = 74 pluginClass.getName().replace('.', '/') 75 + resourceSuffix; 76 77 InputStream is = 78 pluginClass.getClassLoader().getResourceAsStream( 79 resourceName); 80 81 if (is == null) { 82 return null; 84 } 85 86 return FinderFromResource.loadRules(d, pluginClass, is, resourceName); 87 } 88 } 89 90 | Popular Tags |