avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atagu...@apache.org
Subject cvs commit: avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/util AvalonTee.java LoggerManagerTee.java
Date Wed, 11 Jun 2003 12:14:45 GMT
atagunov    2003/06/11 05:14:45

  Modified:    logger/src/java/org/apache/avalon/excalibur/logger/logkit
                        LogKitAdapter.java
  Added:       logger/src/java/org/apache/avalon/excalibur/logger/util
                        AvalonTee.java LoggerManagerTee.java
  Log:
  Ooopss, again a couple of classes were missing.
  And a typo.
  
  Revision  Changes    Path
  1.3       +1 -1      avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/logkit/LogKitAdapter.java
  
  Index: LogKitAdapter.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/logkit/LogKitAdapter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LogKitAdapter.java	11 Jun 2003 12:07:12 -0000	1.2
  +++ LogKitAdapter.java	11 Jun 2003 12:14:45 -0000	1.3
  @@ -96,7 +96,7 @@
        *
        * <p>
        * Our LogKitConfHelper configures getRootLogger(), not getLoggerFor("").
  -     * We think this is a reasonable behaviour and expect that LogKit
  +     * We think this is a reasonable behavior and expect that LogKit
        * Hierarchies configured by other means then LogKitConfHelper are
        * configured in the same way.
        * 
  
  
  
  1.1                  avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/util/AvalonTee.java
  
  Index: AvalonTee.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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", "Excalibur" 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 (INCLU-
   DING, 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 <http://www.apache.org/>.
  
  */
  package org.apache.avalon.excalibur.logger.util;
  
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.container.ContainerUtil;
  import java.util.ArrayList;
  
  /**
   * This class boradcasts Avalon lifestyle events to several
   * destination objects, somewhat like Unix 'tee' command
   * directing its input both to file and to tis output.
   *
   * The current implementation is incomplete and handles
   * only LogEnabled, Contextutalizable, Configurable and Disposable
   * interfaces.
   *
   * @author <a href="http://cvs.apache.org/~atagunov">Anton Tagunov</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/06/11 12:14:45 $
   * @since 4.0
   */
  
  public class AvalonTee implements
          LogEnabled,
          Contextualizable,
          Configurable,
          Startable, 
          Disposable
  {
      /* The objects we direct our events to */
      private ArrayList m_listeners = new ArrayList( 10 );
      /**
       * The number of these objects. This variable is here
       * is to save a line of code in every reactor method
       * rather then to optimize speed.
       */
      private int m_len = 0;
  
      /* Has adding new tees been prohibited? */
      private boolean m_readOnly = false;
  
      /**
       * Disallow adding more tees.
       */
      public void makeReadOnly()
      {
          m_readOnly = true;
      }
  
      /**
       * Adds an object to the list of objects receiving events.
       * @param obj the object to add; can not be null.
       */
      public void addTee( final Object obj )
      {
          if ( m_readOnly )
          {
              throw new IllegalStateException( "makeReadOnly() already invoked" );
          }
  
          if ( obj == null ) throw new NullPointerException( "obj" );
          if ( m_listeners.contains( obj ) )
          {
              // should we complain? better not, probably 
          }
          else
          {
              // adds to the end of the array
              m_listeners.add( obj );
              m_len = m_listeners.size();
          }
      }
  
      public void enableLogging( final Logger logger )
      {
          for( int i = 0; i < m_len; ++i )
          {
              ContainerUtil.enableLogging( m_listeners.get( i ), logger );
          }
      }
  
      public void contextualize( final Context context ) throws ContextException
      {
          for( int i = 0; i < m_len; ++i )
          {
              ContainerUtil.contextualize( m_listeners.get( i ), context );
          }
      }
  
      public void configure( final Configuration config ) throws ConfigurationException
      {
          for( int i = 0; i < m_len; ++i )
          {
              ContainerUtil.configure( m_listeners.get( i ), config );
          }
      }
  
      public void start() throws Exception
      {
          for( int i = 0; i < m_len; ++i )
          {
              ContainerUtil.start( m_listeners.get( i ) );
          }
      }
  
      public void stop() throws Exception
      {
          for( int i = 0; i < m_len; ++i )
          {
              ContainerUtil.stop( m_listeners.get( i ) );
          }
      }
  
      public void dispose()
      {
          for( int i = 0; i < m_len; ++i )
          {
              ContainerUtil.dispose( m_listeners.get( i ) );
          }
      }
  }
  
  
  
  1.1                  avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/util/LoggerManagerTee.java
  
  Index: LoggerManagerTee.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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", "Excalibur" 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 (INCLU-
   DING, 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 <http://www.apache.org/>.
  
  */
  package org.apache.avalon.excalibur.logger.util;
  
  import org.apache.avalon.excalibur.logger.LoggerManager;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * An AvalonTee object is not usefull by itself as it does not
   * implement any component interface. Its primary use is to
   * serve as a base class for objects proxing not only
   * lifecycle but also some "meaningfull" interfaces.
   * This object proxies LoggerManager interface.
   *
   * @author <a href="http://cvs.apache.org/~atagunov">Anton Tagunov</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/06/11 12:14:45 $
   * @since 4.0
   */
  public class LoggerManagerTee extends AvalonTee implements LoggerManager
  {
      /* The wrapped LoggerManager to delegate all the work to.*/
      private final LoggerManager m_loggerManager;
  
      /**
       * Creates a new instance of LoggerManagerTee. Adds the supplied
       * LoggerManager as the first tee. (It will receive the lifecycle
       * events first of all tees).
       */
      public LoggerManagerTee( final LoggerManager loggerManager )
      {
          addTee( loggerManager );
          m_loggerManager = loggerManager;
      }
  
      /**
       * Return the Logger for the specified category.
       */
      public Logger getLoggerForCategory( final String categoryName )
      {
          return m_loggerManager.getLoggerForCategory( categoryName );
      }
  
      /**
       * Return the default Logger.  This is basically the same
       * as getting the Logger for the "" category.
       */
      public Logger getDefaultLogger()
      {
          return m_loggerManager.getDefaultLogger();
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message