1
2
3
4
5
6
7
8
9
10
11 package ch.qos.logback.core.joran.implicitAction;
12
13 import org.xml.sax.Attributes;
14
15 import ch.qos.logback.core.joran.action.Action;
16 import ch.qos.logback.core.joran.spi.ActionException;
17 import ch.qos.logback.core.joran.spi.InterpretationContext;
18
19 public class FruitContextAction extends Action {
20
21 private boolean inError = false;
22
23
24 @Override
25 public void begin(InterpretationContext ec, String name, Attributes attributes)
26 throws ActionException {
27
28 inError = false;
29
30 try {
31 ec.pushObject(context);
32 } catch (Exception oops) {
33 inError = true;
34 addError(
35 "Could not push context", oops);
36 throw new ActionException(oops);
37 }
38 }
39
40 @Override
41 public void end(InterpretationContext ec, String name) throws ActionException {
42 if (inError) {
43 return;
44 }
45
46 Object o = ec.peekObject();
47
48 if (o != context) {
49 addWarn(
50 "The object at the of the stack is not the context named ["
51 + context.getName() + "] pushed earlier.");
52 } else {
53 addInfo(
54 "Popping context named [" + context.getName()
55 + "] from the object stack");
56 ec.popObject();
57 }
58 }
59
60
61 }