1
2
3
4
5
6
7
8
9
10 package ch.qos.logback.core.joran.action.ext;
11
12
13
14 import org.xml.sax.Attributes;
15
16 import ch.qos.logback.core.joran.action.Action;
17 import ch.qos.logback.core.joran.spi.ActionException;
18 import ch.qos.logback.core.joran.spi.InterpretationContext;
19
20
21
22 public class BadEndAction extends Action {
23
24 static String EXCEPTION_TYPE = "type";
25 static final int RUNTIME_EXCEPTION = 0;
26 static final int ACTION_EXCEPTION = 1;
27
28 int type;
29
30
31 public void begin(InterpretationContext ec, String name, Attributes attributes) {
32 String exType = attributes.getValue(EXCEPTION_TYPE);
33 type = RUNTIME_EXCEPTION;
34 if("ActionException".equals(exType)) {
35 type = ACTION_EXCEPTION;
36 }
37 }
38
39 public void end(InterpretationContext ec, String name) throws ActionException {
40 switch(type) {
41 case ACTION_EXCEPTION:
42 throw new ActionException();
43 default:
44 throw new IllegalStateException("bad end");
45 }
46 }
47 }