View Javadoc
1   package ch.qos.logback.core.joran.implicitAction;
2   
3   import ch.qos.logback.core.Context;
4   import ch.qos.logback.core.model.Model;
5   import ch.qos.logback.core.model.processor.ModelHandlerBase;
6   import ch.qos.logback.core.model.processor.ModelHandlerException;
7   import ch.qos.logback.core.model.processor.ModelInterpretationContext;
8   
9   public class FruitContextModelHandler extends ModelHandlerBase {
10  
11      public FruitContextModelHandler(Context context) {
12          super(context);
13      }
14  
15      static public ModelHandlerBase makeInstance(Context context, ModelInterpretationContext ic) {
16          return new FruitContextModelHandler(context);
17      }
18  
19      @Override
20      public void handle(ModelInterpretationContext interpretationContext, Model model) throws ModelHandlerException {
21          interpretationContext.pushObject(context);
22      }
23  
24      @Override
25      public void postHandle(ModelInterpretationContext ec, Model model) throws ModelHandlerException {
26  
27          Object o = ec.peekObject();
28  
29          if (o != context) {
30              addWarn("The object [" + o + "] at top of the stack is not the context named [" + context.getName()
31                      + "] pushed earlier.");
32          } else {
33              addInfo("Popping context named [" + context.getName() + "] from the object stack");
34              ec.popObject();
35          }
36      }
37  
38  }