svn commit: r709 - in logback/trunk: logback-classic/src/main/java/ch/qos/logback/classic logback-classic/src/main/java/ch/qos/logback/classic/util logback-core/src/main/java/ch/qos/logback/core/joran logback-core/src/main/java/ch/qos/logback/core/joran/action logback-core/src/main/java/ch/qos/logback/core/joran/event logback-core/src/main/java/ch/qos/logback/core/joran/spi logback-core/src/test/java/ch/qos/logback/core logback-core/src/test/java/ch/qos/logback/core/joran logback-core/src/test

Author: ceki Date: Wed Oct 18 16:22:03 2006 New Revision: 709 Added: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java - copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/BodyEvent.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java - copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EndEvent.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java - copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEvent.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java - copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEventRecorder.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java - copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/StartEvent.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java - copied, changed from r706, /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/EventRecorderTest.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java Removed: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/BodyEvent.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EndEvent.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEvent.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEventRecorder.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/StartEvent.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/EventRecorderTest.java Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java Log: Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java ============================================================================== --- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java (original) +++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java Wed Oct 18 16:22:03 2006 @@ -1,11 +1,11 @@ /** - * LOGBack: the reliable, fast and flexible logging library for Java. - * - * Copyright (C) 1999-2005, QOS.ch, LOGBack.com - * - * This library is free software, you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation. + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. */ package ch.qos.logback.classic; @@ -25,19 +25,20 @@ import ch.qos.logback.core.spi.AppenderAttachable; import ch.qos.logback.core.spi.AppenderAttachableImpl; - -public final class Logger implements org.slf4j.Logger, AppenderAttachable, Serializable { +public final class Logger implements org.slf4j.Logger, AppenderAttachable, + Serializable { /** - * - */ - private static final long serialVersionUID = 5454405123156820674L; + * + */ + private static final long serialVersionUID = 5454405123156820674L; - /** + /** * The fully qualified name of this class. Used in gathering caller * information. */ - public static final String FQCN = ch.qos.logback.classic.Logger.class.getName(); + public static final String FQCN = ch.qos.logback.classic.Logger.class + .getName(); static int instanceCount = 0; @@ -79,7 +80,7 @@ // loggerRemoteView cannot be final because it may change as a consequence // of changes in LoggerContext LoggerRemoteView loggerRemoteView; - + Logger(String name, Logger parent, LoggerContext loggerContext) { this.name = name; this.parent = parent; @@ -275,7 +276,7 @@ // No appenders in hierarchy if (writes == 0) { - loggerContext.noAppenderDefinedWarning(this); + loggerContext.noAppenderDefinedWarning(this); } } @@ -363,10 +364,9 @@ } /** - * The next three methods could be merged. - * However, we decided not to merge them to make the calls to - * these methods more easily understandable, avoiding many instances - * of passing null parameters. + * The next three methods could be merged. However, we decided not to merge + * them to make the calls to these methods more easily understandable, + * avoiding many instances of passing null parameters. */ private void filterAndLog(String caller, Level level, String format, Throwable t) { @@ -401,19 +401,19 @@ public void debug(String format, Object arg) { if (isDebugEnabled()) { - filterAndLog(FQCN, Level.DEBUG, format, new Object[] {arg}, null); + filterAndLog(FQCN, Level.DEBUG, format, new Object[] { arg }, null); } } public void debug(String format, Object arg1, Object arg2) { if (isDebugEnabled()) { - filterAndLog(FQCN, Level.DEBUG, format, new Object[] {arg1, arg2}, null); + filterAndLog(FQCN, Level.DEBUG, format, new Object[] { arg1, arg2 }, null); } } public void debug(String format, Object[] argArray) { if (isDebugEnabled()) { - filterAndLog(FQCN, Level.DEBUG, format, new Object[] {argArray}, null); + filterAndLog(FQCN, Level.DEBUG, format, new Object[] { argArray }, null); } } @@ -431,21 +431,22 @@ public void debug(Marker marker, String format, Object arg) { if (isDebugEnabled()) { - filterAndLog(FQCN, Level.DEBUG, marker, format, new Object[] {arg}, null); + filterAndLog(FQCN, Level.DEBUG, marker, format, new Object[] { arg }, + null); } } public void debug(Marker marker, String format, Object arg1, Object arg2) { if (isDebugEnabled()) { filterAndLog(FQCN, Level.DEBUG, marker, format, - new Object[] {arg1, arg2}, null); + new Object[] { arg1, arg2 }, null); } } public void debug(Marker marker, String format, Object[] argArray) { if (isDebugEnabled()) { - filterAndLog(FQCN, Level.DEBUG, marker, format, new Object[] {argArray}, - null); + filterAndLog(FQCN, Level.DEBUG, marker, format, + new Object[] { argArray }, null); } } @@ -463,19 +464,19 @@ public void error(String format, Object arg) { if (isErrorEnabled()) { - filterAndLog(FQCN, Level.ERROR, format, new Object[] {arg}, null); + filterAndLog(FQCN, Level.ERROR, format, new Object[] { arg }, null); } } public void error(String format, Object arg1, Object arg2) { if (isErrorEnabled()) { - filterAndLog(FQCN, Level.ERROR, format, new Object[] {arg1, arg2}, null); + filterAndLog(FQCN, Level.ERROR, format, new Object[] { arg1, arg2 }, null); } } public void error(String format, Object[] argArray) { if (isErrorEnabled()) { - filterAndLog(FQCN, Level.ERROR, format, new Object[] {argArray}, null); + filterAndLog(FQCN, Level.ERROR, format, new Object[] { argArray }, null); } } @@ -493,21 +494,22 @@ public void error(Marker marker, String format, Object arg) { if (isErrorEnabled()) { - filterAndLog(FQCN, Level.ERROR, marker, format, new Object[] {arg}, null); + filterAndLog(FQCN, Level.ERROR, marker, format, new Object[] { arg }, + null); } } public void error(Marker marker, String format, Object arg1, Object arg2) { if (isErrorEnabled()) { filterAndLog(FQCN, Level.ERROR, marker, format, - new Object[] {arg1, arg2}, null); + new Object[] { arg1, arg2 }, null); } } public void error(Marker marker, String format, Object[] argArray) { if (isErrorEnabled()) { - filterAndLog(FQCN, Level.ERROR, marker, format, new Object[] {argArray}, - null); + filterAndLog(FQCN, Level.ERROR, marker, format, + new Object[] { argArray }, null); } } @@ -525,19 +527,19 @@ public void info(String format, Object arg) { if (isInfoEnabled()) { - filterAndLog(FQCN, Level.INFO, format, new Object[] {arg}, null); + filterAndLog(FQCN, Level.INFO, format, new Object[] { arg }, null); } } public void info(String format, Object arg1, Object arg2) { if (isInfoEnabled()) { - filterAndLog(FQCN, Level.INFO, format, new Object[] {arg1, arg2}, null); + filterAndLog(FQCN, Level.INFO, format, new Object[] { arg1, arg2 }, null); } } public void info(String format, Object[] argArray) { if (isInfoEnabled()) { - filterAndLog(FQCN, Level.INFO, format, new Object[] {argArray}, null); + filterAndLog(FQCN, Level.INFO, format, new Object[] { argArray }, null); } } @@ -555,20 +557,20 @@ public void info(Marker marker, String format, Object arg) { if (isInfoEnabled()) { - filterAndLog(FQCN, Level.INFO, marker, format, new Object[] {arg}, null); + filterAndLog(FQCN, Level.INFO, marker, format, new Object[] { arg }, null); } } public void info(Marker marker, String format, Object arg1, Object arg2) { if (isInfoEnabled()) { - filterAndLog(FQCN, Level.INFO, marker, format, new Object[] {arg1, arg2}, - null); + filterAndLog(FQCN, Level.INFO, marker, format, + new Object[] { arg1, arg2 }, null); } } public void info(Marker marker, String format, Object[] argArray) { if (isInfoEnabled()) { - filterAndLog(FQCN, Level.INFO, marker, format, new Object[] {argArray}, + filterAndLog(FQCN, Level.INFO, marker, format, new Object[] { argArray }, null); } } @@ -610,9 +612,9 @@ public boolean isWarnEnabled(Marker marker) { return isWarnEnabled(); } - + public boolean isEnabledFor(Level level) { - return (effectiveLevelInt <= level.levelInt); + return (effectiveLevelInt <= level.levelInt); } public void warn(String msg) { @@ -629,19 +631,19 @@ public void warn(String format, Object arg) { if (isWarnEnabled()) { - filterAndLog(FQCN, Level.WARN, format, new Object[] {arg}, null); + filterAndLog(FQCN, Level.WARN, format, new Object[] { arg }, null); } } public void warn(String format, Object arg1, Object arg2) { if (isWarnEnabled()) { - filterAndLog(FQCN, Level.WARN, format, new Object[] {arg1, arg2}, null); + filterAndLog(FQCN, Level.WARN, format, new Object[] { arg1, arg2 }, null); } } public void warn(String format, Object[] argArray) { if (effectiveLevelInt <= Level.WARN_INT) { - filterAndLog(FQCN, Level.WARN, format, new Object[] {argArray}, null); + filterAndLog(FQCN, Level.WARN, format, new Object[] { argArray }, null); } } @@ -653,21 +655,21 @@ public void warn(Marker marker, String format, Object arg) { if (isWarnEnabled()) { - filterAndLog(FQCN, Level.WARN, marker, format, new Object[] {arg}, null); + filterAndLog(FQCN, Level.WARN, marker, format, new Object[] { arg }, null); } } public void warn(Marker marker, String format, Object[] argArray) { if (isWarnEnabled()) { - filterAndLog(FQCN, Level.WARN, marker, format, new Object[] {argArray}, + filterAndLog(FQCN, Level.WARN, marker, format, new Object[] { argArray }, null); } } public void warn(Marker marker, String format, Object arg1, Object arg2) { if (isWarnEnabled()) { - filterAndLog(FQCN, Level.WARN, marker, format, new Object[] {arg1, arg2}, - null); + filterAndLog(FQCN, Level.WARN, marker, format, + new Object[] { arg1, arg2 }, null); } } @@ -691,18 +693,18 @@ /** * Return the context for this logger. + * * @return */ - public LoggerContext getLoggerContext() { - return loggerContext; - } - - - public LoggerRemoteView getLoggerRemoteView() { - return loggerRemoteView; - } - - void buildRemoteView() { - this.loggerRemoteView = new LoggerRemoteView(name, loggerContext); - } + public LoggerContext getLoggerContext() { + return loggerContext; + } + + public LoggerRemoteView getLoggerRemoteView() { + return loggerRemoteView; + } + + void buildRemoteView() { + this.loggerRemoteView = new LoggerRemoteView(name, loggerContext); + } } Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java ============================================================================== --- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java (original) +++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java Wed Oct 18 16:22:03 2006 @@ -1,3 +1,13 @@ +/** + * Logback: the reliable, fast and flexible logging library for Java. + * + * Copyright (C) 1999-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ + package ch.qos.logback.classic.util; import org.slf4j.LoggerFactory; @@ -7,14 +17,13 @@ import ch.qos.logback.core.status.StatusManager; import ch.qos.logback.core.util.StatusPrinter; - public class LoggerStatusPrinter { - - public static void printStatusInDefaultContext() { - Logger logger = (Logger)LoggerFactory.getLogger(LoggerStatusPrinter.class); - LoggerContext lc = logger.getLoggerContext(); - StatusManager sm = lc.getStatusManager(); + + public static void printStatusInDefaultContext() { + Logger logger = (Logger) LoggerFactory.getLogger(LoggerStatusPrinter.class); + LoggerContext lc = logger.getLoggerContext(); + StatusManager sm = lc.getStatusManager(); StatusPrinter.print(sm); - } - + } + } Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java Wed Oct 18 16:22:03 2006 @@ -1,13 +1,12 @@ /** - * Logback: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework for Java. * - * Copyright (C) 1999-2006, QOS.ch + * Copyright (C) 2000-2006, QOS.ch * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation. */ - package ch.qos.logback.core.joran; import java.io.File; @@ -19,13 +18,13 @@ import org.xml.sax.InputSource; +import ch.qos.logback.core.joran.event.SaxEvent; +import ch.qos.logback.core.joran.event.SaxEventRecorder; import ch.qos.logback.core.joran.spi.EventPlayer; import ch.qos.logback.core.joran.spi.ExecutionContext; import ch.qos.logback.core.joran.spi.Interpreter; import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.joran.spi.RuleStore; -import ch.qos.logback.core.joran.spi.SaxEvent; -import ch.qos.logback.core.joran.spi.SaxEventRecorder; import ch.qos.logback.core.joran.spi.SimpleRuleStore; import ch.qos.logback.core.spi.ContextAwareBase; Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java Wed Oct 18 16:22:03 2006 @@ -1,7 +1,7 @@ /** - * Logback: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework for Java. * - * Copyright (C) 1999-2006, QOS.ch + * Copyright (C) 2000-2006, QOS.ch * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java Wed Oct 18 16:22:03 2006 @@ -1,12 +1,13 @@ /** - * LOGBack: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework for Java. * - * Copyright (C) 1999-2006, QOS.ch + * Copyright (C) 2000-2006, QOS.ch * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation. */ + package ch.qos.logback.core.joran.action; Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/BodyEvent.java) ============================================================================== --- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/BodyEvent.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java Wed Oct 18 16:22:03 2006 @@ -1,7 +1,17 @@ -package ch.qos.logback.core.joran.spi; +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ +package ch.qos.logback.core.joran.event; import org.xml.sax.Locator; + public class BodyEvent extends SaxEvent { private String text; Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EndEvent.java) ============================================================================== --- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EndEvent.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java Wed Oct 18 16:22:03 2006 @@ -1,7 +1,17 @@ -package ch.qos.logback.core.joran.spi; +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ +package ch.qos.logback.core.joran.event; import org.xml.sax.Locator; + public class EndEvent extends SaxEvent { EndEvent(String namespaceURI, String localName, String qName, Locator locator) { Added: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java ============================================================================== --- (empty file) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java Wed Oct 18 16:22:03 2006 @@ -0,0 +1,15 @@ +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ +package ch.qos.logback.core.joran.event; + + +public interface InPlayListener { + public void inPlay(SaxEvent event); +} Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEvent.java) ============================================================================== --- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEvent.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java Wed Oct 18 16:22:03 2006 @@ -1,14 +1,23 @@ -package ch.qos.logback.core.joran.spi; +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ +package ch.qos.logback.core.joran.event; import org.xml.sax.Locator; import org.xml.sax.helpers.LocatorImpl; public class SaxEvent { - final String namespaceURI; - final String localName; - final String qName; - final Locator locator; + final public String namespaceURI; + final public String localName; + final public String qName; + final public Locator locator; SaxEvent(String namespaceURI, String localName, String qName, Locator locator) { this.namespaceURI = namespaceURI; Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEventRecorder.java) ============================================================================== --- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEventRecorder.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java Wed Oct 18 16:22:03 2006 @@ -1,4 +1,14 @@ -package ch.qos.logback.core.joran.spi; +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ + +package ch.qos.logback.core.joran.event; import java.io.IOException; import java.io.InputStream; @@ -16,6 +26,8 @@ import org.xml.sax.helpers.DefaultHandler; import ch.qos.logback.core.Context; +import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.spi.ContextAware; import ch.qos.logback.core.spi.ContextAwareImpl; import ch.qos.logback.core.status.Status; Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/StartEvent.java) ============================================================================== --- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/StartEvent.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java Wed Oct 18 16:22:03 2006 @@ -1,13 +1,25 @@ -package ch.qos.logback.core.joran.spi; +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ + +package ch.qos.logback.core.joran.event; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.helpers.AttributesImpl; +import ch.qos.logback.core.joran.spi.Pattern; + public class StartEvent extends SaxEvent { - final Attributes attributes; - final Pattern pattern; + final public Attributes attributes; + final public Pattern pattern; StartEvent(Pattern pattern, String namespaceURI, String localName, String qName, Attributes attributes, Locator locator) { Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java Wed Oct 18 16:22:03 2006 @@ -1,7 +1,7 @@ /** - * LOGBack: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework for Java. * - * Copyright (C) 1999-2006, QOS.ch + * Copyright (C) 2000-2006, QOS.ch * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java Wed Oct 18 16:22:03 2006 @@ -1,7 +1,21 @@ +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ package ch.qos.logback.core.joran.spi; import java.util.List; +import ch.qos.logback.core.joran.event.BodyEvent; +import ch.qos.logback.core.joran.event.EndEvent; +import ch.qos.logback.core.joran.event.SaxEvent; +import ch.qos.logback.core.joran.event.StartEvent; + public class EventPlayer { final Interpreter interpreter; @@ -11,16 +25,24 @@ } public void play(List<SaxEvent> seList) { + for(SaxEvent se : seList) { if(se instanceof StartEvent) { + // invoke fireInPlay before startElement processing + interpreter.getExecutionContext().fireInPlay(se); interpreter.startElement((StartEvent) se); } if(se instanceof BodyEvent) { + // invoke fireInPlay before characters processing + interpreter.getExecutionContext().fireInPlay(se); interpreter.characters((BodyEvent) se); } if(se instanceof EndEvent) { interpreter.endElement((EndEvent) se); + // invoke fireInPlay after endElement processing + interpreter.getExecutionContext().fireInPlay(se); } + } } } Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java Wed Oct 18 16:22:03 2006 @@ -1,7 +1,7 @@ /** - * LOGBack: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework for Java. * - * Copyright (C) 1999-2006, QOS.ch + * Copyright (C) 2000-2006, QOS.ch * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -9,8 +9,10 @@ */ package ch.qos.logback.core.joran.spi; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Stack; @@ -18,6 +20,8 @@ import org.xml.sax.Locator; import ch.qos.logback.core.joran.action.Action; +import ch.qos.logback.core.joran.event.InPlayListener; +import ch.qos.logback.core.joran.event.SaxEvent; import ch.qos.logback.core.spi.ContextAwareBase; import ch.qos.logback.core.status.ErrorStatus; import ch.qos.logback.core.status.InfoStatus; @@ -38,7 +42,8 @@ Map<String, Object> objectMap; Properties substitutionProperties; Interpreter joranInterpreter; - + final List<InPlayListener> listenerList = new ArrayList<InPlayListener>(); + public ExecutionContext(Interpreter joranInterpreter) { this.joranInterpreter = joranInterpreter; objectStack = new Stack<Object> (); @@ -165,4 +170,22 @@ } return OptionHelper.substVars(value, substitutionProperties); } + + public void addInPlayListener(InPlayListener ipl) { + if(listenerList.contains(ipl)) { + System.out.println("InPlayListener "+ipl+" has been already registered"); + } else { + listenerList.add(ipl); + } + } + + public boolean removeInPlayListener(InPlayListener ipl) { + return listenerList.remove(ipl); + } + + void fireInPlay(SaxEvent event) { + for(InPlayListener ipl: listenerList) { + ipl.inPlay(event); + } + } } Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java ============================================================================== --- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java (original) +++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java Wed Oct 18 16:22:03 2006 @@ -1,13 +1,12 @@ /** - * LOGBack: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework for Java. * - * Copyright (C) 1999-2006, QOS.ch + * Copyright (C) 2000-2006, QOS.ch * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation. */ - package ch.qos.logback.core.joran.spi; import java.util.ArrayList; @@ -21,6 +20,9 @@ import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.action.ImplicitAction; +import ch.qos.logback.core.joran.event.BodyEvent; +import ch.qos.logback.core.joran.event.EndEvent; +import ch.qos.logback.core.joran.event.StartEvent; /** * <id>Interpreter</id> is Joran's main driving class. It extends SAX @@ -57,9 +59,10 @@ */ public class Interpreter { private static List EMPTY_LIST = new Vector(0); - private RuleStore ruleStore; - private ExecutionContext ec; - private ArrayList<ImplicitAction> implicitActions; + + final private RuleStore ruleStore; + final private ExecutionContext ec; + final private ArrayList<ImplicitAction> implicitActions; Pattern pattern; Locator locator; @@ -321,10 +324,4 @@ public RuleStore getRuleStore() { return ruleStore; } - - public void setRuleStore(RuleStore ruleStore) { - this.ruleStore = ruleStore; - } - - } Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java ============================================================================== --- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java (original) +++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java Wed Oct 18 16:22:03 2006 @@ -1,3 +1,12 @@ +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ package ch.qos.logback.core; import junit.framework.Test; Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java ============================================================================== --- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java (original) +++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java Wed Oct 18 16:22:03 2006 @@ -1,13 +1,12 @@ /** - * Logback: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework for Java. * - * Copyright (C) 1999-2006, QOS.ch + * Copyright (C) 2000-2006, QOS.ch * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation. */ - package ch.qos.logback.core.joran; import junit.framework.Test; @@ -19,8 +18,8 @@ public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SkippingInInterpreterTest.class); - suite.addTestSuite(EventRecorderTest.class); suite.addTestSuite(TrivialcConfiguratorTest.class); + suite.addTest(ch.qos.logback.core.joran.event.PackageTest.suite()); suite.addTest(ch.qos.logback.core.joran.spi.PackageTest.suite()); return suite; } Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java ============================================================================== --- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java (original) +++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java Wed Oct 18 16:22:03 2006 @@ -1,5 +1,5 @@ /** - * LOGBack: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework. * * Copyright (C) 1999-2006, QOS.ch * Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java ============================================================================== --- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java (original) +++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java Wed Oct 18 16:22:03 2006 @@ -1,3 +1,12 @@ +/** + * Logback: the generic, reliable, fast and flexible logging framework. + * + * Copyright (C) 1999-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ package ch.qos.logback.core.joran; import java.util.HashMap; @@ -11,7 +20,7 @@ HashMap<Pattern, Action> rulesMap; - TrivialConfigurator(HashMap<Pattern, Action> rules) { + public TrivialConfigurator(HashMap<Pattern, Action> rules) { this.rulesMap = rules; } Copied: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java (from r706, /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/EventRecorderTest.java) ============================================================================== --- /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/EventRecorderTest.java (original) +++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java Wed Oct 18 16:22:03 2006 @@ -1,13 +1,13 @@ /** - * Logback: the generic, reliable, fast and flexible logging framework. + * Logback: the generic, reliable, fast and flexible logging framework for Java. * - * Copyright (C) 1999-2006, QOS.ch + * Copyright (C) 2000-2006, QOS.ch * * This library is free software, you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation. */ -package ch.qos.logback.core.joran; +package ch.qos.logback.core.joran.event; import java.io.FileInputStream; import java.util.List; @@ -23,10 +23,10 @@ import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; -import ch.qos.logback.core.joran.spi.BodyEvent; -import ch.qos.logback.core.joran.spi.SaxEvent; -import ch.qos.logback.core.joran.spi.SaxEventRecorder; -import ch.qos.logback.core.joran.spi.StartEvent; +import ch.qos.logback.core.joran.event.BodyEvent; +import ch.qos.logback.core.joran.event.SaxEvent; +import ch.qos.logback.core.joran.event.SaxEventRecorder; +import ch.qos.logback.core.joran.event.StartEvent; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.status.StatusManager; import ch.qos.logback.core.util.Constants; Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java ============================================================================== --- (empty file) +++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java Wed Oct 18 16:22:03 2006 @@ -0,0 +1,43 @@ +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ +package ch.qos.logback.core.joran.event; + +import java.util.HashMap; + +import junit.framework.TestCase; +import ch.qos.logback.core.Context; +import ch.qos.logback.core.ContextBase; +import ch.qos.logback.core.joran.TrivialConfigurator; +import ch.qos.logback.core.joran.action.Action; +import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.util.Constants; + +public class InPlayFireTest extends TestCase { + + Context context = new ContextBase(); + HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>(); + + public void testBasic() throws JoranException { + ListenAction listenAction = new ListenAction(); + + rulesMap.put(new Pattern("fire"), listenAction); + TrivialConfigurator gc = new TrivialConfigurator(rulesMap); + + gc.setContext(context); + gc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/fire1.xml"); + + assertEquals(3, listenAction.getSeList().size()); + assertTrue(listenAction.getSeList().get(0) instanceof StartEvent); + assertTrue(listenAction.getSeList().get(1) instanceof BodyEvent); + assertTrue(listenAction.getSeList().get(2) instanceof EndEvent); + + } +} Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java ============================================================================== --- (empty file) +++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java Wed Oct 18 16:22:03 2006 @@ -0,0 +1,46 @@ +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ + +package ch.qos.logback.core.joran.event; + +import java.util.ArrayList; +import java.util.List; + +import org.xml.sax.Attributes; + +import ch.qos.logback.core.joran.action.Action; +import ch.qos.logback.core.joran.spi.ActionException; +import ch.qos.logback.core.joran.spi.ExecutionContext; + +public class ListenAction extends Action implements InPlayListener { + + List<SaxEvent> seList = new ArrayList<SaxEvent>(); + + @Override + public void begin(ExecutionContext ec, String name, Attributes attributes) + throws ActionException { + ec.addInPlayListener(this); + } + + @Override + public void end(ExecutionContext ec, String name) throws ActionException { + ec.removeInPlayListener(this); + + } + + public void inPlay(SaxEvent event) { + seList.add(event); + } + + public List<SaxEvent> getSeList() { + return seList; + } + +} Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java ============================================================================== --- (empty file) +++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java Wed Oct 18 16:22:03 2006 @@ -0,0 +1,24 @@ +/** + * Logback: the generic, reliable, fast and flexible logging framework for Java. + * + * Copyright (C) 2000-2006, QOS.ch + * + * This library is free software, you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation. + */ +package ch.qos.logback.core.joran.event; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class PackageTest extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTestSuite(EventRecorderTest.class); + suite.addTestSuite(InPlayFireTest.class); + return suite; + } +}
participants (1)
-
noreply.ceki@qos.ch