1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 1999-2006, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  
11  package ch.qos.logback.core.joran.action.ext;
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  
20  
21  public class BadBeginAction extends Action {
22  
23  
24    static String EXCEPTION_TYPE = "type";
25    static final int RUNTIME_EDXCEPTION = 0;
26    static final int ACTION_EXCEPTION = 1;
27    
28    int type;
29    
30    public BadBeginAction() {
31    }
32  
33    public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException {
34      
35      String exType = attributes.getValue(EXCEPTION_TYPE);
36      type = RUNTIME_EDXCEPTION;
37      if("ActionException".equals(exType)) {
38        type = ACTION_EXCEPTION;
39      }
40      
41      switch(type) {
42      case ACTION_EXCEPTION: 
43        throw new ActionException();
44      default:
45        throw new IllegalStateException("bad begin");
46      }
47     
48    }
49  
50    public void end(InterpretationContext ec, String name) {
51    }
52  }