Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 13101 invoked from network); 6 Feb 2003 21:15:52 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 6 Feb 2003 21:15:52 -0000 Received: (qmail 14593 invoked by uid 97); 6 Feb 2003 21:17:25 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@nagoya.betaversion.org Received: (qmail 14586 invoked from network); 6 Feb 2003 21:17:24 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 6 Feb 2003 21:17:24 -0000 Received: (qmail 13009 invoked by uid 500); 6 Feb 2003 21:15:51 -0000 Mailing-List: contact avalon-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list avalon-cvs@jakarta.apache.org Received: (qmail 12997 invoked by uid 500); 6 Feb 2003 21:15:50 -0000 Received: (qmail 12994 invoked from network); 6 Feb 2003 21:15:50 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 6 Feb 2003 21:15:50 -0000 Received: (qmail 48102 invoked by uid 1152); 6 Feb 2003 21:15:50 -0000 Date: 6 Feb 2003 21:15:49 -0000 Message-ID: <20030206211549.48101.qmail@icarus.apache.org> From: bloritsch@apache.org To: avalon-logkit-cvs@apache.org Subject: cvs commit: avalon-logkit/src/test/org/apache/log/test LoggerListenerTestCase.java RecordingLoggerListener.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bloritsch 2003/02/06 13:15:49 Modified: src/java/org/apache/log Hierarchy.java src/test/org/apache/log/test LoggerListenerTestCase.java RecordingLoggerListener.java Log: complete listener code Revision Changes Path 1.24 +35 -1 avalon-logkit/src/java/org/apache/log/Hierarchy.java Index: Hierarchy.java =================================================================== RCS file: /home/cvs/avalon-logkit/src/java/org/apache/log/Hierarchy.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- Hierarchy.java 6 Feb 2003 16:39:58 -0000 1.23 +++ Hierarchy.java 6 Feb 2003 21:15:49 -0000 1.24 @@ -70,7 +70,7 @@ { ///Format of default formatter private static final String FORMAT = - "%7.7{priority} %23.23{time:yyyy-MM-dd' 'HH:mm:ss.SSS} [%8.8{category}] (%{context}): " + "%7.7{priority} %23.23{time:yyyy-MM-dd' 'HH:mm:ss.SSS} [%8.8{category}] (%{context}): " + "%{message}\n%{throwable}"; ///The instance of default hierarchy @@ -205,6 +205,8 @@ */ public synchronized void addLoggerListener( final LoggerListener loggerListener ) { + if ( null == loggerListener ) throw new NullPointerException( "loggerListener" ); + if ( null == m_loggerListener ) { m_loggerListener = loggerListener; @@ -212,6 +214,38 @@ else { throw new UnsupportedOperationException( "LoggerListener already set on a unicast event notifier" ); + } + } + + public synchronized LoggerListener[] getLoggerListeners() + { + LoggerListener[] listeners = null; + + if ( null == m_loggerListener ) + { + listeners = new LoggerListener[] {}; + } + else + { + listeners = new LoggerListener[] {m_loggerListener}; + } + + return listeners; + } + + /** + * Remove the LoggerListener associated with hierarchy. Perform this + * step before adding a new one if you want to change it. + * + * @param loggerListener the LoggerListener + */ + public synchronized void removeLoggerListener( final LoggerListener loggerListener ) + { + if ( null == loggerListener ) throw new NullPointerException( "loggerListener" ); + + if ( null != m_loggerListener && m_loggerListener.equals( loggerListener ) ); + { + m_loggerListener = null; } } 1.3 +70 -5 avalon-logkit/src/test/org/apache/log/test/LoggerListenerTestCase.java Index: LoggerListenerTestCase.java =================================================================== RCS file: /home/cvs/avalon-logkit/src/test/org/apache/log/test/LoggerListenerTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LoggerListenerTestCase.java 6 Feb 2003 16:39:58 -0000 1.2 +++ LoggerListenerTestCase.java 6 Feb 2003 21:15:49 -0000 1.3 @@ -1,9 +1,56 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. +/* ==================================================================== + * The Apache Software License, Version 1.1 * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. + * Copyright (c) 1997-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software + * itself, if and wherever such third-party acknowledgments + * normally appear. + * + * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" + * must not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package org.apache.log.test; @@ -40,6 +87,24 @@ { // It passed, yay! } + } + + public void testRemoveLoggerListener() + { + final Hierarchy hierarchy = new Hierarchy(); + final RecordingLoggerListener listener = new RecordingLoggerListener(); + + hierarchy.addLoggerListener( listener ); + + assertEquals( 1, hierarchy.getLoggerListeners().length ); + + hierarchy.removeLoggerListener( listener ); + + assertEquals( 0, hierarchy.getLoggerListeners().length ); + + hierarchy.addLoggerListener( listener ); + + assertEquals( 1, hierarchy.getLoggerListeners().length ); } public void testPriorityInheritance() 1.2 +53 -6 avalon-logkit/src/test/org/apache/log/test/RecordingLoggerListener.java Index: RecordingLoggerListener.java =================================================================== RCS file: /home/cvs/avalon-logkit/src/test/org/apache/log/test/RecordingLoggerListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RecordingLoggerListener.java 3 Feb 2003 19:39:39 -0000 1.1 +++ RecordingLoggerListener.java 6 Feb 2003 21:15:49 -0000 1.2 @@ -1,9 +1,56 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. +/* ==================================================================== + * The Apache Software License, Version 1.1 * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. + * Copyright (c) 1997-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software + * itself, if and wherever such third-party acknowledgments + * normally appear. + * + * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" + * must not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package org.apache.log.test; --------------------------------------------------------------------- To unsubscribe, e-mail: avalon-cvs-unsubscribe@jakarta.apache.org For additional commands, e-mail: avalon-cvs-help@jakarta.apache.org