/** Invoked when rule is added to digester. */ @Override public void setDigester(Digester digester) { super.setDigester(digester); log = digester.getLogger(); }
/** * Get the Log object associated with the specified Digester instance, * or a "no-op" logging object if the digester reference is null. * <p> * You should use this method instead of digester.getLogger() in * any situation where the digester might be null. */ static Log getLogger(Digester digester) { if (digester == null) { return new org.apache.commons.logging.impl.NoOpLog(); } return digester.getLogger(); } }
/** * Just add a SetPropertiesRule at the specified path. */ @Override public void addRules(Digester digester, String path) { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) { log.debug( "LoaderSetProperties loading rules for plugin at path [" + path + "]"); } digester.addSetProperties(path); } }
/** * Just invoke the target method. */ @Override public void addRules(Digester d, String path) throws PluginException { Log log = d.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) { log.debug( "LoaderFromClass loading rules for plugin at path [" + path + "]"); } try { Object[] params = {d, path}; rulesMethod.invoke(null, params); } catch (Exception e) { throw new PluginException( "Unable to invoke rules method " + rulesMethod + " on rules class " + rulesClass, e); } }
/** * Add the rules previously loaded from the input stream into the * specified digester. */ @Override public void addRules(Digester d, String path) throws PluginException { Log log = d.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) { log.debug( "LoaderFromStream: loading rules for plugin at path [" + path + "]"); } // Note that this input-source doesn't have any idea of its // system id, so it has no way of resolving relative URLs // such as the "include" feature of xmlrules. This is ok, // because that doesn't work well with our approach of // caching the input data in memory anyway. InputSource source = new InputSource(new ByteArrayInputStream(input)); FromXmlRuleSet ruleSet = new FromXmlRuleSet(source); ruleSet.addRuleInstances(d, path); } }
/** * Duplicate the processing that the Digester does when firing the * body methods of rules. It would be really nice if the Digester * class provided a way for this functionality to just be invoked * directly. */ private void fireBodyMethods(List<Rule> rules, String namespaceURI, String name, String text) throws Exception { if ((rules != null) && (rules.size() > 0)) { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); for (int i = 0; i < rules.size(); i++) { try { Rule rule = rules.get(i); if (debug) { log.debug(" Fire body() for " + rule); } rule.body(namespaceURI, name, text); } catch (Exception e) { throw digester.createSAXException(e); } catch (Error e) { throw e; } } } }
/** * Duplicate the processing that the Digester does when firing the * begin methods of rules. It would be really nice if the Digester * class provided a way for this functionality to just be invoked * directly. */ public void fireBeginMethods(List<Rule> rules, String namespace, String name, org.xml.sax.Attributes list) throws java.lang.Exception { if ((rules != null) && (rules.size() > 0)) { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); for (int i = 0; i < rules.size(); i++) { try { Rule rule = rules.get(i); if (debug) { log.debug(" Fire begin() for " + rule); } rule.begin(namespace, name, list); } catch (Exception e) { throw digester.createSAXException(e); } catch (Error e) { throw e; } } } }
Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); for (int i = 0; i < rules.size(); i++) {
/** * Set the associated digester. * If needed, this class loads the parameter classes from their names. */ @Override public void setDigester(Digester digester) { // call superclass super.setDigester(digester); // if necessary, load parameter classes if (this.paramClassNames != null) { this.paramTypes = new Class[paramClassNames.length]; for (int i = 0; i < this.paramClassNames.length; i++) { try { this.paramTypes[i] = digester.getClassLoader().loadClass(this.paramClassNames[i]); } catch (ClassNotFoundException e) { // use the digester log digester.getLogger().error("(CallMethodRule) Cannot load class " + this.paramClassNames[i], e); this.paramTypes[i] = null; // Will cause NPE later } } } }
/** * Attempt to load custom rules for the target class at the specified * pattern. * <p> * On return, any custom rules associated with the plugin class have * been loaded into the Rules object currently associated with the * specified digester object. */ public void configure(Digester digester, String pattern) throws PluginException { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) { log.debug("configure being called!"); } if (!initialized) { throw new PluginAssertionFailure("Not initialized."); } if (ruleLoader != null) { ruleLoader.addRules(digester, pattern); } } }
Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) {
org.xml.sax.Attributes attributes) throws java.lang.Exception { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) {
/** Invoked when rule is added to digester. */ public void setDigester(Digester digester) { super.setDigester(digester); log = digester.getLogger(); }
/** * Just add a SetPropertiesRule at the specified path. */ public void addRules(Digester digester, String path) { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) { log.debug( "LoaderSetProperties loading rules for plugin at path [" + path + "]"); } digester.addSetProperties(path); } }
/** * Get the Log object associated with the specified Digester instance, * or a "no-op" logging object if the digester reference is null. * <p> * You should use this method instead of digester.getLogger() in * any situation where the digester might be null. */ static Log getLogger(Digester digester) { if (digester == null) { return new org.apache.commons.logging.impl.NoOpLog(); } return digester.getLogger(); } }
@Override public void end (String namespace, String name) throws Exception { // identify the objects to be used Object child = digester.peek(0); Object parent = digester.peek(1); Class<?> pclass = parent.getClass(); if (digester.getLogger().isDebugEnabled()) { digester.getLogger().debug("Set " + pclass.getName() + "." + _fieldName + " = " + child); } // stuff the child object into the field of the parent Field field = pclass.getField(_fieldName); field.set(parent, child); }
/** * 结束处理, 弹出最近的context * * @throws Exception 如果失败 */ @Override public void end(String namespace, String name) throws Exception { ContextSensitiveRules rules = (ContextSensitiveRules) digester.getRules(); String context = rules.popContext(); if (context != null) { if (digester.getLogger().isDebugEnabled()) { digester.getLogger().debug("[SetContextRule]{" + digester.getMatch() + "} Pop " + context); } } }
@Override public void end (String namespace, String name) throws Exception { Object top = digester.peek(); if (digester.getLogger().isDebugEnabled()) { digester.getLogger().debug( "CallSpecial " + StringUtil.shortClassName(this) + ".parseAndSet(" + StringUtil.shortClassName(top) + ")"); } parseAndSet(_bodyText, top); }
public Object createObject(Attributes attributes) { // Identify the name of the class to instantiate String className = attributes.getValue("className"); if (className == null) { ModuleConfig mc = (ModuleConfig) digester.peek(); className = mc.getActionMappingClass(); } // Instantiate the new object and return it Object actionMapping = null; try { actionMapping = RequestUtils.applicationInstance(className, cl); } catch (Exception e) { digester.getLogger().error("ActionMappingFactory.createObject: ", e); } return actionMapping; } }
public Object createObject(Attributes attributes) { // Identify the name of the class to instantiate String className = attributes.getValue("className"); if (className == null) { ModuleConfig mc = (ModuleConfig) digester.peek(1); className = mc.getActionForwardClass(); } // Instantiate the new object and return it Object actionForward = null; try { actionForward = RequestUtils.applicationInstance(className, cl); } catch (Exception e) { digester.getLogger().error("ActionForwardFactory.createObject: ", e); } return actionForward; } }