本文整理汇总了Java中org.apache.commons.digester.Digester.push方法的典型用法代码示例。如果您正苦于以下问题:Java Digester.push方法的具体用法?Java Digester.push怎么用?Java Digester.push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.digester.Digester
的用法示例。
在下文中一共展示了Digester.push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseConfig
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
private void parseConfig(String publicId, String entityURL,
String strutsConfig) {
// Prepare a Digester for parsing a struts-config.xml file
Digester digester = new Digester();
digester.push(config);
digester.setNamespaceAware(true);
digester.setValidating(true);
digester.addRuleSet(new ConfigRuleSet());
digester.register(publicId,
this.getClass().getResource(entityURL).toString());
// Parse the test struts-config.xml file
try {
InputStream input =
this.getClass().getResourceAsStream(strutsConfig);
assertNotNull("Got an input stream for " + strutsConfig, input);
digester.parse(input);
input.close();
} catch (Throwable t) {
t.printStackTrace(System.out);
fail("Parsing threw exception: " + t);
}
}
示例2: ValidatorResources
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
* Create a ValidatorResources object from an InputStream.
*
* @param streams An array of InputStreams to several validation.xml
* configuration files that will be read in order and merged into this object.
* It's the client's responsibility to close these streams.
* @throws SAXException if the validation XML files are not valid or well
* formed.
* @throws IOException if an I/O error occurs processing the XML files
* @since Validator 1.1
*/
public ValidatorResources(InputStream[] streams)
throws IOException, SAXException {
super();
Digester digester = initDigester();
for (int i = 0; i < streams.length; i++) {
if (streams[i] == null) {
throw new IllegalArgumentException("Stream[" + i + "] is null");
}
digester.push(this);
digester.parse(streams[i]);
}
this.process();
}
示例3: parseURL
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
private void parseURL(URL u) {
Digester d = new Digester();
d.setValidating(false);
d.push(this);
d.addObjectCreate("factory/template", HashMap.class);
d.addRule("factory/template", new AttributeCopyRule());
d.addSetNext("factory/template", "addFactoryTemplate");
try {
d.parse(u.openStream());
}
catch (Exception e) {
throw new ManifestFactoryParseException("Unable to parse " +
builder.getManifestFilename(), e);
}
}
示例4: load
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
* Load the contents of our configuration file.
*/
protected void load() {
// Validate the existence of our configuration file
File file = new File(pathname);
if (!file.isAbsolute())
file = new File(System.getProperty("catalina.base"), pathname);
if (!file.exists() || !file.canRead()) {
log("Cannot load configuration file " + file.getAbsolutePath());
return;
}
// Load the contents of our configuration file
Digester digester = new Digester();
digester.setValidating(false);
digester.addRuleSet(new MemoryRuleSet());
try {
digester.push(this);
digester.parse(file);
} catch (Exception e) {
log("Error processing configuration file " +
file.getAbsolutePath(), e);
return;
}
}
示例5: parseXML
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public static GoPluginDescriptor parseXML(InputStream pluginXML, String pluginJarFileLocation, File pluginBundleLocation, boolean isBundledPlugin) throws IOException, SAXException {
Digester digester = initDigester();
GoPluginDescriptorParser parserForThisXML = new GoPluginDescriptorParser(pluginJarFileLocation, pluginBundleLocation, isBundledPlugin);
digester.push(parserForThisXML);
digester.addCallMethod("go-plugin", "createPlugin", 2);
digester.addCallParam("go-plugin", 0, "id");
digester.addCallParam("go-plugin", 1, "version");
digester.addCallMethod("go-plugin/about", "createAbout", 4);
digester.addCallParam("go-plugin/about/name", 0);
digester.addCallParam("go-plugin/about/version", 1);
digester.addCallParam("go-plugin/about/target-go-version", 2);
digester.addCallParam("go-plugin/about/description", 3);
digester.addCallMethod("go-plugin/about/vendor", "createVendor", 2);
digester.addCallParam("go-plugin/about/vendor/name", 0);
digester.addCallParam("go-plugin/about/vendor/url", 1);
digester.addCallMethod("go-plugin/about/target-os/value", "addTargetOS", 1);
digester.addCallParam("go-plugin/about/target-os/value", 0);
digester.parse(pluginXML);
return parserForThisXML.descriptor;
}
示例6: xml2Object
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public void xml2Object() throws SAXException
{
Digester digester = new Digester();
digester.push(this);
digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
digester.addCallParam("datasources/datasource/name", 0);
digester.addCallParam("datasources/datasource/driver", 1);
digester.addCallParam("datasources/datasource/url", 2);
digester.addCallParam("datasources/datasource/username", 3);
digester.addCallParam("datasources/datasource/password", 4);
try{
//java.io.InputStream xmlFile = getClass().getResourceAsStream("xml/datasource.xml");
java.io.InputStream xmlFile
= new java.io.FileInputStream(gafetes.util.VariablesAmbiente.getArchivoDBConfiguracion());
digester.parse(xmlFile);
}catch( java.io.IOException ioex ){
System.out.println();
}
}
示例7: xmlConfiguration2Object
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public void xmlConfiguration2Object() throws SAXException
{
Digester digester = new Digester();
digester.push(this);
digester.addCallMethod("datasources/datasource", "addDataConfigurationSource", 4 );
digester.addCallParam("datasources/datasource/rutaFotos", 0);
digester.addCallParam("datasources/datasource/rutaCarpetaFotos", 1);
digester.addCallParam("datasources/datasource/rutaFotoNoExiste", 2);
digester.addCallParam("datasources/datasource/passPhrase", 3);
try{
//java.io.InputStream xmlFile = getClass().getResourceAsStream("xml/datasource.xml");
java.io.InputStream xmlFile
= new java.io.FileInputStream(gafetes.util.VariablesAmbiente.getArchivoConfiguracion());
digester.parse(xmlFile);
}catch( java.io.IOException ioex ){
System.out.println();
}
}
示例8: createObject
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public Object createObject(
Attributes attributes) throws Exception
{
String href = attributes.getValue("href");
if (href == null)
throw new IllegalStateException("Missing href attribute");
URL master = (URL)digester.getRoot();
URL included = new URL(master, href);
Digester includedDigester = createEmptyDigester();
addDigesterRules(includedDigester);
includedDigester.push(included);
includedDigester.push(digester.peek());
URLConnection conn = included.openConnection();
InputStream is = conn.getInputStream();
includedDigester.parse(is);
is.close();
// We don't really want the included object - but return it anyway
return included;
}
示例9: 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();
}
示例10: parseXML
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public static void parseXML() {
Digester digester = new Digester();
digester.push(_instance); // Push controller servlet onto the stack
digester.setValidating(false);
digester.addObjectCreate("eformap-config/databaseap",DatabaseAP.class);
//digester.addSetProperties("eformap-config/databaseap");
digester.addBeanPropertySetter("eformap-config/databaseap/ap-name","apName");
digester.addBeanPropertySetter("eformap-config/databaseap/ap-sql","apSQL");
digester.addBeanPropertySetter("eformap-config/databaseap/ap-output","apOutput");
digester.addBeanPropertySetter("eformap-config/databaseap/ap-insql", "apInSQL");
digester.addBeanPropertySetter("eformap-config/databaseap/archive", "archive");
digester.addBeanPropertySetter("eformap-config/databaseap/ap-json-output", "apJsonOutput");
digester.addSetNext("eformap-config/databaseap","addDatabaseAP");
try {
Properties op = oscar.OscarProperties.getInstance();
String configpath = op.getProperty("eform_databaseap_config");
InputStream fs = null;
if (configpath == null) {
EFormLoader eLoader = new EFormLoader();
ClassLoader loader = eLoader.getClass().getClassLoader();
fs = loader.getResourceAsStream("/oscar/eform/apconfig.xml");
}else{
fs = new FileInputStream(configpath);
}
digester.parse(fs);
fs.close();
} catch (Exception e) { MiscUtils.getLogger().error("Error", e); }
}
示例11: initModuleConfig
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
* <p>Initialize the module configuration information for the specified
* module.</p>
*
* @param prefix Module prefix for this module
* @param paths Comma-separated list of context-relative resource path(s)
* for this modules's configuration resource(s)
* @return The new module configuration instance.
* @throws ServletException if initialization cannot be performed
* @since Struts 1.1
*/
protected ModuleConfig initModuleConfig(String prefix, String paths)
throws ServletException {
if (log.isDebugEnabled()) {
log.debug("Initializing module path '" + prefix
+ "' configuration from '" + paths + "'");
}
// Parse the configuration for this module
ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
ModuleConfig config = factoryObject.createModuleConfig(prefix);
// Configure the Digester instance we will use
Digester digester = initConfigDigester();
List urls = splitAndResolvePaths(paths);
URL url;
for (Iterator i = urls.iterator(); i.hasNext();) {
url = (URL) i.next();
digester.push(config);
this.parseModuleConfigFile(digester, url);
}
getServletContext().setAttribute(Globals.MODULE_KEY
+ config.getPrefix(), config);
return config;
}
示例12: processStandardFacesConfig
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
private static void processStandardFacesConfig(
DesignerProject designerProject, Digester digester,
FacesConfigBean fcb) {
IFile config = designerProject.getProject().getFile(FACESCONFIG_PATH);
if (!config.exists()) {
if (logger.isInfoEnabled()) {
logger.info("faces-config.xml not found for project {0}",
designerProject.getProject().getName());
}
return;
}
digester.clear();
digester.push(fcb);
try {
digester.parse(config.getContents(false));
} catch (Exception e) {
if (logger.isErrorEnabled()) {
logger.error(e,
"Error Parsing Standard faces config for project {0}",
designerProject.getProject().getName());
}
}
}
示例13: StemmerFactory
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
private StemmerFactory() {
initParams = new Properties();
try {
Digester digester = new Digester();
digester.push(this);
digester.addCallMethod("jsre-config/stemmer-list/stemmer",
"addStemmer", 2);
digester.addCallParam(
"jsre-config/stemmer-list/stemmer/stemmer-name", 0);
digester.addCallParam(
"jsre-config/stemmer-list/stemmer/stemmer-class", 1);
String configFile = System.getProperty("config.file");
if (configFile == null) {
logger.debug("StemmerFactory uses the default config file: jsre-config.xml");
checkFileExists(JSRE_HOME + RESOURCES_PATH + "jsre-config.xml");
digester.parse(JSRE_HOME + RESOURCES_PATH + "jsre-config.xml");
} else {
logger.debug("StemmerFactory uses the config file: "
+ configFile);
digester.parse(configFile);
}
} catch (Exception e) {
logger.error("", e);
}
}
示例14: start
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
* Prepare for active use of the public methods of this Component.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents it from being started
*/
public synchronized void start() throws LifecycleException {
// Validate the existence of our database file
File file = new File(pathname);
if (!file.isAbsolute())
file = new File(System.getProperty("catalina.base"), pathname);
if (!file.exists() || !file.canRead())
throw new LifecycleException
(sm.getString("memoryRealm.loadExist",
file.getAbsolutePath()));
// Load the contents of the database file
if (debug >= 1)
log(sm.getString("memoryRealm.loadPath",
file.getAbsolutePath()));
Digester digester = getDigester();
try {
synchronized (digester) {
digester.push(this);
digester.parse(file);
}
} catch (Exception e) {
throw new LifecycleException("memoryRealm.readXml", e);
}
// Perform normal superclass initialization
super.start();
}
示例15: read
import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
synchronized Map<String, IAdapter> read(URL url) throws IOException, SAXException, InterruptedException {
try {
AdapterService catcher = new AdapterServiceImpl();
Configuration configuration = new Configuration(catcher);
ConfigurationDigester configurationDigester = new ConfigurationDigester();
Digester digester = configurationDigester.getDigester(configuration);
digester.push(catcher);
digester.parse(url.openStream());
// Does'nt work. I probably don't know how it is supposed to work.
return catcher.getAdapters();
} catch (Throwable t) {
LOG.error("For " + url + ": " + t.getMessage(), t);
return null;
}
}