View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.core.joran.replay;
15  
16  import java.util.List;
17  
18  import ch.qos.logback.core.joran.GenericConfigurator;
19  import ch.qos.logback.core.joran.action.NOPAction;
20  import ch.qos.logback.core.joran.action.NestedBasicPropertyIA;
21  import ch.qos.logback.core.joran.action.NestedComplexPropertyIA;
22  import ch.qos.logback.core.joran.event.SaxEvent;
23  import ch.qos.logback.core.joran.spi.ElementSelector;
24  import ch.qos.logback.core.joran.spi.EventPlayer;
25  import ch.qos.logback.core.joran.spi.Interpreter;
26  import ch.qos.logback.core.joran.spi.JoranException;
27  import ch.qos.logback.core.joran.spi.RuleStore;
28  
29  public class FruitConfigurator extends GenericConfigurator {
30  
31      FruitFactory ff;
32  
33      public FruitConfigurator(FruitFactory ff) {
34          this.ff = ff;
35      }
36  
37      @Override
38      final public void doConfigure(final List<SaxEvent> eventList) throws JoranException {
39          buildInterpreter();
40          interpreter.getInterpretationContext().pushObject(ff);
41          EventPlayer player = new EventPlayer(interpreter);
42          player.play(eventList);
43      }
44  
45      @Override
46      protected void addImplicitRules(Interpreter interpreter) {
47          NestedComplexPropertyIA nestedIA = new NestedComplexPropertyIA(getBeanDescriptionCache());
48          nestedIA.setContext(context);
49          interpreter.addImplicitAction(nestedIA);
50  
51          NestedBasicPropertyIA nestedSimpleIA = new NestedBasicPropertyIA(getBeanDescriptionCache());
52          nestedIA.setContext(context);
53          interpreter.addImplicitAction(nestedSimpleIA);
54      }
55  
56      @Override
57      protected void addInstanceRules(RuleStore rs) {
58          rs.addRule(new ElementSelector("fruitShell"), new NOPAction());
59      }
60  
61  }