本文整理汇总了Java中org.apache.commons.digester.xmlrules.DigesterLoader类的典型用法代码示例。如果您正苦于以下问题:Java DigesterLoader类的具体用法?Java DigesterLoader怎么用?Java DigesterLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DigesterLoader类属于org.apache.commons.digester.xmlrules包,在下文中一共展示了DigesterLoader类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadDigesterRules
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
private void loadDigesterRules(String rulesfileName)
{
if (rulesfileName == null)
{
logger.error("No rules file configured");
return;
}
logger.info("loading rulesfile " + rulesfileName);
URL rulesURL = ClassLoader.getSystemResource(rulesfileName);
if (rulesURL == null)
{
logger.error("Unable to find rules file " + rulesfileName);
throw new IllegalStateException("Unable to find rules file " + rulesfileName);
}
digester = DigesterLoader.createDigester(rulesURL);
}
示例2: doPipe
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
@Override
public PipeRunResult doPipe(Object input, IPipeLineSession session)
throws PipeRunException {
//Multi threading: instantiate digester for each request as the digester is NOT thread-safe.
//TODO: make a pool of digesters
Digester digester = DigesterLoader.createDigester(rulesURL);
try {
ByteArrayInputStream xmlInputStream =
new ByteArrayInputStream(input.toString().getBytes());
return new PipeRunResult(getForward(), digester.parse(xmlInputStream));
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session)+"exception in digesting", e);
}
}
示例3: S2ValidatorResources
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
/**
* インスタンスを構築します。
*
* @param streams
* 入力ストリームの配列
* @throws IOException
* IO例外が発生した場合。
* @throws SAXException
* SAX例外が発生した場合。
*/
public S2ValidatorResources(InputStream[] streams) throws IOException,
SAXException {
URL rulesUrl = ValidatorResources.class
.getResource("digester-rules.xml");
Digester digester = DigesterLoader.createDigester(rulesUrl);
digester.setNamespaceAware(true);
digester.setValidating(true);
digester.setUseContextClassLoader(true);
for (int i = 0; i < REGISTRATIONS.length; i += 2) {
URL url = ValidatorResources.class
.getResource(REGISTRATIONS[i + 1]);
if (url != null) {
digester.register(REGISTRATIONS[i], url.toString());
}
}
for (int i = 0; i < streams.length; i++) {
digester.push(this);
digester.parse(streams[i]);
}
initialize();
}
示例4: digesterFromXml
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
/**
* <p>Instantiate a Digester from an XML input stream using the Commons
* <code>DigesterLoader</code>.</p>
* @param path the path to the digester rules XML to be found using <code>source</code>
* @param source a string indicating the lookup method to be used with <code>path</code>
* @return a configured Digester
* @throws FileNotFoundException
* @throws MalformedURLException
* @see #getConfigURL(String, String)
*/
protected Digester digesterFromXml(String path, String source)
throws IOException {
URL configURL = this.getConfigURL(path, source);
if (configURL == null)
{
throw new NullPointerException("No resource '" + path + "' found in '" + source + "'");
}
return DigesterLoader.createDigester(configURL);
}
示例5: loadRules
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
/**
* @return Rules loaded from the appropriate XML file
*/
protected Rules loadRules(String digestorRulesFileName) {
// locate Digester rules
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL rulesUrl = classLoader.getResource(digestorRulesFileName);
if (rulesUrl == null) {
throw new RuntimeException("unable to locate digester rules file " + digestorRulesFileName);
}
// create and init digester
Digester digester = DigesterLoader.createDigester(rulesUrl);
return digester.getRules();
}
示例6: loadRules
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
/**
* @return Rules loaded from the appropriate XML file
*/
private Rules loadRules(String digestorRulesFileName) {
// locate Digester rules
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL rulesUrl = classLoader.getResource(digestorRulesFileName);
if (rulesUrl == null) {
throw new RuntimeException("unable to locate digester rules file " + digestorRulesFileName);
}
// create and init digester
Digester digester = DigesterLoader.createDigester(rulesUrl);
return digester.getRules();
}
示例7: load
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
/**
* Loads the configuration parameters by delegating to commons digester.
*/
public Collection<T> load() throws KettleConfigException
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Digester digester = DigesterLoader.createDigester(loader.getResource(rulesURL));
final Set<T> configObjs = new LinkedHashSet<T>();
digester.addRule(setNext, new SetNextRule("")
{
@SuppressWarnings("unchecked")
public void end(String nameSpace, String name) throws Exception
{
configObjs.add((T) digester.peek());
}
});
try
{
digester.parse(loader.getResource(configURL));
} catch (Exception e)
{
throw new KettleConfigException(e);
}
return configObjs;
}
示例8: initDigester
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
/**
* Initialize the digester.
*/
private Digester initDigester() {
URL rulesUrl = this.getClass().getResource(VALIDATOR_RULES);
if (rulesUrl == null) {
// Fix for Issue# VALIDATOR-195
rulesUrl = ValidatorResources.class.getResource(VALIDATOR_RULES);
}
if (getLog().isDebugEnabled()) {
getLog().debug("Loading rules from '" + rulesUrl + "'");
}
Digester digester = DigesterLoader.createDigester(rulesUrl);
digester.setNamespaceAware(true);
digester.setValidating(true);
digester.setUseContextClassLoader(true);
// Add rules for arg0-arg3 elements
addOldArgRules(digester);
// register DTDs
for (int i = 0; i < REGISTRATIONS.length; i += 2) {
URL url = this.getClass().getResource(REGISTRATIONS[i + 1]);
if (url != null) {
digester.register(REGISTRATIONS[i], url.toString());
}
}
return digester;
}
示例9: configure
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
@Override
public void configure() throws ConfigurationException {
super.configure();
try {
rulesURL = ClassUtils.getResourceURL(classLoader, digesterRulesFile);
DigesterLoader.createDigester(rulesURL); // load rules to check if they can be loaded when needed
} catch (Exception e) {
throw new ConfigurationException(getLogPrefix(null)+"Digester rules file ["+digesterRulesFile+"] not found", e);
}
log.debug(getLogPrefix(null)+"End of configuration");
}
示例10: unmarshal
import org.apache.commons.digester.xmlrules.DigesterLoader; //导入依赖的package包/类
/**
* Parses and validates the XML input data.
*/
public void unmarshal(String objects) throws TaskException {
try {
// get the configuration filename
String configFilename = PARAM_CONFIG_FILENAME_DEFAULT;
if (parameters.get(PARAM_CONFIG_FILENAME.getName()) != null) {
configFilename = (String) parameters.get(PARAM_CONFIG_FILENAME.getName());
}
// if the filename is relative, prepend default directory
configFilename = getAbsolutePath(configFilename);
LOG.debug("Config filename: " + configFilename);
// load the parsing rules
Digester digester = DigesterLoader.createDigester(new URL("file:///" + configFilename));
digester.setUseContextClassLoader(true);
// parse the input string
//digester.setValidating(true);
data = digester.parse(new StringReader(objects));
} catch (IOException ioe) {
LOG.error("Error parsing XML file: " + ioe.toString());
throw new TaskException(ioe);
} catch (SAXException saxe) {
LOG.error("Error parsing XML file: " + saxe.toString());
throw new TaskException(saxe);
}
}