本文整理匯總了Java中org.apache.commons.digester.Digester.setUseContextClassLoader方法的典型用法代碼示例。如果您正苦於以下問題:Java Digester.setUseContextClassLoader方法的具體用法?Java Digester.setUseContextClassLoader怎麽用?Java Digester.setUseContextClassLoader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.digester.Digester
的用法示例。
在下文中一共展示了Digester.setUseContextClassLoader方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: XmlParser
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
/**
* Constructor.
* Creates a digester parser and initializes syntax rules.
*/
public XmlParser()
{
digester = new Digester();
digester.setValidating(validating);
digester.setNamespaceAware(true);
digester.setUseContextClassLoader(true);
// Register our local copy of the DTDs that we can find
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());
}
}
// Init syntax rules
initDigester( digester );
}
示例2: XmlParser
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
/**
* Constructor.
* Creates a digester parser and initializes syntax rules.
*/
public XmlParser()
{
digester = new Digester();
digester.setValidating(validating);
digester.setNamespaceAware(true);
digester.setUseContextClassLoader(true);
// Register our local copy of the DTDs that we can find
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());
}
}
// Init syntax rules
initDigester( digester );
}
示例3: DdlUtilsDataHandling
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
/**
* Creates a new data handling object.
*/
public DdlUtilsDataHandling()
{
_digester = new Digester();
_digester.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId, String systemId)
{
// we don't care about the DTD for data files
return new InputSource(new StringReader(""));
}
});
_digester.setNamespaceAware(true);
_digester.setValidating(false);
_digester.setUseContextClassLoader(true);
_digester.setRules(new ExtendedBaseRules());
_digester.addRuleSet(new DataRuleSet());
}
示例4: S2ValidatorResources
import org.apache.commons.digester.Digester; //導入方法依賴的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();
}
示例5: getFormat
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
protected Format getFormat() throws IOException, SAXException {
// parse the XML ...
// create a field object per field element
if (format == null) {
Digester digester = new Digester();
digester.setValidating(true);
digester.setUseContextClassLoader(true);
digester.addObjectCreate("format", "com.sapienter.jbilling.server.mediation.Format");
digester.addObjectCreate("format/field", "com.sapienter.jbilling.server.mediation.FormatField");
digester.addCallMethod("format/field/name","setName",0);
digester.addCallMethod("format/field/type","setType",0);
digester.addCallMethod("format/field/startPosition","setStartPosition",0);
digester.addCallMethod("format/field/durationFormat","setDurationFormat",0);
digester.addCallMethod("format/field/length","setLength",0);
digester.addCallMethod("format/field/isKey","isKeyTrue");
digester.addSetNext("format/field", "addField", "com.sapienter.jbilling.server.mediation.FormatField");
format = (Format) digester.parse(new File(formatFileName));
LOG.debug("using format: " + format);
}
return format;
}
示例6: initDigester
import org.apache.commons.digester.Digester; //導入方法依賴的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;
}
示例7: digestStatistics
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
public void digestStatistics(Reader reader, String sysid) throws ConfigurationException {
Reader fileReader = new EncapsulatingReader(reader, "<"+ROOT_ELEM_NAME+">", "</"+ROOT_ELEM_NAME+">", false);
Digester digester = new Digester();
digester.setUseContextClassLoader(true);
// push config on the stack
digester.push(this);
try {
// String prefix="/"+ROOT_ELEM_NAME+"/";
String prefix="*/";
digester.addSetProperties(prefix+"statisticsCollection"); // timestamp info
digester.addSetProperties(prefix+"statisticsCollection/statgroup"); // instance info
digester.addObjectCreate (prefix+"statisticsCollection/statgroup/statgroup",SummaryRecord.class); // adapterinfo
digester.addSetProperties(prefix+"statisticsCollection/statgroup/statgroup");
digester.addSetNext (prefix+"statisticsCollection/statgroup/statgroup","registerRecord");
digester.addObjectCreate (prefix+"statisticsCollection/statgroup/statgroup/stat/interval/item",Item.class); // adapterinfo
digester.addSetProperties(prefix+"statisticsCollection/statgroup/statgroup/stat/interval/item");
digester.addSetNext (prefix+"statisticsCollection/statgroup/statgroup/stat/interval/item","registerItem");
InputSource is= new InputSource(fileReader);
digester.parse(is);
} catch (Exception e) {
// wrap exception to be sure it gets rendered via the IbisException-renderer
throw new ConfigurationException("error during parsing of file ["+sysid +"]", e);
}
}
示例8: execute
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
/**
* Installs a module description in the target OpenCms. Module description
* comes from the path given in the parameter configurationXml. The XML file
* there contains module description(s) in the format as in WEB-INF/config/opencms-modules.xml
* or manifest.xml of an exported module. It may contain multiple modules,
* but it must be well formed, say, in case of multiple modules it must have one root node
* containing the module entries. These module configuration(s) get added to
* WEB-INF/config/opencms-modules.xml of the target installation.
* Module content gets sync'ed and published afterwards by the respective plugin goals.
*
* @param webappDirectory
* path to WEB-INF of the OpenCms installation
* @param adminPassword
* password of user "Admin" performing the operation
* @param moduleSourcePath
* path to module xml configuration file
* @throws CmsException
* if anything OpenCms goes wrong
* @throws IOException
* in case configuration files cannot be read
* @throws SAXException
* in case configuration files cannot be parsed
*/
public final void execute(final String webappDirectory,
final String adminPassword, final String moduleSourcePath, final String moduleVersion)
throws IOException, CmsException, SAXException {
final String webinfdir = webappDirectory + File.separatorChar +
"WEB-INF";
final CmOpenCmsShell cmsshell = CmOpenCmsShell.getInstance(webinfdir,
"Admin", adminPassword);
this.moduleVersion = moduleVersion;
if (cmsshell != null) {
this.cms = cmsshell.getCmsObject();
final CmsRequestContext requestcontext = this.cms.getRequestContext();
requestcontext.setCurrentProject(this.cms.readProject("Offline"));
this.setReport(new CmsShellReport(requestcontext.getLocale()));
// code taken from org.opencms.module.CmsModuleImportExportHandler (readModuleFromImport)
final Digester digester = new Digester();
digester.setUseContextClassLoader(true);
digester.setValidating(false);
digester.setRuleNamespaceURI(null);
digester.setErrorHandler(new CmsXmlErrorHandler());
digester.push(this);
CmsModuleXmlHandler.addXmlDigesterRules(digester);
simpleReport("Parsing module file: "+moduleSourcePath+". Version: "+moduleVersion);
digester.parse(new FileInputStream(new File(moduleSourcePath)));
simpleReport("End of parsing module file: "+moduleSourcePath+". Version: "+moduleVersion);
}else{
System.err.println("[WARN]VfsModule.execute(): CmsShell not available");
}
}
示例9: unmarshal
import org.apache.commons.digester.Digester; //導入方法依賴的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);
}
}
示例10: createServerList
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
/**
* Creates the rules.
*
* @return The rules all put into a rule chain
*/
private LinkedList createServerList(File data) throws Exception {
Digester digester = new Digester();
digester.setUseContextClassLoader(true);
// Construct server list
digester.addObjectCreate("config", LinkedList.class);
// Create servers
digester.addObjectCreate("config/server", null, "className");
digester.addSetProperties("config/server");
// Create rule
digester.addObjectCreate("config/server/rule", null, "className");
digester.addSetProperties("config/server/rule");
digester.addSetNext("config/server/rule", "setRule");
// Create composite rule
digester.addObjectCreate("config/server/composite-rule", null,
"className");
digester.addSetProperties("config/server/composite-rule");
digester.addObjectCreate("config/server/composite-rule/rule", null,
"className");
digester.addSetProperties("config/server/composite-rule/rule");
digester.addSetNext("config/server/composite-rule/rule", "addRule");
digester.addSetNext("config/server/composite-rule", "setRule");
// Add server to list
digester.addSetNext("config/server", "add");
// Create cluster servers
digester.addObjectCreate("config/cluster-server", null, "className");
digester.addSetProperties("config/cluster-server");
// Create the servers in this cluster
digester.addCallMethod("config/cluster-server/server", "addServer", 2);
digester.addCallParam("config/cluster-server/server", 0, "domainName");
digester.addCallParam("config/cluster-server/server", 1, "path");
// Create rule
digester.addObjectCreate("config/cluster-server/rule", null,
"className");
digester.addSetProperties("config/cluster-server/rule");
digester.addSetNext("config/cluster-server/rule", "setRule");
// Create composite rule
digester.addObjectCreate("config/cluster-server/composite-rule", null,
"className");
digester.addSetProperties("config/cluster-server/composite-rule");
digester.addObjectCreate("config/cluster-server/composite-rule/rule",
null, "className");
digester.addSetProperties("config/cluster-server/composite-rule/rule");
digester.addSetNext("config/cluster-server/composite-rule/rule",
"addRule");
digester.addSetNext("config/cluster-server/composite-rule", "setRule");
// Add server to list
digester.addSetNext("config/cluster-server", "add");
return (LinkedList) digester.parse(data);
}
示例11: createDigester
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
public static Digester createDigester(boolean validateXml) {
Digester digester = new Digester();
digester.setNamespaceAware(false);
digester.setUseContextClassLoader(true);
digester.setValidating(validateXml);
try {
digester.addRuleSet(new ManagedBeanRuleSet());
} catch (IncompatibleClassChangeError e) {
e.printStackTrace();
}
digester.push(new FacesConfigBean());
return digester;
}
示例12: getDigester
import org.apache.commons.digester.Digester; //導入方法依賴的package包/類
public Digester getDigester(Configuration configuration) throws SAXNotSupportedException, SAXNotRecognizedException {
Digester digester = new Digester();
digester.setUseContextClassLoader(true);
digester.push(configuration);
URL digesterRulesURL = ClassUtils.getResourceURL(this, getDigesterRules());
FromXmlRuleSet ruleSet = new FromXmlRuleSet(digesterRulesURL);
digester.addRuleSet(ruleSet);
Rule attributeChecker = new AttributeCheckingRule();
digester.addRule("*/jmsRealms", attributeChecker);
digester.addRule("*/jmsRealm", attributeChecker);
digester.addRule("*/sapSystem", attributeChecker);
digester.addRule("*/adapter", attributeChecker);
digester.addRule("*/pipeline", attributeChecker);
digester.addRule("*/errorMessageFormatter", attributeChecker);
digester.addRule("*/receiver", attributeChecker);
digester.addRule("*/sender", attributeChecker);
digester.addRule("*/listener", attributeChecker);
digester.addRule("*/postboxSender", attributeChecker);
digester.addRule("*/postboxListener", attributeChecker);
digester.addRule("*/errorSender", attributeChecker);
digester.addRule("*/messageLog", attributeChecker);
digester.addRule("*/inProcessStorage", attributeChecker);
digester.addRule("*/errorStorage", attributeChecker);
digester.addRule("*/pipe", attributeChecker);
digester.addRule("*/readerFactory", attributeChecker);
digester.addRule("*/manager", attributeChecker);
digester.addRule("*/manager/flow", attributeChecker);
digester.addRule("*/recordHandler", attributeChecker);
digester.addRule("*/resultHandler", attributeChecker);
digester.addRule("*/forward", attributeChecker);
digester.addRule("*/child", attributeChecker);
digester.addRule("*/param", attributeChecker);
digester.addRule("*/pipeline/exits/exit", attributeChecker);
digester.addRule("*/scheduler/job", attributeChecker);
digester.addRule("*/locker", attributeChecker);
digester.addRule("*/directoryCleaner", attributeChecker);
digester.addRule("*/statistics", attributeChecker);
digester.addRule("*/handler", attributeChecker);
digester.addRule("*/cache", attributeChecker);
digester.addRule("*/inputValidator", attributeChecker);
digester.addRule("*/outputValidator", attributeChecker);
digester.addRule("*/inputWrapper", attributeChecker);
digester.addRule("*/outputWrapper", attributeChecker);
if (MonitorManager.getInstance().isEnabled()) {
MonitorManager.getInstance().setDigesterRules(digester);
}
boolean validation = AppConstants.getInstance().getBoolean(CONFIGURATION_VALIDATION_KEY, false);
if (validation) {
digester.setValidating(true);
digester.setNamespaceAware(true);
digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", "AdapterFramework.xsd");
XmlErrorHandler xeh = new XmlErrorHandler();
digester.setErrorHandler(xeh);
}
return digester;
}