avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/util ContextManager.java FortressConfig.java
Date Fri, 11 Apr 2003 07:38:31 GMT
donaldp     2003/04/11 00:38:31

  Modified:    fortress/src/java/org/apache/avalon/fortress RoleEntry.java
               fortress/src/java/org/apache/avalon/fortress/impl
                        AbstractContainer.java DefaultContainer.java
                        DefaultContainerManager.java
               fortress/src/java/org/apache/avalon/fortress/impl/extensions
                        InstrumentableCreator.java
               fortress/src/java/org/apache/avalon/fortress/impl/handler
                        AbstractComponentHandler.java ComponentFactory.java
                        LEAwareComponentHandler.java
               fortress/src/java/org/apache/avalon/fortress/impl/lookup
                        FortressServiceManager.java
                        FortressServiceSelector.java
               fortress/src/java/org/apache/avalon/fortress/util
                        ContextManager.java FortressConfig.java
  Log:
  styled
  
  Revision  Changes    Path
  1.8       +15 -15    avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/RoleEntry.java
  
  Index: RoleEntry.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/RoleEntry.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RoleEntry.java	22 Mar 2003 12:46:32 -0000	1.7
  +++ RoleEntry.java	11 Apr 2003 07:38:30 -0000	1.8
  @@ -3,34 +3,34 @@
    ============================================================================
                      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 
  +
  + 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
  @@ -41,11 +41,11 @@
    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 
  + 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.fortress;
   
  
  
  
  1.21      +2 -2      avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/AbstractContainer.java
  
  Index: AbstractContainer.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/AbstractContainer.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- AbstractContainer.java	5 Apr 2003 19:39:35 -0000	1.20
  +++ AbstractContainer.java	11 Apr 2003 07:38:30 -0000	1.21
  @@ -487,7 +487,7 @@
        * Create the hint map for a role.  The map may have to take care for thread-safety.
        * By default a StaticBucketMap is created, but you may change the implementation
        * or increment the number of buckets according your needs.
  -     * 
  +     *
        * <div>
        *   <span style="font-weight:strong;text-color: red;">WARNING:</span>
        *   This Map must be threadsafe, so either use the
  
  
  
  1.11      +7 -7      avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/DefaultContainer.java
  
  Index: DefaultContainer.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/DefaultContainer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultContainer.java	7 Apr 2003 20:19:08 -0000	1.10
  +++ DefaultContainer.java	11 Apr 2003 07:38:30 -0000	1.11
  @@ -138,7 +138,7 @@
           throws ConfigurationException
       {
           String className = null;
  -        
  +
           if( "component".equals( config.getName() ) )
           {
               className = config.getAttribute( "class" );
  @@ -152,15 +152,15 @@
                       "[name: " + config.getName() + ", location: " + config.getLocation() + "]";
                   throw new ConfigurationException( message );
               }
  -            
  +
               className = roleEntry.getComponentClass().getName();
           }
  -        
  -        if (getLogger().isDebugEnabled())
  +
  +        if( getLogger().isDebugEnabled() )
           {
  -            getLogger().debug("Configuration processed for: " + className);
  +            getLogger().debug( "Configuration processed for: " + className );
           }
  -        
  +
           return className;
       }
   
  
  
  
  1.13      +4 -4      avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/DefaultContainerManager.java
  
  Index: DefaultContainerManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/DefaultContainerManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultContainerManager.java	5 Apr 2003 19:39:35 -0000	1.12
  +++ DefaultContainerManager.java	11 Apr 2003 07:38:30 -0000	1.13
  @@ -146,14 +146,14 @@
               String logCategory = (String)initParameters.get( ContextManagerConstants.LOG_CATEGORY );
               LoggerManager loggerManager = (LoggerManager)initParameters.get( LoggerManager.ROLE );
               Logger logger;
  -            
  -            if (null == logCategory)
  +
  +            if( null == logCategory )
               {
                   logger = loggerManager.getDefaultLogger();
               }
               else
               {
  -                logger = loggerManager.getLoggerForCategory(logCategory);
  +                logger = loggerManager.getLoggerForCategory( logCategory );
               }
   
               return logger;
  
  
  
  1.5       +101 -101  avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/extensions/InstrumentableCreator.java
  
  Index: InstrumentableCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/extensions/InstrumentableCreator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InstrumentableCreator.java	19 Mar 2003 12:55:46 -0000	1.4
  +++ InstrumentableCreator.java	11 Apr 2003 07:38:30 -0000	1.5
  @@ -1,101 +1,101 @@
  -/* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2003 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 "D-Haven" 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
  - * <http://www.apache.org/>.
  - */
  -package org.apache.avalon.fortress.impl.extensions;
  -
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.lifecycle.AbstractCreator;
  -import org.apache.excalibur.instrument.InstrumentManageable;
  -import org.apache.excalibur.instrument.InstrumentManager;
  -import org.apache.excalibur.instrument.Instrumentable;
  -
  -/**
  - * The InstrumentableCreator is used as a standard lifecycle
  - * extension for containers that support it.
  - */
  -public class InstrumentableCreator extends AbstractCreator
  -{
  -    private final InstrumentManager m_instrumentManager;
  -    private final boolean m_instrumentEnabled;
  -
  -    public InstrumentableCreator( InstrumentManager instrumentManager )
  -    {
  -        m_instrumentManager = instrumentManager;
  -        m_instrumentEnabled = instrumentManager != null;
  -    }
  -
  -    /**
  -     * Assign the instrumentables and InstrumentManageables
  -     */
  -    public void create( Object object, Context context ) throws Exception
  -    {
  -        if( m_instrumentEnabled && object instanceof Instrumentable )
  -        {
  -            String instrumentableName = (String)context.get( "component.name" );
  -            final Instrumentable instrumentable = (Instrumentable)object;
  -            instrumentable.setInstrumentableName( instrumentableName );
  -
  -            // Get the name from the instrumentable in case it was changed since being set above.
  -            m_instrumentManager.registerInstrumentable(
  -                instrumentable, instrumentable.getInstrumentableName() );
  -
  -        }
  -
  -        if( m_instrumentEnabled && object instanceof InstrumentManageable )
  -        {
  -            ( (InstrumentManageable)object ).setInstrumentManager( m_instrumentManager );
  -        }
  -
  -    }
  -}
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2003 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 "D-Haven" 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
  + * <http://www.apache.org/>.
  + */
  +package org.apache.avalon.fortress.impl.extensions;
  +
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.lifecycle.AbstractCreator;
  +import org.apache.excalibur.instrument.InstrumentManageable;
  +import org.apache.excalibur.instrument.InstrumentManager;
  +import org.apache.excalibur.instrument.Instrumentable;
  +
  +/**
  + * The InstrumentableCreator is used as a standard lifecycle
  + * extension for containers that support it.
  + */
  +public class InstrumentableCreator extends AbstractCreator
  +{
  +    private final InstrumentManager m_instrumentManager;
  +    private final boolean m_instrumentEnabled;
  +
  +    public InstrumentableCreator( InstrumentManager instrumentManager )
  +    {
  +        m_instrumentManager = instrumentManager;
  +        m_instrumentEnabled = instrumentManager != null;
  +    }
  +
  +    /**
  +     * Assign the instrumentables and InstrumentManageables
  +     */
  +    public void create( Object object, Context context ) throws Exception
  +    {
  +        if( m_instrumentEnabled && object instanceof Instrumentable )
  +        {
  +            String instrumentableName = (String)context.get( "component.name" );
  +            final Instrumentable instrumentable = (Instrumentable)object;
  +            instrumentable.setInstrumentableName( instrumentableName );
  +
  +            // Get the name from the instrumentable in case it was changed since being set above.
  +            m_instrumentManager.registerInstrumentable(
  +                instrumentable, instrumentable.getInstrumentableName() );
  +
  +        }
  +
  +        if( m_instrumentEnabled && object instanceof InstrumentManageable )
  +        {
  +            ( (InstrumentManageable)object ).setInstrumentManager( m_instrumentManager );
  +        }
  +
  +    }
  +}
  
  
  
  1.12      +355 -355  avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler/AbstractComponentHandler.java
  
  Index: AbstractComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler/AbstractComponentHandler.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AbstractComponentHandler.java	22 Mar 2003 12:46:33 -0000	1.11
  +++ AbstractComponentHandler.java	11 Apr 2003 07:38:30 -0000	1.12
  @@ -1,355 +1,355 @@
  -/*
  -
  - ============================================================================
  -                   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.fortress.impl.handler;
  -
  -import org.apache.avalon.excalibur.logger.LoggerManager;
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.activity.Initializable;
  -import org.apache.avalon.framework.container.ContainerUtil;
  -import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable;
  -import org.apache.excalibur.instrument.CounterInstrument;
  -import org.apache.excalibur.instrument.Instrumentable;
  -import org.apache.excalibur.mpool.ObjectFactory;
  -
  -/**
  - * AbstractComponentHandler class, ensures components are initialized
  - * and destroyed correctly.
  - *
  - * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  - * @version CVS $Revision$ $Date$
  - * @since 4.0
  - */
  -public abstract class AbstractComponentHandler
  -    extends AbstractLogEnabledInstrumentable
  -    implements Serviceable, Initializable, Disposable, ComponentHandler
  -{
  -    private CounterInstrument m_request = new CounterInstrument( "requests" );
  -    private CounterInstrument m_release = new CounterInstrument( "releases" );
  -
  -    /**
  -     * The instance of the ComponentFactory that creates and disposes of the
  -     * Component
  -     */
  -    protected ObjectFactory m_factory;
  -
  -    /**
  -     * State management boolean stating whether the Handler is initialized or
  -     * not
  -     */
  -    protected boolean m_prepared;
  -
  -    /**
  -     * State management boolean stating whether the Handler is disposed or
  -     * not
  -     */
  -    protected boolean m_disposed;
  -
  -    /** Logger for factory */
  -    protected Logger m_logger;
  -
  -    /** Logger Manager */
  -    protected LoggerManager m_loggerManager;
  -
  -    /**
  -     * @avalon.dependency type="LoggerManager"
  -     */
  -    public void service( ServiceManager manager )
  -        throws ServiceException
  -    {
  -        m_loggerManager =
  -            (LoggerManager)manager.lookup( LoggerManager.ROLE );
  -        m_factory =
  -            (ObjectFactory)manager.lookup( ObjectFactory.ROLE );
  -    }
  -
  -    public void initialize()
  -        throws Exception
  -    {
  -        final String classname = getClass().getName();
  -        final int index = classname.lastIndexOf( '.' );
  -        final String name = classname.substring( index + 1 );
  -
  -        String loggerName = name.toLowerCase();
  -        if( name.endsWith( "ComponentHandler" ) )
  -        {
  -            final int endIndex = loggerName.length() - 16;
  -            loggerName = loggerName.substring( 0, endIndex );
  -        }
  -
  -        final String categoryName = "system.handler." + loggerName;
  -        m_logger =
  -            m_loggerManager.getLoggerForCategory( categoryName );
  -
  -        if( m_factory instanceof Instrumentable )
  -        {
  -            addChildInstrumentable( (Instrumentable)m_factory );
  -        }
  -
  -        addInstrument( m_request );
  -        addInstrument( m_release );
  -
  -        setInstrumentableName( name );
  -    }
  -
  -    /**
  -     * Return the component's class that this handler is trying to create.
  -     * Used for deubug information.
  -     *
  -     * @return the <code>Class</code> object for the component
  -     */
  -    public Class getComponentClass()
  -    {
  -        return m_factory.getCreatedClass();
  -    }
  -
  -    /**
  -     * Actually prepare the handler and make it ready to
  -     * handle component access.
  -     *
  -     * @throws Exception if unable to prepare handler
  -     */
  -    public synchronized void prepareHandler()
  -        throws Exception
  -    {
  -        if( m_prepared )
  -        {
  -            return;
  -        }
  -
  -        if( m_disposed )
  -        {
  -            final String message = "Attempted to prepare disposed ComponentHandler for : " +
  -                m_factory.getCreatedClass().getName();
  -            m_logger.warn( message );
  -
  -            return;
  -        }
  -
  -        doPrepare();
  -
  -        if( m_logger.isDebugEnabled() )
  -        {
  -            final String message = "ComponentHandler initialized for: " +
  -                m_factory.getCreatedClass().getName();
  -            m_logger.debug( message );
  -        }
  -
  -        m_prepared = true;
  -    }
  -
  -    /**
  -     * Initialize the ComponentHandler.
  -     * Subclasses should overide this to do their own initialization.
  -     */
  -    protected void doPrepare()
  -        throws Exception
  -    {
  -    }
  -
  -    /**
  -     * Get a reference of the desired Component
  -     * @return the component
  -     */
  -    public Object get()
  -        throws Exception
  -    {
  -        if( !m_prepared )
  -        {
  -            prepareHandler();
  -        }
  -
  -        if( m_disposed )
  -        {
  -            final String message =
  -                "You cannot get a component from a disposed holder";
  -            throw new IllegalStateException( message );
  -        }
  -
  -        if( m_request.isActive() )
  -        {
  -            m_request.increment();
  -        }
  -
  -        return doGet();
  -    }
  -
  -    /**
  -     * Subclasses should actually overide this to do the work
  -     * of retrieving a service.
  -     *
  -     * @return the service
  -     * @throws Exception if unable to aquire service
  -     */
  -    protected abstract Object doGet()
  -        throws Exception;
  -
  -    /**
  -     * Return a reference of the desired Component
  -     * @param component the component
  -     */
  -    public void put( final Object component )
  -    {
  -        if( !m_prepared )
  -        {
  -            final String message =
  -                "You cannot put a component in an uninitialized holder";
  -            throw new IllegalStateException( message );
  -        }
  -
  -        if( m_release.isActive() )
  -        {
  -            m_release.increment();
  -        }
  -
  -        doPut( component );
  -    }
  -
  -    /**
  -     * Subclasses should overide this to return component to handler.
  -     *
  -     * @param component the component
  -     */
  -    protected void doPut( final Object component )
  -    {
  -    }
  -
  -    /**
  -     * Create a new component for handler.
  -     *
  -     * @return the new component
  -     * @throws Exception if unable to create new component
  -     */
  -    protected Object newComponent()
  -        throws Exception
  -    {
  -        try
  -        {
  -            return m_factory.newInstance();
  -        }
  -        catch( final Exception e )
  -        {
  -            if( m_logger.isErrorEnabled() )
  -            {
  -                final String message = "Unable to create new instance";
  -                m_logger.error( message, e );
  -            }
  -
  -            throw e;
  -        }
  -    }
  -
  -    /**
  -     * Dispose of the specified component.
  -     *
  -     * @param component the component
  -     */
  -    protected void disposeComponent( final Object component )
  -    {
  -        if( null == component )
  -        {
  -            return;
  -        }
  -        try
  -        {
  -            m_factory.dispose( component );
  -        }
  -        catch( final Exception e )
  -        {
  -            if( m_logger.isWarnEnabled() )
  -            {
  -                m_logger.warn( "Error disposing component", e );
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Dispose of the ComponentHandler and any associated Pools and Factories.
  -     */
  -    public void dispose()
  -    {
  -        doDispose();
  -        try
  -        {
  -            ContainerUtil.dispose( m_factory );
  -        }
  -        catch( RuntimeException e )
  -        {
  -            if( m_logger.isWarnEnabled() )
  -            {
  -                final String message = "Error decommissioning component: " +
  -                    m_factory.getCreatedClass().getName();
  -                m_logger.warn( message, e );
  -            }
  -        }
  -
  -        m_disposed = true;
  -    }
  -
  -    /**
  -     * Dispose handler specific resources.
  -     * Subclasses should overide this to provide their own funcitonality.
  -     */
  -    protected void doDispose()
  -    {
  -    }
  -
  -    /**
  -     * Represents the handler as a string.
  -     * @return the string representation of the handler
  -     */
  -    public String toString()
  -    {
  -        return getClass().getName() + "[for: " + m_factory.getCreatedClass().getName() + "]";
  -    }
  -}
  +/*
  +
  + ============================================================================
  +                   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.fortress.impl.handler;
  +
  +import org.apache.avalon.excalibur.logger.LoggerManager;
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.container.ContainerUtil;
  +import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable;
  +import org.apache.excalibur.instrument.CounterInstrument;
  +import org.apache.excalibur.instrument.Instrumentable;
  +import org.apache.excalibur.mpool.ObjectFactory;
  +
  +/**
  + * AbstractComponentHandler class, ensures components are initialized
  + * and destroyed correctly.
  + *
  + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  + * @version CVS $Revision$ $Date$
  + * @since 4.0
  + */
  +public abstract class AbstractComponentHandler
  +    extends AbstractLogEnabledInstrumentable
  +    implements Serviceable, Initializable, Disposable, ComponentHandler
  +{
  +    private CounterInstrument m_request = new CounterInstrument( "requests" );
  +    private CounterInstrument m_release = new CounterInstrument( "releases" );
  +
  +    /**
  +     * The instance of the ComponentFactory that creates and disposes of the
  +     * Component
  +     */
  +    protected ObjectFactory m_factory;
  +
  +    /**
  +     * State management boolean stating whether the Handler is initialized or
  +     * not
  +     */
  +    protected boolean m_prepared;
  +
  +    /**
  +     * State management boolean stating whether the Handler is disposed or
  +     * not
  +     */
  +    protected boolean m_disposed;
  +
  +    /** Logger for factory */
  +    protected Logger m_logger;
  +
  +    /** Logger Manager */
  +    protected LoggerManager m_loggerManager;
  +
  +    /**
  +     * @avalon.dependency type="LoggerManager"
  +     */
  +    public void service( ServiceManager manager )
  +        throws ServiceException
  +    {
  +        m_loggerManager =
  +            (LoggerManager)manager.lookup( LoggerManager.ROLE );
  +        m_factory =
  +            (ObjectFactory)manager.lookup( ObjectFactory.ROLE );
  +    }
  +
  +    public void initialize()
  +        throws Exception
  +    {
  +        final String classname = getClass().getName();
  +        final int index = classname.lastIndexOf( '.' );
  +        final String name = classname.substring( index + 1 );
  +
  +        String loggerName = name.toLowerCase();
  +        if( name.endsWith( "ComponentHandler" ) )
  +        {
  +            final int endIndex = loggerName.length() - 16;
  +            loggerName = loggerName.substring( 0, endIndex );
  +        }
  +
  +        final String categoryName = "system.handler." + loggerName;
  +        m_logger =
  +            m_loggerManager.getLoggerForCategory( categoryName );
  +
  +        if( m_factory instanceof Instrumentable )
  +        {
  +            addChildInstrumentable( (Instrumentable)m_factory );
  +        }
  +
  +        addInstrument( m_request );
  +        addInstrument( m_release );
  +
  +        setInstrumentableName( name );
  +    }
  +
  +    /**
  +     * Return the component's class that this handler is trying to create.
  +     * Used for deubug information.
  +     *
  +     * @return the <code>Class</code> object for the component
  +     */
  +    public Class getComponentClass()
  +    {
  +        return m_factory.getCreatedClass();
  +    }
  +
  +    /**
  +     * Actually prepare the handler and make it ready to
  +     * handle component access.
  +     *
  +     * @throws Exception if unable to prepare handler
  +     */
  +    public synchronized void prepareHandler()
  +        throws Exception
  +    {
  +        if( m_prepared )
  +        {
  +            return;
  +        }
  +
  +        if( m_disposed )
  +        {
  +            final String message = "Attempted to prepare disposed ComponentHandler for : " +
  +                m_factory.getCreatedClass().getName();
  +            m_logger.warn( message );
  +
  +            return;
  +        }
  +
  +        doPrepare();
  +
  +        if( m_logger.isDebugEnabled() )
  +        {
  +            final String message = "ComponentHandler initialized for: " +
  +                m_factory.getCreatedClass().getName();
  +            m_logger.debug( message );
  +        }
  +
  +        m_prepared = true;
  +    }
  +
  +    /**
  +     * Initialize the ComponentHandler.
  +     * Subclasses should overide this to do their own initialization.
  +     */
  +    protected void doPrepare()
  +        throws Exception
  +    {
  +    }
  +
  +    /**
  +     * Get a reference of the desired Component
  +     * @return the component
  +     */
  +    public Object get()
  +        throws Exception
  +    {
  +        if( !m_prepared )
  +        {
  +            prepareHandler();
  +        }
  +
  +        if( m_disposed )
  +        {
  +            final String message =
  +                "You cannot get a component from a disposed holder";
  +            throw new IllegalStateException( message );
  +        }
  +
  +        if( m_request.isActive() )
  +        {
  +            m_request.increment();
  +        }
  +
  +        return doGet();
  +    }
  +
  +    /**
  +     * Subclasses should actually overide this to do the work
  +     * of retrieving a service.
  +     *
  +     * @return the service
  +     * @throws Exception if unable to aquire service
  +     */
  +    protected abstract Object doGet()
  +        throws Exception;
  +
  +    /**
  +     * Return a reference of the desired Component
  +     * @param component the component
  +     */
  +    public void put( final Object component )
  +    {
  +        if( !m_prepared )
  +        {
  +            final String message =
  +                "You cannot put a component in an uninitialized holder";
  +            throw new IllegalStateException( message );
  +        }
  +
  +        if( m_release.isActive() )
  +        {
  +            m_release.increment();
  +        }
  +
  +        doPut( component );
  +    }
  +
  +    /**
  +     * Subclasses should overide this to return component to handler.
  +     *
  +     * @param component the component
  +     */
  +    protected void doPut( final Object component )
  +    {
  +    }
  +
  +    /**
  +     * Create a new component for handler.
  +     *
  +     * @return the new component
  +     * @throws Exception if unable to create new component
  +     */
  +    protected Object newComponent()
  +        throws Exception
  +    {
  +        try
  +        {
  +            return m_factory.newInstance();
  +        }
  +        catch( final Exception e )
  +        {
  +            if( m_logger.isErrorEnabled() )
  +            {
  +                final String message = "Unable to create new instance";
  +                m_logger.error( message, e );
  +            }
  +
  +            throw e;
  +        }
  +    }
  +
  +    /**
  +     * Dispose of the specified component.
  +     *
  +     * @param component the component
  +     */
  +    protected void disposeComponent( final Object component )
  +    {
  +        if( null == component )
  +        {
  +            return;
  +        }
  +        try
  +        {
  +            m_factory.dispose( component );
  +        }
  +        catch( final Exception e )
  +        {
  +            if( m_logger.isWarnEnabled() )
  +            {
  +                m_logger.warn( "Error disposing component", e );
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Dispose of the ComponentHandler and any associated Pools and Factories.
  +     */
  +    public void dispose()
  +    {
  +        doDispose();
  +        try
  +        {
  +            ContainerUtil.dispose( m_factory );
  +        }
  +        catch( RuntimeException e )
  +        {
  +            if( m_logger.isWarnEnabled() )
  +            {
  +                final String message = "Error decommissioning component: " +
  +                    m_factory.getCreatedClass().getName();
  +                m_logger.warn( message, e );
  +            }
  +        }
  +
  +        m_disposed = true;
  +    }
  +
  +    /**
  +     * Dispose handler specific resources.
  +     * Subclasses should overide this to provide their own funcitonality.
  +     */
  +    protected void doDispose()
  +    {
  +    }
  +
  +    /**
  +     * Represents the handler as a string.
  +     * @return the string representation of the handler
  +     */
  +    public String toString()
  +    {
  +        return getClass().getName() + "[for: " + m_factory.getCreatedClass().getName() + "]";
  +    }
  +}
  
  
  
  1.21      +3 -3      avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler/ComponentFactory.java
  
  Index: ComponentFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler/ComponentFactory.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ComponentFactory.java	3 Apr 2003 13:43:51 -0000	1.20
  +++ ComponentFactory.java	11 Apr 2003 07:38:30 -0000	1.21
  @@ -205,10 +205,10 @@
       private Logger aquireLogger()
       {
           Logger logger;
  -        
  +
           try
           {
  -            final String name = (String)m_context.get("component.logger");
  +            final String name = (String)m_context.get( "component.logger" );
               if( getLogger().isDebugEnabled() )
               {
                   final String message = "logger name is " + name;
  
  
  
  1.12      +158 -158  avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler/LEAwareComponentHandler.java
  
  Index: LEAwareComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler/LEAwareComponentHandler.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LEAwareComponentHandler.java	22 Mar 2003 12:46:33 -0000	1.11
  +++ LEAwareComponentHandler.java	11 Apr 2003 07:38:30 -0000	1.12
  @@ -1,158 +1,158 @@
  -/*
  -
  - ============================================================================
  -                   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.fortress.impl.handler;
  -
  -import org.apache.avalon.fortress.util.LifecycleExtensionManager;
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.container.ContainerUtil;
  -import org.apache.avalon.framework.context.Context;
  -
  -/**
  - * A ComponentHandler that delegates to underlying handler but also
  - * calls relevent Lifecycle Extension handlers at the right time.
  - *
  - * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version CVS $Revision$ $Date$
  - */
  -public class LEAwareComponentHandler
  -    implements ComponentHandler, Disposable
  -{
  -    private final ComponentHandler m_componentHandler;
  -    private final LifecycleExtensionManager m_extManager;
  -    private final Context m_context;
  -
  -    /**
  -     * Creation of a new handler.
  -     * @param componentHandler the handler
  -     * @param extManager the extension manager
  -     * @param context the context
  -     */
  -    public LEAwareComponentHandler( final ComponentHandler componentHandler,
  -                                    final LifecycleExtensionManager extManager,
  -                                    final Context context )
  -    {
  -        if( null == componentHandler )
  -        {
  -            throw new NullPointerException( "componentHandler" );
  -        }
  -        if( null == extManager )
  -        {
  -            throw new NullPointerException( "extManager" );
  -        }
  -        if( null == context )
  -        {
  -            throw new NullPointerException( "context" );
  -        }
  -
  -        m_componentHandler = componentHandler;
  -        m_extManager = extManager;
  -        m_context = context;
  -    }
  -
  -    /**
  -     * Return the component's class that this handler is trying to create.
  -     * Used for deubug information.
  -     *
  -     * @return the <code>Class</code> object for the component
  -     */
  -    public Class getComponentClass()
  -    {
  -        return m_componentHandler.getComponentClass();
  -    }
  -
  -    /**
  -     * Prepare the handler.
  -     * @exception Exception if a handler preparation error occurs
  -     */
  -    public void prepareHandler()
  -        throws Exception
  -    {
  -        m_componentHandler.prepareHandler();
  -    }
  -
  -    /**
  -     * Retrieve the object and execute access extensions.
  -     *
  -     * @return the object
  -     * @throws Exception if unable to aquire object
  -     */
  -    public Object get() throws Exception
  -    {
  -        final Object object = m_componentHandler.get();
  -        m_extManager.executeAccessExtensions( object, m_context );
  -        return object;
  -    }
  -
  -    /**
  -     * Return component and execute Release extensions.
  -     *
  -     * @param component the component
  -     */
  -    public void put( final Object component )
  -    {
  -        try
  -        {
  -            m_extManager.executeReleaseExtensions( component, m_context );
  -        }
  -        catch( Exception e )
  -        {
  -            // REVISIT(MC): we need to log this somewhere
  -        }
  -        m_componentHandler.put( component );
  -    }
  -
  -    /**
  -     * Disposal of the handler.
  -     */
  -    public void dispose()
  -    {
  -        ContainerUtil.dispose( m_componentHandler );
  -    }
  -}
  +/*
  +
  + ============================================================================
  +                   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.fortress.impl.handler;
  +
  +import org.apache.avalon.fortress.util.LifecycleExtensionManager;
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.container.ContainerUtil;
  +import org.apache.avalon.framework.context.Context;
  +
  +/**
  + * A ComponentHandler that delegates to underlying handler but also
  + * calls relevent Lifecycle Extension handlers at the right time.
  + *
  + * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  + * @version CVS $Revision$ $Date$
  + */
  +public class LEAwareComponentHandler
  +    implements ComponentHandler, Disposable
  +{
  +    private final ComponentHandler m_componentHandler;
  +    private final LifecycleExtensionManager m_extManager;
  +    private final Context m_context;
  +
  +    /**
  +     * Creation of a new handler.
  +     * @param componentHandler the handler
  +     * @param extManager the extension manager
  +     * @param context the context
  +     */
  +    public LEAwareComponentHandler( final ComponentHandler componentHandler,
  +                                    final LifecycleExtensionManager extManager,
  +                                    final Context context )
  +    {
  +        if( null == componentHandler )
  +        {
  +            throw new NullPointerException( "componentHandler" );
  +        }
  +        if( null == extManager )
  +        {
  +            throw new NullPointerException( "extManager" );
  +        }
  +        if( null == context )
  +        {
  +            throw new NullPointerException( "context" );
  +        }
  +
  +        m_componentHandler = componentHandler;
  +        m_extManager = extManager;
  +        m_context = context;
  +    }
  +
  +    /**
  +     * Return the component's class that this handler is trying to create.
  +     * Used for deubug information.
  +     *
  +     * @return the <code>Class</code> object for the component
  +     */
  +    public Class getComponentClass()
  +    {
  +        return m_componentHandler.getComponentClass();
  +    }
  +
  +    /**
  +     * Prepare the handler.
  +     * @exception Exception if a handler preparation error occurs
  +     */
  +    public void prepareHandler()
  +        throws Exception
  +    {
  +        m_componentHandler.prepareHandler();
  +    }
  +
  +    /**
  +     * Retrieve the object and execute access extensions.
  +     *
  +     * @return the object
  +     * @throws Exception if unable to aquire object
  +     */
  +    public Object get() throws Exception
  +    {
  +        final Object object = m_componentHandler.get();
  +        m_extManager.executeAccessExtensions( object, m_context );
  +        return object;
  +    }
  +
  +    /**
  +     * Return component and execute Release extensions.
  +     *
  +     * @param component the component
  +     */
  +    public void put( final Object component )
  +    {
  +        try
  +        {
  +            m_extManager.executeReleaseExtensions( component, m_context );
  +        }
  +        catch( Exception e )
  +        {
  +            // REVISIT(MC): we need to log this somewhere
  +        }
  +        m_componentHandler.put( component );
  +    }
  +
  +    /**
  +     * Disposal of the handler.
  +     */
  +    public void dispose()
  +    {
  +        ContainerUtil.dispose( m_componentHandler );
  +    }
  +}
  
  
  
  1.13      +221 -221  avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/lookup/FortressServiceManager.java
  
  Index: FortressServiceManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/lookup/FortressServiceManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- FortressServiceManager.java	22 Mar 2003 12:46:34 -0000	1.12
  +++ FortressServiceManager.java	11 Apr 2003 07:38:30 -0000	1.13
  @@ -1,221 +1,221 @@
  -/*
  -
  - ============================================================================
  -                   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.fortress.impl.lookup;
  -
  -import java.util.Map;
  -import org.apache.avalon.fortress.Container;
  -import org.apache.avalon.fortress.impl.AbstractContainer;
  -import org.apache.avalon.fortress.impl.handler.ComponentHandler;
  -import org.apache.avalon.framework.component.ComponentSelector;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.avalon.framework.service.ServiceSelector;
  -import org.apache.avalon.framework.service.WrapperServiceSelector;
  -import org.apache.commons.collections.StaticBucketMap;
  -
  -/**
  - * This is the Default ServiceManager for the Container.  It provides
  - * a very simple abstraction, and makes it easy for the Container to manage
  - * the references.
  - *
  - * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  - * @version CVS $Revision$ $Date$
  - */
  -public class FortressServiceManager
  -    implements ServiceManager
  -{
  -    private final Container m_container;
  -    private final Map m_used;
  -    private final ServiceManager m_parent;
  -
  -    /**
  -     * This constructor is for a ContainerComponentManager with a parent
  -     * ComponentLocator
  -     * @param container the impl
  -     * @param parent the parent service manager
  -     * @exception NullPointerException if the supplied impl is null
  -     * @exception NullPointerException if the supplied parent is null
  -     */
  -    public FortressServiceManager( final Container container,
  -                                   final ServiceManager parent ) throws NullPointerException
  -    {
  -        if( null == container )
  -        {
  -            throw new NullPointerException( "impl" );
  -        }
  -        if( null == parent )
  -        {
  -            throw new NullPointerException( "parent" );
  -        }
  -
  -        m_parent = parent;
  -        m_container = container;
  -        m_used = new StaticBucketMap();
  -    }
  -
  -    public Object lookup( final String role )
  -        throws ServiceException
  -    {
  -        Lookup lookup = parseRole( role );
  -
  -        if( !m_container.has( lookup.m_role, lookup.m_hint ) )
  -        {
  -            return m_parent.lookup( role );
  -        }
  -
  -        final Object result = m_container.get( lookup.m_role, lookup.m_hint );
  -        if( result instanceof ServiceSelector )
  -        {
  -            return result;
  -        }
  -
  -        if( result instanceof ComponentSelector )
  -        {
  -            return new WrapperServiceSelector( lookup.m_role, (ComponentSelector)result );
  -        }
  -
  -        if( !( result instanceof ComponentHandler ) )
  -        {
  -            final String message = "Invalid entry in component manager";
  -            throw new ServiceException( role, message );
  -        }
  -
  -        try
  -        {
  -            final ComponentHandler handler = (ComponentHandler)result;
  -            final Object component = handler.get();
  -
  -            m_used.put( new ComponentKey( component ), handler );
  -            return component;
  -        }
  -        catch( final ServiceException ce )
  -        {
  -            throw ce; // rethrow
  -        }
  -        catch( final Exception e )
  -        {
  -            final String message =
  -                "Could not return a reference to the Component";
  -            throw new ServiceException( role, message, e );
  -        }
  -    }
  -
  -    public boolean hasService( final String role )
  -    {
  -        Lookup lookup = parseRole( role );
  -
  -        if( m_container.has( lookup.m_role, lookup.m_hint ) )
  -        {
  -            return true;
  -        }
  -        else
  -        {
  -            return null != m_parent ? m_parent.hasService( role ) : false;
  -        }
  -    }
  -
  -    public void release( final Object component )
  -    {
  -        final ComponentHandler handler = (ComponentHandler)m_used.remove( new ComponentKey( component ) );
  -        if( null == handler )
  -        {
  -            if( null == m_parent )
  -            {
  -                /* This is a purplexing problem.  SOmetimes the m_used hash
  -                 * returns null for the component--usually a ThreadSafe
  -                 * component.  When there is no handler and no parent, that
  -                 * is an error condition--but if the component is usually
  -                 * ThreadSafe, the impact is essentially nill.
  -                 */
  -                //Pete: This occurs when objects are released more often than
  -                //when they are aquired
  -                //Pete: It also happens when a release of a ComponentSelector occurs
  -            }
  -            else
  -            {
  -                m_parent.release( component );
  -            }
  -        }
  -        else
  -        {
  -            handler.put( component );
  -        }
  -    }
  -
  -    private Lookup parseRole( String role )
  -    {
  -        Lookup lookup = new Lookup();
  -        lookup.m_role = role;
  -        lookup.m_hint = AbstractContainer.DEFAULT_ENTRY;
  -
  -        if( role.endsWith( "Selector" ) )
  -        {
  -            lookup.m_role = role.substring( 0, role.length() - "Selector".length() );
  -            lookup.m_hint = AbstractContainer.SELECTOR_ENTRY;
  -        }
  -
  -        int index = role.lastIndexOf( "/" );
  -
  -        // needs to be further than the first character
  -        if( index > 0 )
  -        {
  -            lookup.m_role = role.substring( 0, index );
  -            lookup.m_hint = role.substring( index + 1 );
  -        }
  -
  -        return lookup;
  -    }
  -
  -    private final static class Lookup
  -    {
  -        String m_role;
  -        String m_hint;
  -    }
  -}
  +/*
  +
  + ============================================================================
  +                   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.fortress.impl.lookup;
  +
  +import java.util.Map;
  +import org.apache.avalon.fortress.Container;
  +import org.apache.avalon.fortress.impl.AbstractContainer;
  +import org.apache.avalon.fortress.impl.handler.ComponentHandler;
  +import org.apache.avalon.framework.component.ComponentSelector;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.ServiceSelector;
  +import org.apache.avalon.framework.service.WrapperServiceSelector;
  +import org.apache.commons.collections.StaticBucketMap;
  +
  +/**
  + * This is the Default ServiceManager for the Container.  It provides
  + * a very simple abstraction, and makes it easy for the Container to manage
  + * the references.
  + *
  + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  + * @version CVS $Revision$ $Date$
  + */
  +public class FortressServiceManager
  +    implements ServiceManager
  +{
  +    private final Container m_container;
  +    private final Map m_used;
  +    private final ServiceManager m_parent;
  +
  +    /**
  +     * This constructor is for a ContainerComponentManager with a parent
  +     * ComponentLocator
  +     * @param container the impl
  +     * @param parent the parent service manager
  +     * @exception NullPointerException if the supplied impl is null
  +     * @exception NullPointerException if the supplied parent is null
  +     */
  +    public FortressServiceManager( final Container container,
  +                                   final ServiceManager parent ) throws NullPointerException
  +    {
  +        if( null == container )
  +        {
  +            throw new NullPointerException( "impl" );
  +        }
  +        if( null == parent )
  +        {
  +            throw new NullPointerException( "parent" );
  +        }
  +
  +        m_parent = parent;
  +        m_container = container;
  +        m_used = new StaticBucketMap();
  +    }
  +
  +    public Object lookup( final String role )
  +        throws ServiceException
  +    {
  +        Lookup lookup = parseRole( role );
  +
  +        if( !m_container.has( lookup.m_role, lookup.m_hint ) )
  +        {
  +            return m_parent.lookup( role );
  +        }
  +
  +        final Object result = m_container.get( lookup.m_role, lookup.m_hint );
  +        if( result instanceof ServiceSelector )
  +        {
  +            return result;
  +        }
  +
  +        if( result instanceof ComponentSelector )
  +        {
  +            return new WrapperServiceSelector( lookup.m_role, (ComponentSelector)result );
  +        }
  +
  +        if( !( result instanceof ComponentHandler ) )
  +        {
  +            final String message = "Invalid entry in component manager";
  +            throw new ServiceException( role, message );
  +        }
  +
  +        try
  +        {
  +            final ComponentHandler handler = (ComponentHandler)result;
  +            final Object component = handler.get();
  +
  +            m_used.put( new ComponentKey( component ), handler );
  +            return component;
  +        }
  +        catch( final ServiceException ce )
  +        {
  +            throw ce; // rethrow
  +        }
  +        catch( final Exception e )
  +        {
  +            final String message =
  +                "Could not return a reference to the Component";
  +            throw new ServiceException( role, message, e );
  +        }
  +    }
  +
  +    public boolean hasService( final String role )
  +    {
  +        Lookup lookup = parseRole( role );
  +
  +        if( m_container.has( lookup.m_role, lookup.m_hint ) )
  +        {
  +            return true;
  +        }
  +        else
  +        {
  +            return null != m_parent ? m_parent.hasService( role ) : false;
  +        }
  +    }
  +
  +    public void release( final Object component )
  +    {
  +        final ComponentHandler handler = (ComponentHandler)m_used.remove( new ComponentKey( component ) );
  +        if( null == handler )
  +        {
  +            if( null == m_parent )
  +            {
  +                /* This is a purplexing problem.  SOmetimes the m_used hash
  +                 * returns null for the component--usually a ThreadSafe
  +                 * component.  When there is no handler and no parent, that
  +                 * is an error condition--but if the component is usually
  +                 * ThreadSafe, the impact is essentially nill.
  +                 */
  +                //Pete: This occurs when objects are released more often than
  +                //when they are aquired
  +                //Pete: It also happens when a release of a ComponentSelector occurs
  +            }
  +            else
  +            {
  +                m_parent.release( component );
  +            }
  +        }
  +        else
  +        {
  +            handler.put( component );
  +        }
  +    }
  +
  +    private Lookup parseRole( String role )
  +    {
  +        Lookup lookup = new Lookup();
  +        lookup.m_role = role;
  +        lookup.m_hint = AbstractContainer.DEFAULT_ENTRY;
  +
  +        if( role.endsWith( "Selector" ) )
  +        {
  +            lookup.m_role = role.substring( 0, role.length() - "Selector".length() );
  +            lookup.m_hint = AbstractContainer.SELECTOR_ENTRY;
  +        }
  +
  +        int index = role.lastIndexOf( "/" );
  +
  +        // needs to be further than the first character
  +        if( index > 0 )
  +        {
  +            lookup.m_role = role.substring( 0, index );
  +            lookup.m_hint = role.substring( index + 1 );
  +        }
  +
  +        return lookup;
  +    }
  +
  +    private final static class Lookup
  +    {
  +        String m_role;
  +        String m_hint;
  +    }
  +}
  
  
  
  1.10      +153 -153  avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/lookup/FortressServiceSelector.java
  
  Index: FortressServiceSelector.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/lookup/FortressServiceSelector.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FortressServiceSelector.java	22 Mar 2003 12:46:34 -0000	1.9
  +++ FortressServiceSelector.java	11 Apr 2003 07:38:30 -0000	1.10
  @@ -1,153 +1,153 @@
  -/*
  -
  - ============================================================================
  -                   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.fortress.impl.lookup;
  -
  -import java.util.Map;
  -import org.apache.avalon.fortress.Container;
  -import org.apache.avalon.fortress.impl.handler.ComponentHandler;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceSelector;
  -import org.apache.commons.collections.StaticBucketMap;
  -
  -/**
  - * This is the Default ServiceSelector for the Container.  It provides
  - * a very simple abstraction, and makes it easy for the Container to manage
  - * the references.
  - *
  - * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  - * @version CVS $Revision$ $Date$
  - */
  -public class FortressServiceSelector
  -    implements ServiceSelector
  -{
  -    private final String m_key;
  -    private final Container m_container;
  -    private final Map m_used;
  -
  -    /**
  -     * Creation of  new service selector.
  -     * @param container the impl
  -     * @param key a key
  -     */
  -    public FortressServiceSelector( final Container container,
  -                                    final String key )
  -    {
  -        if( null == container )
  -        {
  -            throw new NullPointerException( "impl" );
  -        }
  -        if( null == key )
  -        {
  -            throw new NullPointerException( "key" );
  -        }
  -
  -        m_key = key;
  -        m_container = container;
  -        m_used = new StaticBucketMap();
  -    }
  -
  -    public Object select( final Object hint )
  -        throws ServiceException
  -    {
  -        try
  -        {
  -            final ComponentHandler handler = getHandler( hint );
  -            final Object component = handler.get();
  -            m_used.put( new ComponentKey( component ), handler );
  -            return component;
  -        }
  -        catch( final ServiceException ce )
  -        {
  -            throw ce; // rethrow
  -        }
  -        catch( final Exception e )
  -        {
  -            final String name = m_key + "/" + hint.toString();
  -            final String message = "Could not return a reference to the Component";
  -            throw new ServiceException( name, message, e );
  -        }
  -    }
  -
  -    public boolean isSelectable( final Object hint )
  -    {
  -        return m_container.has( m_key, hint );
  -    }
  -
  -    public void release( Object component )
  -    {
  -        final ComponentHandler handler =
  -            (ComponentHandler)m_used.remove( new ComponentKey( component ) );
  -        if( null != handler )
  -        {
  -            handler.put( component );
  -        }
  -    }
  -
  -    private ComponentHandler getHandler( final Object hint )
  -        throws ServiceException
  -    {
  -        if( null == hint )
  -        {
  -            final String message = "hint cannot be null";
  -            throw new IllegalArgumentException( message );
  -        }
  -
  -        final ComponentHandler handler =
  -            (ComponentHandler)m_container.get( m_key, hint );
  -        if( null == handler )
  -        {
  -            final String message =
  -                "The hint does not exist in the ComponentSelector";
  -            throw new ServiceException( m_key + "/" + hint.toString(),
  -                                        message );
  -        }
  -        return handler;
  -    }
  -}
  +/*
  +
  + ============================================================================
  +                   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.fortress.impl.lookup;
  +
  +import java.util.Map;
  +import org.apache.avalon.fortress.Container;
  +import org.apache.avalon.fortress.impl.handler.ComponentHandler;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceSelector;
  +import org.apache.commons.collections.StaticBucketMap;
  +
  +/**
  + * This is the Default ServiceSelector for the Container.  It provides
  + * a very simple abstraction, and makes it easy for the Container to manage
  + * the references.
  + *
  + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  + * @version CVS $Revision$ $Date$
  + */
  +public class FortressServiceSelector
  +    implements ServiceSelector
  +{
  +    private final String m_key;
  +    private final Container m_container;
  +    private final Map m_used;
  +
  +    /**
  +     * Creation of  new service selector.
  +     * @param container the impl
  +     * @param key a key
  +     */
  +    public FortressServiceSelector( final Container container,
  +                                    final String key )
  +    {
  +        if( null == container )
  +        {
  +            throw new NullPointerException( "impl" );
  +        }
  +        if( null == key )
  +        {
  +            throw new NullPointerException( "key" );
  +        }
  +
  +        m_key = key;
  +        m_container = container;
  +        m_used = new StaticBucketMap();
  +    }
  +
  +    public Object select( final Object hint )
  +        throws ServiceException
  +    {
  +        try
  +        {
  +            final ComponentHandler handler = getHandler( hint );
  +            final Object component = handler.get();
  +            m_used.put( new ComponentKey( component ), handler );
  +            return component;
  +        }
  +        catch( final ServiceException ce )
  +        {
  +            throw ce; // rethrow
  +        }
  +        catch( final Exception e )
  +        {
  +            final String name = m_key + "/" + hint.toString();
  +            final String message = "Could not return a reference to the Component";
  +            throw new ServiceException( name, message, e );
  +        }
  +    }
  +
  +    public boolean isSelectable( final Object hint )
  +    {
  +        return m_container.has( m_key, hint );
  +    }
  +
  +    public void release( Object component )
  +    {
  +        final ComponentHandler handler =
  +            (ComponentHandler)m_used.remove( new ComponentKey( component ) );
  +        if( null != handler )
  +        {
  +            handler.put( component );
  +        }
  +    }
  +
  +    private ComponentHandler getHandler( final Object hint )
  +        throws ServiceException
  +    {
  +        if( null == hint )
  +        {
  +            final String message = "hint cannot be null";
  +            throw new IllegalArgumentException( message );
  +        }
  +
  +        final ComponentHandler handler =
  +            (ComponentHandler)m_container.get( m_key, hint );
  +        if( null == handler )
  +        {
  +            final String message =
  +                "The hint does not exist in the ComponentSelector";
  +            throw new ServiceException( m_key + "/" + hint.toString(),
  +                                        message );
  +        }
  +        return handler;
  +    }
  +}
  
  
  
  1.18      +4 -4      avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/util/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/util/ContextManager.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ContextManager.java	7 Apr 2003 20:46:59 -0000	1.17
  +++ ContextManager.java	11 Apr 2003 07:38:30 -0000	1.18
  @@ -557,8 +557,8 @@
        */
       protected void initializeServiceManager() throws Exception
       {
  -        final ServiceManager parent = (ServiceManager)get(m_rootContext, SERVICE_MANAGER, null);
  -        final DefaultServiceManager manager = new DefaultServiceManager(parent);
  +        final ServiceManager parent = (ServiceManager)get( m_rootContext, SERVICE_MANAGER, null );
  +        final DefaultServiceManager manager = new DefaultServiceManager( parent );
           final DefaultServiceSelector selector = new DefaultServiceSelector();
           final URLSourceFactory file = new URLSourceFactory();
           file.enableLogging( getLogger() );
  @@ -582,7 +582,7 @@
           assumeOwnership( manager );
   
           m_manager = manager;
  -        
  +
           m_childContext.put( ContextManagerConstants.SERVICE_MANAGER, m_manager );
       }
   
  
  
  
  1.12      +2 -2      avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/util/FortressConfig.java
  
  Index: FortressConfig.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/util/FortressConfig.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FortressConfig.java	29 Mar 2003 18:53:24 -0000	1.11
  +++ FortressConfig.java	11 Apr 2003 07:38:30 -0000	1.12
  @@ -125,7 +125,7 @@
   
           File contextDir = new File( System.getProperty( "user.dir" ) );
           File workDir = new File( System.getProperty( "java.io.tmpdir" ) );
  -        
  +
           defaultContext.put( ContextManagerConstants.THREADS_CPU, new Integer( 2 ) );
           defaultContext.put( ContextManagerConstants.THREAD_TIMEOUT, new Long( 1000 ) );
           defaultContext.put( ContextManagerConstants.CONTEXT_DIRECTORY, contextDir );
  
  
  

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


Mime
View raw message