Java Code Examples for org.apache.commons.digester.Digester#getLogger()

The following examples show how to use org.apache.commons.digester.Digester#getLogger() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoaderFromClass.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    } 
}
 
Example 2
Source File: LoaderFromStream.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: Declaration.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 4
Source File: LoaderSetProperties.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: LogUtils.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 6
Source File: Declaration.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Must be called exactly once, and must be called before any call
 * to the configure method.
 */
public void init(Digester digester, PluginManager pm) throws PluginException {
    Log log = digester.getLogger();
    boolean debug = log.isDebugEnabled();
    if (debug) {
        log.debug("init being called!");
    }
    
    if (initialized) {
        throw new PluginAssertionFailure("Init called multiple times.");
    }

    if ((pluginClass == null) && (pluginClassName != null)) {
        try {
            // load the plugin class object
            pluginClass = 
                digester.getClassLoader().loadClass(pluginClassName);
        } catch(ClassNotFoundException cnfe) {
            throw new PluginException(
                "Unable to load class " + pluginClassName, cnfe);
        }
    }

    if (ruleLoader == null) {
        // the caller didn't provide a ruleLoader to the constructor,
        // so get the plugin manager to "discover" one.
        log.debug("Searching for ruleloader...");
        ruleLoader = pm.findLoader(digester, id, pluginClass, properties);
    } else {
        log.debug("This declaration has an explicit ruleLoader.");
    }
    
    if (debug) {
        if (ruleLoader == null) {
            log.debug(
                "No ruleLoader found for plugin declaration"
                + " id [" + id + "]"
                + ", class [" + pluginClass.getClass().getName() + "].");
        } else {
            log.debug(
                "RuleLoader of type [" + ruleLoader.getClass().getName()
                + "] associated with plugin declaration"
                + " id [" + id + "]"
                + ", class [" + pluginClass.getClass().getName() + "].");
        }
    }
    
    initialized = true;        
}