001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.core.joran.replay; 015 016import java.util.List; 017 018import ch.qos.logback.core.joran.GenericConfigurator; 019import ch.qos.logback.core.joran.action.NOPAction; 020import ch.qos.logback.core.joran.action.NestedBasicPropertyIA; 021import ch.qos.logback.core.joran.action.NestedComplexPropertyIA; 022import ch.qos.logback.core.joran.event.SaxEvent; 023import ch.qos.logback.core.joran.spi.ElementSelector; 024import ch.qos.logback.core.joran.spi.EventPlayer; 025import ch.qos.logback.core.joran.spi.Interpreter; 026import ch.qos.logback.core.joran.spi.JoranException; 027import ch.qos.logback.core.joran.spi.RuleStore; 028 029public class FruitConfigurator extends GenericConfigurator { 030 031 FruitFactory ff; 032 033 public FruitConfigurator(FruitFactory ff) { 034 this.ff = ff; 035 } 036 037 @Override 038 final public void doConfigure(final List<SaxEvent> eventList) throws JoranException { 039 buildInterpreter(); 040 interpreter.getInterpretationContext().pushObject(ff); 041 EventPlayer player = new EventPlayer(interpreter); 042 player.play(eventList); 043 } 044 045 @Override 046 protected void addImplicitRules(Interpreter interpreter) { 047 NestedComplexPropertyIA nestedIA = new NestedComplexPropertyIA(getBeanDescriptionCache()); 048 nestedIA.setContext(context); 049 interpreter.addImplicitAction(nestedIA); 050 051 NestedBasicPropertyIA nestedSimpleIA = new NestedBasicPropertyIA(getBeanDescriptionCache()); 052 nestedIA.setContext(context); 053 interpreter.addImplicitAction(nestedSimpleIA); 054 } 055 056 @Override 057 protected void addInstanceRules(RuleStore rs) { 058 rs.addRule(new ElementSelector("fruitShell"), new NOPAction()); 059 } 060 061}