Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 
 package ch.qos.logback.core.joran.action;
 
 
 
 
 public class AppenderAction<E> extends Action {
   Appender<E> appender;
   private boolean inError = false;

  
Instantiates an appender of the given class and sets its name. The appender thus generated is placed in the ch.qos.logback.core.joran.spi.InterpretationContext's appender bag.
 
   @SuppressWarnings("unchecked")
   public void begin(InterpretationContext ecString localName,
       Attributes attributesthrows ActionException {
     // We are just beginning, reset variables
      = null;
      = false;
 
     String className = attributes.getValue();
     if (OptionHelper.isEmpty(className)) {
       addError("Missing class name for appender. Near [" + localName
           + "] line " + getLineNumber(ec));
        = true;
       return;
     }
 
     try {
       addInfo("About to instantiate appender of type [" + className + "]");
 
        = (Appender) OptionHelper.instantiateByClassName(className,
           ch.qos.logback.core.Appender.class);
 
       .setContext();
 
       String appenderName = ec.subst(attributes.getValue());
 
       if (OptionHelper.isEmpty(appenderName)) {
         addWarn("No appender name given for appender of type " + className
             + "].");
       } else {
         .setName(appenderName);
         addInfo("Naming appender as [" + appenderName + "]");
       }
 
       // The execution context contains a bag which contains the appenders
       // created thus far.
       HashMap<StringAppenderappenderBag = (HashMapec.getObjectMap().get(
           .);
 
       // add the appender just created to the appender bag.
       appenderBag.put(appenderName);
 
       ec.pushObject();
     } catch (Exception oops) {
        = true;
       addError("Could not create an Appender of type [" + className + "].",
           oops);
       throw new ActionException(oops);
     }
   }

  
Once the children elements are also parsed, now is the time to activate the appender options.
 
   public void end(InterpretationContext ecString name) {
     if () {
       return;
     }
 
     if ( instanceof LifeCycle) {
       ((LifeCycle).start();
     }
 
     Object o = ec.peekObject();
    if (o != ) {
      addWarn("The object at the of the stack is not the appender named ["
          + .getName() + "] pushed earlier.");
    } else {
      ec.popObject();
    }
  }
New to GrepCode? Check out our FAQ X