avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/util/system Linux.java Windows98.java
Date Tue, 26 Feb 2002 02:06:31 GMT
leif        02/02/25 18:06:31

  Modified:    src/scratchpad/org/apache/avalon/excalibur/mpool
                        ObjectFactory.java Pool.java
               src/scratchpad/org/apache/avalon/excalibur/profile
                        AbstractProfilePoint.java
                        EventsPerSampleProfilePoint.java
                        PeekValueProfilePoint.java Profilable.java
                        ProfilePoint.java Profiler.java
                        ValueProfilePoint.java
               src/scratchpad/org/apache/avalon/excalibur/system/test
                        ContainerProfile.java TestContainer.java
               src/scratchpad/org/apache/avalon/excalibur/system/util
                        AbstractRoleManager.java
                        ConfigurableRoleManager.java ContextManager.java
                        ExcaliburRoleManager.java RoleManager.java
               src/scratchpad/org/apache/avalon/excalibur/system/util/test
                        ConfigurableRoleManagerTestCase.java
                        ExcaliburRoleManagerTestCase.java
               src/scratchpad/org/apache/avalon/excalibur/util/system
                        Linux.java Windows98.java
  Log:
  Fix files which were checked in with ^m^j Line Feeds.
  There were no other changes in this commit.
  
  Revision  Changes    Path
  1.2       +47 -47    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/mpool/ObjectFactory.java
  
  Index: ObjectFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/mpool/ObjectFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ObjectFactory.java	13 Feb 2002 16:19:53 -0000	1.1
  +++ ObjectFactory.java	26 Feb 2002 02:06:30 -0000	1.2
  @@ -1,47 +1,47 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.mpool;
  -
  -/**
  - * This interface is to define how an ObjectFactory is defined.  While this
  - * class is not strictly necessary, the implementation of the Pool can differ
  - * object creation to and instance of this interface.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/13 16:19:53 $
  - * @since 4.1.2
  - */
  -public interface ObjectFactory
  -{
  -    /**
  -     * Create a new instance of the object being pooled.
  -     *
  -     * @return the pooled Object instance
  -     * @throws Exception if the object cannot be instantiated
  -     */
  -    Object newInstance() throws Exception;
  -
  -    /**
  -     * Get the class of the object you are creating.
  -     *
  -     * @return Class object of the factory's class
  -     */
  -    Class getCreatedClass();
  -
  -    /**
  -     * Performs any deconstruction that is necessary for the
  -     * object.
  -     *
  -     * @param object to destroy
  -     * @throws IllegalArgumentException if the object is not of
  -     *         the same class that the factory creates.
  -     * @throws Exception if there is any other reason that the
  -     *         factory has problems disposing of the object.
  -     */
  -    void dispose(Object object) throws Exception;
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.mpool;
  +
  +/**
  + * This interface is to define how an ObjectFactory is defined.  While this
  + * class is not strictly necessary, the implementation of the Pool can differ
  + * object creation to and instance of this interface.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/26 02:06:30 $
  + * @since 4.1.2
  + */
  +public interface ObjectFactory
  +{
  +    /**
  +     * Create a new instance of the object being pooled.
  +     *
  +     * @return the pooled Object instance
  +     * @throws Exception if the object cannot be instantiated
  +     */
  +    Object newInstance() throws Exception;
  +
  +    /**
  +     * Get the class of the object you are creating.
  +     *
  +     * @return Class object of the factory's class
  +     */
  +    Class getCreatedClass();
  +
  +    /**
  +     * Performs any deconstruction that is necessary for the
  +     * object.
  +     *
  +     * @param object to destroy
  +     * @throws IllegalArgumentException if the object is not of
  +     *         the same class that the factory creates.
  +     * @throws Exception if there is any other reason that the
  +     *         factory has problems disposing of the object.
  +     */
  +    void dispose(Object object) throws Exception;
  +}
  
  
  
  1.2       +54 -54    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/mpool/Pool.java
  
  Index: Pool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/mpool/Pool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Pool.java	13 Feb 2002 16:19:53 -0000	1.1
  +++ Pool.java	26 Feb 2002 02:06:30 -0000	1.2
  @@ -1,54 +1,54 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.mpool;
  -
  -/**
  - * This interface is to define how a Pool is used.  We have determined by
  - * using the previous Pool implementations that the Pool marker interface
  - * is considered harmful.  When generics are introduced in JDK 1.5, this
  - * interface will be a prime candidate for those improvements.
  - *
  - * <p>
  - *  It is important to realize that some objects are cheaper to simply allow
  - *  the garbage collector to take care of them.  Therefore, only pool objects
  - *  that are computationally expensive to create.  Prime candidates would be
  - *  Components, JDBC Connection objects, Socket connections, etc.
  - * </p>
  - * <p>
  - *  The interface is inspired by both the Mutex acquire/release and the
  - *  structure of the ThreadLocal object.  In fact, it would be trivial
  - *  to implement a "ThreadLocal" pool.
  - * </p>
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/13 16:19:53 $
  - * @since 4.1.2
  - */
  -public interface Pool
  -{
  -    /**
  -     * Acquire an instance of the pooled object.
  -     *
  -     * @return the pooled Object instance
  -     */
  -    Object acquire() throws Exception;
  -
  -    /**
  -     * Release the instance of the pooled object.
  -     *
  -     * @param pooledObject  The pooled object to release to the pool.
  -     */
  -    void release( Object pooledObject );
  -
  -    /**
  -     * Create a new instance of the object being pooled.
  -     *
  -     * @return the pooled Object instance
  -     */
  -    Object newInstance() throws Exception;
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.mpool;
  +
  +/**
  + * This interface is to define how a Pool is used.  We have determined by
  + * using the previous Pool implementations that the Pool marker interface
  + * is considered harmful.  When generics are introduced in JDK 1.5, this
  + * interface will be a prime candidate for those improvements.
  + *
  + * <p>
  + *  It is important to realize that some objects are cheaper to simply allow
  + *  the garbage collector to take care of them.  Therefore, only pool objects
  + *  that are computationally expensive to create.  Prime candidates would be
  + *  Components, JDBC Connection objects, Socket connections, etc.
  + * </p>
  + * <p>
  + *  The interface is inspired by both the Mutex acquire/release and the
  + *  structure of the ThreadLocal object.  In fact, it would be trivial
  + *  to implement a "ThreadLocal" pool.
  + * </p>
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/26 02:06:30 $
  + * @since 4.1.2
  + */
  +public interface Pool
  +{
  +    /**
  +     * Acquire an instance of the pooled object.
  +     *
  +     * @return the pooled Object instance
  +     */
  +    Object acquire() throws Exception;
  +
  +    /**
  +     * Release the instance of the pooled object.
  +     *
  +     * @param pooledObject  The pooled object to release to the pool.
  +     */
  +    void release( Object pooledObject );
  +
  +    /**
  +     * Create a new instance of the object being pooled.
  +     *
  +     * @return the pooled Object instance
  +     */
  +    Object newInstance() throws Exception;
  +}
  
  
  
  1.4       +37 -37    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/AbstractProfilePoint.java
  
  Index: AbstractProfilePoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/AbstractProfilePoint.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractProfilePoint.java	13 Dec 2001 22:17:50 -0000	1.3
  +++ AbstractProfilePoint.java	26 Feb 2002 02:06:30 -0000	1.4
  @@ -1,37 +1,37 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.profile;
  -
  -/**
  - * The ProfilPoint interface is to mark objects that can be sampled by a
  - * Profiler. The interface only has one sampling method to simplify the items
  - * that can be sampled.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - */
  -public abstract class AbstractProfilePoint implements ProfilePoint
  -{
  -    private final String m_name;
  -
  -    /**
  -     * Initializes the ProfilePoint with a name.
  -     */
  -    public AbstractProfilePoint( String name )
  -    {
  -        m_name = name;
  -    }
  -
  -    /**
  -     * Get the ProfilePoint's name.  The Profiler uses this so that the
  -     * heading for the sample data makes sense.
  -     */
  -    public final String getName()
  -    {
  -        return m_name;
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.profile;
  +
  +/**
  + * The ProfilPoint interface is to mark objects that can be sampled by a
  + * Profiler. The interface only has one sampling method to simplify the items
  + * that can be sampled.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + */
  +public abstract class AbstractProfilePoint implements ProfilePoint
  +{
  +    private final String m_name;
  +
  +    /**
  +     * Initializes the ProfilePoint with a name.
  +     */
  +    public AbstractProfilePoint( String name )
  +    {
  +        m_name = name;
  +    }
  +
  +    /**
  +     * Get the ProfilePoint's name.  The Profiler uses this so that the
  +     * heading for the sample data makes sense.
  +     */
  +    public final String getName()
  +    {
  +        return m_name;
  +    }
  +}
  
  
  
  1.3       +49 -49    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/EventsPerSampleProfilePoint.java
  
  Index: EventsPerSampleProfilePoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/EventsPerSampleProfilePoint.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EventsPerSampleProfilePoint.java	13 Dec 2001 20:37:13 -0000	1.2
  +++ EventsPerSampleProfilePoint.java	26 Feb 2002 02:06:30 -0000	1.3
  @@ -1,49 +1,49 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.profile;
  -
  -/**
  - * The ProfilPoint interface is to mark objects that can be sampled by a
  - * Profiler. The interface only has one sampling method to simplify the items
  - * that can be sampled.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - */
  -public class EventsPerSampleProfilePoint extends AbstractProfilePoint
  -{
  -    private       int    m_value = 0;
  -
  -    /**
  -     * Creates a EventsPerSampleProfilePoint with an initial name.
  -     */
  -    public EventsPerSampleProfilePoint( String name )
  -    {
  -        super( name );
  -    }
  -
  -    /**
  -     * Set the sample value
  -     */
  -    public void increment( )
  -    {
  -        m_value++;
  -    }
  -
  -    /**
  -     * Obtain the sample.  All samples are an integer, so the profiled objects
  -     * must measure quantity (numbers of items), rate (items/period), time in
  -     * milliseconds, etc.
  -     */
  -    public int getSample()
  -    {
  -        final int returnValue = m_value;
  -        m_value = 0;
  -
  -        return returnValue;
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.profile;
  +
  +/**
  + * The ProfilPoint interface is to mark objects that can be sampled by a
  + * Profiler. The interface only has one sampling method to simplify the items
  + * that can be sampled.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + */
  +public class EventsPerSampleProfilePoint extends AbstractProfilePoint
  +{
  +    private       int    m_value = 0;
  +
  +    /**
  +     * Creates a EventsPerSampleProfilePoint with an initial name.
  +     */
  +    public EventsPerSampleProfilePoint( String name )
  +    {
  +        super( name );
  +    }
  +
  +    /**
  +     * Set the sample value
  +     */
  +    public void increment( )
  +    {
  +        m_value++;
  +    }
  +
  +    /**
  +     * Obtain the sample.  All samples are an integer, so the profiled objects
  +     * must measure quantity (numbers of items), rate (items/period), time in
  +     * milliseconds, etc.
  +     */
  +    public int getSample()
  +    {
  +        final int returnValue = m_value;
  +        m_value = 0;
  +
  +        return returnValue;
  +    }
  +}
  
  
  
  1.3       +49 -49    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/PeekValueProfilePoint.java
  
  Index: PeekValueProfilePoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/PeekValueProfilePoint.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PeekValueProfilePoint.java	13 Dec 2001 20:37:13 -0000	1.2
  +++ PeekValueProfilePoint.java	26 Feb 2002 02:06:30 -0000	1.3
  @@ -1,49 +1,49 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.profile;
  -
  -/**
  - * The ProfilPoint interface is to mark objects that can be sampled by a
  - * Profiler. The interface only has one sampling method to simplify the items
  - * that can be sampled.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - */
  -public class PeekValueProfilePoint extends AbstractProfilePoint
  -{
  -    private       int    m_value = 0;
  -
  -    /**
  -     * Creates a PeekValueProfilePoint with an initial name.
  -     */
  -    public PeekValueProfilePoint( String name )
  -    {
  -        super( name );
  -    }
  -
  -    /**
  -     * Set the sample value
  -     */
  -    public void setValue( int currentValue )
  -    {
  -        if ( currentValue > m_value )
  -        {
  -            m_value = currentValue;
  -        }
  -    }
  -
  -    /**
  -     * Obtain the sample.  All samples are an integer, so the profiled objects
  -     * must measure quantity (numbers of items), rate (items/period), time in
  -     * milliseconds, etc.
  -     */
  -    public int getSample()
  -    {
  -        return m_value;
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.profile;
  +
  +/**
  + * The ProfilPoint interface is to mark objects that can be sampled by a
  + * Profiler. The interface only has one sampling method to simplify the items
  + * that can be sampled.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + */
  +public class PeekValueProfilePoint extends AbstractProfilePoint
  +{
  +    private       int    m_value = 0;
  +
  +    /**
  +     * Creates a PeekValueProfilePoint with an initial name.
  +     */
  +    public PeekValueProfilePoint( String name )
  +    {
  +        super( name );
  +    }
  +
  +    /**
  +     * Set the sample value
  +     */
  +    public void setValue( int currentValue )
  +    {
  +        if ( currentValue > m_value )
  +        {
  +            m_value = currentValue;
  +        }
  +    }
  +
  +    /**
  +     * Obtain the sample.  All samples are an integer, so the profiled objects
  +     * must measure quantity (numbers of items), rate (items/period), time in
  +     * milliseconds, etc.
  +     */
  +    public int getSample()
  +    {
  +        return m_value;
  +    }
  +}
  
  
  
  1.5       +65 -65    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/Profilable.java
  
  Index: Profilable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/Profilable.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Profilable.java	12 Feb 2002 15:12:30 -0000	1.4
  +++ Profilable.java	26 Feb 2002 02:06:30 -0000	1.5
  @@ -1,65 +1,65 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.profile;
  -
  -/**
  - * The Profilable interface is to mark objects that can be sampled by a Profiler.
  - * The interface provides a method to initialize the profiler, plus two methods
  - * to provide an optimization cue for the object (when it is safe not to track
  - * events).
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - */
  -public interface Profilable
  -{
  -    /**
  -     * Empty Profilable array for use in hierarchical Profilable systems.
  -     */
  -    Profilable[] EMPTY_PROFILABLE_ARRAY = new Profilable[] {};
  -
  -    /**
  -     * Gets the name of the Profileable class.  Good names include what the
  -     * expected samples are.  For instance "ThreadController: number of threads"
  -     * or "EventQueue: events processed per second".  The real results come from
  -     * the Profilable object itself, but the name is so humans have a reference
  -     * for the values.  This name also scopes the names supplied by the
  -     * ProfilePoints.
  -     */
  -    String getName();
  -
  -    /**
  -     * Obtain a reference to all the ProfilePoints that the Profilable
  -     * object wishes to expose.  All sampling is done directly through
  -     * the ProfilePoints as opposed to the Profilable interface.
  -     */
  -    ProfilePoint[] getProfilePoints();
  -
  -    /**
  -     * The Profiler will call this method when it begins taking samples.
  -     * This is an optimization cue to the Profilable class.  It does take
  -     * resources to hold ProfilePoints and update them.  A class may keep
  -     * a <code>boolean</code> to flag whether the ProfilePoints are to be
  -     * maintained.
  -     */
  -    void startProfiling();
  -
  -    /**
  -     * The Profiler will call this method when it no longer is interested
  -     * in taking samples.  It is an optimization cue to the Profilable
  -     * class so that it can release resources and stop maintaining the
  -     * ProfilePoints.
  -     */
  -    void stopProfiling();
  -
  -    /**
  -     * The Profiler will recursively call this method until it receives an
  -     * EMPTY_PROFILABLE_ARRAY.  This method should never return null.
  -     */
  -    Profilable[] getChildProfilables();
  -}
  -
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.profile;
  +
  +/**
  + * The Profilable interface is to mark objects that can be sampled by a Profiler.
  + * The interface provides a method to initialize the profiler, plus two methods
  + * to provide an optimization cue for the object (when it is safe not to track
  + * events).
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + */
  +public interface Profilable
  +{
  +    /**
  +     * Empty Profilable array for use in hierarchical Profilable systems.
  +     */
  +    Profilable[] EMPTY_PROFILABLE_ARRAY = new Profilable[] {};
  +
  +    /**
  +     * Gets the name of the Profileable class.  Good names include what the
  +     * expected samples are.  For instance "ThreadController: number of threads"
  +     * or "EventQueue: events processed per second".  The real results come from
  +     * the Profilable object itself, but the name is so humans have a reference
  +     * for the values.  This name also scopes the names supplied by the
  +     * ProfilePoints.
  +     */
  +    String getName();
  +
  +    /**
  +     * Obtain a reference to all the ProfilePoints that the Profilable
  +     * object wishes to expose.  All sampling is done directly through
  +     * the ProfilePoints as opposed to the Profilable interface.
  +     */
  +    ProfilePoint[] getProfilePoints();
  +
  +    /**
  +     * The Profiler will call this method when it begins taking samples.
  +     * This is an optimization cue to the Profilable class.  It does take
  +     * resources to hold ProfilePoints and update them.  A class may keep
  +     * a <code>boolean</code> to flag whether the ProfilePoints are to be
  +     * maintained.
  +     */
  +    void startProfiling();
  +
  +    /**
  +     * The Profiler will call this method when it no longer is interested
  +     * in taking samples.  It is an optimization cue to the Profilable
  +     * class so that it can release resources and stop maintaining the
  +     * ProfilePoints.
  +     */
  +    void stopProfiling();
  +
  +    /**
  +     * The Profiler will recursively call this method until it receives an
  +     * EMPTY_PROFILABLE_ARRAY.  This method should never return null.
  +     */
  +    Profilable[] getChildProfilables();
  +}
  +
  
  
  
  1.3       +31 -31    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/ProfilePoint.java
  
  Index: ProfilePoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/ProfilePoint.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProfilePoint.java	13 Dec 2001 20:37:13 -0000	1.2
  +++ ProfilePoint.java	26 Feb 2002 02:06:30 -0000	1.3
  @@ -1,31 +1,31 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.profile;
  -
  -/**
  - * The ProfilPoint interface is to mark objects that can be sampled by a
  - * Profiler. The interface only has one sampling method to simplify the items
  - * that can be sampled.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - */
  -public interface ProfilePoint
  -{
  -    /**
  -     * Get the ProfilePoint's name.  The Profiler uses this so that the
  -     * heading for the sample data makes sense.
  -     */
  -    String getName();
  -
  -    /**
  -     * Obtain the sample.  All samples are an integer, so the profiled objects
  -     * must measure quantity (numbers of items), rate (items/period), time in
  -     * milliseconds, etc.
  -     */
  -    int getSample();
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.profile;
  +
  +/**
  + * The ProfilPoint interface is to mark objects that can be sampled by a
  + * Profiler. The interface only has one sampling method to simplify the items
  + * that can be sampled.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + */
  +public interface ProfilePoint
  +{
  +    /**
  +     * Get the ProfilePoint's name.  The Profiler uses this so that the
  +     * heading for the sample data makes sense.
  +     */
  +    String getName();
  +
  +    /**
  +     * Obtain the sample.  All samples are an integer, so the profiled objects
  +     * must measure quantity (numbers of items), rate (items/period), time in
  +     * milliseconds, etc.
  +     */
  +    int getSample();
  +}
  
  
  
  1.5       +63 -63    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/Profiler.java
  
  Index: Profiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/Profiler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Profiler.java	12 Feb 2002 15:12:30 -0000	1.4
  +++ Profiler.java	26 Feb 2002 02:06:30 -0000	1.5
  @@ -1,63 +1,63 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.profile;
  -
  -import java.io.File;
  -import java.io.IOException;
  -
  -/**
  - * The Profiler is used to determine numeric values for specific parts of the
  - * Avalon environment.  The idea is to add references to Profilable objects to
  - * the Profiler.  The Profiler takes periodic snapshots of the running system
  - * so that performance or resource usage can be assertained.  The sample duration
  - * is dependant on the Profiler's settings, and should never change during the
  - * time the Profiler is running.
  - *
  - * <p>
  - *   Please do respect that for more accurate statistical information, the first
  - *   and last sample must be thrown out.  The first sample may have residual
  - *   information from before the test, and the last sample may be from an
  - *   incomplete timeslice.  For instance, if the Profiler obtains a sample once
  - *   every second, and it stops itself 500ms after the previous sample, the last
  - *   sample will only represent 1/2 the typical timeslice.
  - * </p>
  - * <p>
  - *   Please also bear in mind that Java has a non-deterministic scheduler, and
  - *   samples may not be taken exactly on the specified interval.  This sample
  - *   <em>jitter</em> is acceptable when averaged over a longer period of time.
  - * </p>
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - */
  -public interface Profiler
  -{
  -    /**
  -     * Adds a target to profile.  NOTE: if the Profilable class does
  -     * not expose any ProfilePoints, it is excluded from the list of Profilable
  -     * classes that are notified when the Profiler is active.
  -     *
  -     * @parameter  profileSource  The actual source of the samples
  -     */
  -    void add( Profilable profileSource );
  -
  -    /**
  -     * Reports the results of the profiling to a ProfileReport.  The actual
  -     * format depends on the ProfileReport given.  It can be simple Comma
  -     * Separated Values (CSV) with the columns representing a unique Profilable.
  -     * Most spreadsheet programs can import this and generate meaningful graphs
  -     * from it.  Another alternative is to output the information in a tool
  -     * specific format.  The actual format depends on the ProfileReport in
  -     * question, and the Profiler merely needs to reference to the object.
  -     *
  -     * @parameter  outputInfo  The handle of the file the profiler serializes the
  -     *                         results to.
  -     *
  -     * @throws <code>NullPointerException</code> If the ProfileReport is null.
  -     */
  -    void report( ProfileReport outputInfo );
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.profile;
  +
  +import java.io.File;
  +import java.io.IOException;
  +
  +/**
  + * The Profiler is used to determine numeric values for specific parts of the
  + * Avalon environment.  The idea is to add references to Profilable objects to
  + * the Profiler.  The Profiler takes periodic snapshots of the running system
  + * so that performance or resource usage can be assertained.  The sample duration
  + * is dependant on the Profiler's settings, and should never change during the
  + * time the Profiler is running.
  + *
  + * <p>
  + *   Please do respect that for more accurate statistical information, the first
  + *   and last sample must be thrown out.  The first sample may have residual
  + *   information from before the test, and the last sample may be from an
  + *   incomplete timeslice.  For instance, if the Profiler obtains a sample once
  + *   every second, and it stops itself 500ms after the previous sample, the last
  + *   sample will only represent 1/2 the typical timeslice.
  + * </p>
  + * <p>
  + *   Please also bear in mind that Java has a non-deterministic scheduler, and
  + *   samples may not be taken exactly on the specified interval.  This sample
  + *   <em>jitter</em> is acceptable when averaged over a longer period of time.
  + * </p>
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + */
  +public interface Profiler
  +{
  +    /**
  +     * Adds a target to profile.  NOTE: if the Profilable class does
  +     * not expose any ProfilePoints, it is excluded from the list of Profilable
  +     * classes that are notified when the Profiler is active.
  +     *
  +     * @parameter  profileSource  The actual source of the samples
  +     */
  +    void add( Profilable profileSource );
  +
  +    /**
  +     * Reports the results of the profiling to a ProfileReport.  The actual
  +     * format depends on the ProfileReport given.  It can be simple Comma
  +     * Separated Values (CSV) with the columns representing a unique Profilable.
  +     * Most spreadsheet programs can import this and generate meaningful graphs
  +     * from it.  Another alternative is to output the information in a tool
  +     * specific format.  The actual format depends on the ProfileReport in
  +     * question, and the Profiler merely needs to reference to the object.
  +     *
  +     * @parameter  outputInfo  The handle of the file the profiler serializes the
  +     *                         results to.
  +     *
  +     * @throws <code>NullPointerException</code> If the ProfileReport is null.
  +     */
  +    void report( ProfileReport outputInfo );
  +}
  
  
  
  1.3       +46 -46    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/ValueProfilePoint.java
  
  Index: ValueProfilePoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/profile/ValueProfilePoint.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ValueProfilePoint.java	13 Dec 2001 20:37:13 -0000	1.2
  +++ ValueProfilePoint.java	26 Feb 2002 02:06:30 -0000	1.3
  @@ -1,46 +1,46 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.profile;
  -
  -/**
  - * The ProfilPoint interface is to mark objects that can be sampled by a
  - * Profiler. The interface only has one sampling method to simplify the items
  - * that can be sampled.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - */
  -public class ValueProfilePoint extends AbstractProfilePoint
  -{
  -    private       int    m_value = 0;
  -
  -    /**
  -     * Creates a ValueProfilePoint with an initial name.
  -     */
  -    public ValueProfilePoint( String name )
  -    {
  -        super( name );
  -    }
  -
  -    /**
  -     * Set the sample value
  -     */
  -    public void setValue( int currentValue )
  -    {
  -        m_value = currentValue;
  -    }
  -
  -    /**
  -     * Obtain the sample.  All samples are an integer, so the profiled objects
  -     * must measure quantity (numbers of items), rate (items/period), time in
  -     * milliseconds, etc.
  -     */
  -    public int getSample()
  -    {
  -        return m_value;
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.profile;
  +
  +/**
  + * The ProfilPoint interface is to mark objects that can be sampled by a
  + * Profiler. The interface only has one sampling method to simplify the items
  + * that can be sampled.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + */
  +public class ValueProfilePoint extends AbstractProfilePoint
  +{
  +    private       int    m_value = 0;
  +
  +    /**
  +     * Creates a ValueProfilePoint with an initial name.
  +     */
  +    public ValueProfilePoint( String name )
  +    {
  +        super( name );
  +    }
  +
  +    /**
  +     * Set the sample value
  +     */
  +    public void setValue( int currentValue )
  +    {
  +        m_value = currentValue;
  +    }
  +
  +    /**
  +     * Obtain the sample.  All samples are an integer, so the profiled objects
  +     * must measure quantity (numbers of items), rate (items/period), time in
  +     * milliseconds, etc.
  +     */
  +    public int getSample()
  +    {
  +        return m_value;
  +    }
  +}
  
  
  
  1.6       +408 -408  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/ContainerProfile.java
  
  Index: ContainerProfile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/ContainerProfile.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContainerProfile.java	20 Feb 2002 18:45:04 -0000	1.5
  +++ ContainerProfile.java	26 Feb 2002 02:06:30 -0000	1.6
  @@ -1,408 +1,408 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.test;
  -
  -import junit.framework.TestCase;
  -
  -import org.apache.avalon.excalibur.system.*;
  -import org.apache.avalon.excalibur.component.*;
  -import org.apache.avalon.excalibur.logger.*;
  -import org.apache.avalon.excalibur.testcase.*;
  -
  -import org.apache.avalon.excalibur.monitor.Monitor;
  -import org.apache.avalon.excalibur.datasource.DataSourceComponent;
  -import org.apache.avalon.excalibur.xml.Parser;
  -
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.context.*;
  -import org.apache.avalon.framework.configuration.*;
  -import org.apache.avalon.framework.parameters.*;
  -import org.apache.avalon.framework.logger.*;
  -import junit.textui.TestRunner;
  -
  -import java.net.URL;
  -
  -/**
  - * Used as a basis for the PoolComparisonProfile Tests
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version $Id: ContainerProfile.java,v 1.5 2002/02/20 18:45:04 bloritsch Exp $
  - */
  -public final class ContainerProfile
  -    extends TestCase
  -{
  -    /**
  -     * The TEST_SIZE defines the overall size of the tests.  Decreasing this will
  -     *  decrease the time the test takes to run, but also decrease its efficiency.
  -     */
  -    protected static final int      TEST_SIZE   = 50000;
  -    protected static final int      THREADS     = 100;
  -
  -    protected static Throwable      m_throwable = null;
  -    protected static int            m_getCount  = 0;
  -
  -    protected Logger                m_logger;
  -    protected org.apache.log.Logger m_logKitLogger;
  -
  -    /*---------------------------------------------------------------
  -     * Constructors
  -     *-------------------------------------------------------------*/
  -    public ContainerProfile(String name)
  -    {
  -        super(name);
  -
  -        // Set to debug to see more useful information.
  -        org.apache.log.Logger logger =
  -            org.apache.log.Hierarchy.getDefaultHierarchy().getLoggerFor( "test" );
  -        logger.setPriority( org.apache.log.Priority.INFO );
  -        m_logKitLogger = logger;
  -        m_logger = new LogKitLogger( logger );
  -    }
  -
  -    /*---------------------------------------------------------------
  -     * ECM vs. ContainerManager StartTimes
  -     *-------------------------------------------------------------*/
  -    /**
  -     * Compare the ECM and ContainerManager start times.
  -     */
  -    public void testCompare_ECM_ContainerManager_UseageTime()
  -        throws Exception
  -    {
  -        resetMemory(); // Start clean
  -
  -        long ecmStart = System.currentTimeMillis();
  -            ExcaliburComponentManager manager = new ExcaliburComponentManager();
  -            Context context = new DefaultContext();
  -            manager.setLogger(m_logKitLogger);
  -            manager.contextualize( context );
  -            DefaultLogKitManager logmanager = new DefaultLogKitManager();
  -            logmanager.setLogger(m_logKitLogger);
  -            logmanager.contextualize(context);
  -            logmanager.configure( getLogKitConfig() );
  -            manager.setLogKitManager(logmanager);
  -            manager.configure( getContainerConfig() );
  -            manager.initialize();
  -        long ecmStop = System.currentTimeMillis();
  -        long ecmDuration = ecmStop - ecmStart;
  -
  -        resetMemory(); // Start clean
  -
  -        long cmStart = System.currentTimeMillis();
  -            Parameters params = new Parameters();
  -            params.setParameter( ContainerManager.CONTAINER_CLASS, "org.apache.avalon.excalibur.system.test.TestContainer" );
  -            params.setParameter( ContainerManager.CONTEXT_DIRECTORY, "./" );
  -            params.setParameter( ContainerManager.WORK_DIRECTORY, "/tmp/" );
  -            params.setParameter( ContainerManager.CONTAINER_CONFIG, "resource://org/apache/avalon/excalibur/system/test/ContainerProfile.xconf" );
  -            params.setParameter( ContainerManager.LOG_CATEGORY, "test" );
  -            params.setParameter( ContainerManager.LOGKIT_CONFIG, "resource://org/apache/avalon/excalibur/system/test/ContainerProfile.xlog" );
  -            params.setParameter( ContainerManager.THREADS_CPU, "2" );
  -            params.makeReadOnly();
  -            ContainerManager cm = new ContainerManager( params, new NullLogger() );
  -            TestContainer container = (TestContainer) cm.getContainer();
  -            assertNotNull(container);
  -        long cmStop = System.currentTimeMillis();
  -        long cmDuration = cmStop - cmStart;
  -
  -        // Show a summary
  -        if ( m_logger.isInfoEnabled() )
  -        {
  -            m_logger.info( "Test Case: ECM_ContainerManager_StartTime" );
  -            m_logger.info( "     ECM time = " + ecmDuration + "ms." );
  -            m_logger.info( "     ContainerManager time = " + cmDuration + "ms." );
  -
  -            double mult;
  -            mult = ( cmDuration > 0 ? ( ecmDuration * 100 / cmDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  -            m_logger.info( "  => ContainerManager is " + mult + " X as fast as ExcaliburComponentManager on init." );
  -            mult = ( ecmDuration > 0 ? ( cmDuration * 100 / ecmDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  -            m_logger.info( "  => ExcaliburComponentManager is " + mult + " X as fast as ContainerManager on init." );
  -        }
  -
  -        resetMemory();
  -
  -        lookupTest( "Test Case: ECM_ContainerManager_UseageTime", container.getCM(), manager );
  -
  -        resetMemory();
  -
  -        ecmStart = System.currentTimeMillis();
  -            manager.dispose();
  -        ecmStop = System.currentTimeMillis();
  -        ecmDuration = ecmStop - ecmStart;
  -
  -        resetMemory();
  -
  -        cmStart = System.currentTimeMillis();
  -            cm.dispose();
  -        cmStop = System.currentTimeMillis();
  -        cmDuration = cmStop - cmStart;
  -
  -        // Show a summary
  -        if ( m_logger.isInfoEnabled() )
  -        {
  -            m_logger.info( "Test Case: ECM_ContainerManager_KillTime" );
  -            m_logger.info( "     ECM time = " + ecmDuration + "ms." );
  -            m_logger.info( "     ContainerManager time = " + cmDuration + "ms." );
  -
  -            double mult;
  -            mult = ( cmDuration > 0 ? ( ecmDuration * 100 / cmDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  -            m_logger.info( "  => ContainerManager is " + mult + " X as fast as ExcaliburComponentManager on dispose." );
  -            mult = ( ecmDuration > 0 ? ( cmDuration * 100 / ecmDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  -            m_logger.info( "  => ExcaliburComponentManager is " + mult + " X as fast as ContainerManager on dispose." );
  -        }
  -    }
  -
  -    /*---------------------------------------------------------------
  -     * Utility Methods
  -     *-------------------------------------------------------------*/
  -    protected void resetMemory()
  -    {
  -        System.gc();
  -        System.gc();
  -
  -        // Let the system settle down.
  -        try
  -        {
  -            Thread.sleep( 50 );
  -        }
  -        catch (InterruptedException e ) {}
  -        Runtime runtime = Runtime.getRuntime();
  -        m_logger.debug( "Memory: " + ( runtime.totalMemory() - runtime.freeMemory() ) );
  -    }
  -
  -    /**
  -     * Get the LogKitManager Config file
  -     */
  -    protected Configuration getLogKitConfig()
  -        throws Exception
  -    {
  -        final String resourceName = this.getClass().getName().replace( '.', '/' ) + ".xlog";
  -        URL resource = this.getClass().getClassLoader().getResource( resourceName );
  -        return loadConfig( resource );
  -    }
  -
  -    /**
  -     * Get the Container Config file
  -     */
  -    protected Configuration getContainerConfig()
  -        throws Exception
  -    {
  -        final String resourceName = this.getClass().getName().replace( '.', '/' ) + ".xconf";
  -        URL resource = this.getClass().getClassLoader().getResource( resourceName );
  -        return loadConfig( resource );
  -    }
  -
  -    /**
  -     * Load Config
  -     */
  -    protected Configuration loadConfig( URL path )
  -        throws Exception
  -    {
  -        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -        return builder.build( path.openStream() );
  -    }
  -
  -    /**
  -     * Get the short class name
  -     */
  -    protected String getShortClassName( Object o )
  -    {
  -        String name = o.getClass().getName();
  -        int pos = name.lastIndexOf('.');
  -        if ( pos > 0 )
  -        {
  -            name = name.substring( pos + 1 );
  -        }
  -        return name;
  -    }
  -
  -    /**
  -     * The guts of the various test cases.  Will dispose the pools
  -     */
  -    protected void lookupTest(String name, ComponentManager cmA, ComponentManager cmB)
  -        throws Exception
  -    {
  -        m_logger.info( "Test Case: " + name );
  -
  -        // Get the short class names
  -        final String cmAName = getShortClassName( cmA );
  -        final String cmBName = getShortClassName( cmB );
  -
  -        // Start clean
  -        resetMemory();
  -
  -
  -        // Get the time for ecm
  -        final long cmADuration = getLookupRunTime( cmA );
  -        m_logger.info( "     " + cmAName + " time = " + cmADuration + "ms. to use " + TEST_SIZE + " calls on 3 components." );
  -        resetMemory();
  -
  -
  -        // Get the time for manager
  -        final long cmBDuration = getLookupRunTime( cmB );
  -        m_logger.info( "     " + cmBName + " time = " + cmBDuration + "ms. to use " + TEST_SIZE + " calls on 3 components." );
  -        resetMemory();
  -
  -        // Show a summary
  -        if ( m_logger.isInfoEnabled() )
  -        {
  -            double mult;
  -            mult = ( cmADuration > 0 ? ( cmBDuration * 100 / cmADuration ) / 100.0 : Float.POSITIVE_INFINITY );
  -            m_logger.info( "  => " + cmAName + " is " + mult + " X as fast as " + cmBName + "." );
  -
  -            mult = ( cmBDuration > 0 ? ( cmADuration * 100 / cmBDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  -            m_logger.info( "  => " + cmBName + " is " + mult + " X as fast as " + cmAName + "." );
  -        }
  -    }
  -
  -    protected long getLookupRunTime( ComponentManager manager )
  -    {
  -        // Create the runnable
  -        LookupRunner runnable = new LookupRunner(manager, m_logger);
  -
  -        LatchedThreadGroup group = new LatchedThreadGroup( runnable, THREADS );
  -        group.enableLogging( m_logger );
  -
  -        long duration;
  -        try
  -        {
  -            duration = group.go();
  -        }
  -        catch ( Throwable t )
  -        {
  -            // Throwable could have been thrown by one of the tests.
  -            if (m_throwable == null) {
  -                m_throwable = t;
  -            }
  -            duration = 0;
  -        }
  -
  -        if ( m_throwable != null )
  -        {
  -            throw new CascadingAssertionFailedError( "Exception in test thread.", m_throwable );
  -        }
  -
  -        assertTrue( "m_getCount == 0 (" + m_getCount + ")", m_getCount == 0 );
  -
  -        return duration;
  -    }
  -
  -    private static class LookupRunner implements Runnable
  -    {
  -        private Logger m_logger;
  -        private ComponentManager m_manager;
  -        private int m_getCount = 0;
  -        private Throwable m_throwable = null;
  -
  -        public LookupRunner(ComponentManager manager, Logger logger)
  -        {
  -            m_manager = manager;
  -            m_logger = logger;
  -        }
  -
  -        public int getCount()
  -        {
  -            return m_getCount;
  -        }
  -
  -        public Throwable getThrowable()
  -        {
  -            return m_throwable;
  -        }
  -
  -        public void run()
  -        {
  -            // Perform this threads part of the test.
  -            final int loops = (TEST_SIZE / THREADS);
  -            for( int i = 0; i < loops; i++ )
  -            {
  -                Parser parser = null;
  -                DataSourceComponent datasource = null;
  -                Monitor monitor = null;
  -
  -                try
  -                {
  -                    parser = (Parser) m_manager.lookup(Parser.ROLE);
  -
  -                    // Make the loops hold the components longer than they are released, but only slightly.
  -                    Thread.yield();
  -                }
  -                catch (Throwable t)
  -                {
  -                    m_logger.error( "Unexpected error after " + m_getCount +
  -                                    " iterations retrieved for Parser", t );
  -
  -                    if (m_throwable == null) {
  -                        m_throwable = t;
  -                    }
  -                    return;
  -                }
  -                finally
  -                {
  -                    if ( null != parser )
  -                    {
  -                        m_manager.release( parser );
  -                    }
  -                }
  -                try
  -                {
  -                    datasource = (DataSourceComponent) m_manager.lookup(DataSourceComponent.ROLE);
  -
  -                    // Make the loops hold the components longer than they are released, but only slightly.
  -                    Thread.yield();
  -                }
  -                catch (Throwable t)
  -                {
  -                    m_logger.error( "Unexpected error after " + m_getCount +
  -                                    " iterations retrieved for DataSourceComponent", t );
  -
  -                    if (m_throwable == null) {
  -                        m_throwable = t;
  -                    }
  -                    return;
  -                }
  -                finally
  -                {
  -                    if ( null != datasource )
  -                    {
  -                        m_manager.release( datasource );
  -                    }
  -                }
  -
  -                try
  -                {
  -                    monitor = (Monitor) m_manager.lookup(Monitor.ROLE);
  -
  -                    // Make the loops hold the components longer than they are released, but only slightly.
  -                    Thread.yield();
  -                }
  -                catch (Throwable t)
  -                {
  -                    m_logger.error( "Unexpected error after " + m_getCount +
  -                                    " iterations retrieved for DataSourceComponent", t );
  -
  -                    if (m_throwable == null) {
  -                        m_throwable = t;
  -                    }
  -                    return;
  -                }
  -                finally
  -                {
  -                    if ( null != monitor )
  -                    {
  -                        m_manager.release( monitor );
  -                    }
  -                }
  -            }
  -        }
  -    }
  -
  -    public static final void main(String[] args)
  -    {
  -         TestRunner.run( ContainerProfile.class );
  -    }
  -}
  -
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.test;
  +
  +import junit.framework.TestCase;
  +
  +import org.apache.avalon.excalibur.system.*;
  +import org.apache.avalon.excalibur.component.*;
  +import org.apache.avalon.excalibur.logger.*;
  +import org.apache.avalon.excalibur.testcase.*;
  +
  +import org.apache.avalon.excalibur.monitor.Monitor;
  +import org.apache.avalon.excalibur.datasource.DataSourceComponent;
  +import org.apache.avalon.excalibur.xml.Parser;
  +
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.context.*;
  +import org.apache.avalon.framework.configuration.*;
  +import org.apache.avalon.framework.parameters.*;
  +import org.apache.avalon.framework.logger.*;
  +import junit.textui.TestRunner;
  +
  +import java.net.URL;
  +
  +/**
  + * Used as a basis for the PoolComparisonProfile Tests
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version $Id: ContainerProfile.java,v 1.6 2002/02/26 02:06:30 leif Exp $
  + */
  +public final class ContainerProfile
  +    extends TestCase
  +{
  +    /**
  +     * The TEST_SIZE defines the overall size of the tests.  Decreasing this will
  +     *  decrease the time the test takes to run, but also decrease its efficiency.
  +     */
  +    protected static final int      TEST_SIZE   = 50000;
  +    protected static final int      THREADS     = 100;
  +
  +    protected static Throwable      m_throwable = null;
  +    protected static int            m_getCount  = 0;
  +
  +    protected Logger                m_logger;
  +    protected org.apache.log.Logger m_logKitLogger;
  +
  +    /*---------------------------------------------------------------
  +     * Constructors
  +     *-------------------------------------------------------------*/
  +    public ContainerProfile(String name)
  +    {
  +        super(name);
  +
  +        // Set to debug to see more useful information.
  +        org.apache.log.Logger logger =
  +            org.apache.log.Hierarchy.getDefaultHierarchy().getLoggerFor( "test" );
  +        logger.setPriority( org.apache.log.Priority.INFO );
  +        m_logKitLogger = logger;
  +        m_logger = new LogKitLogger( logger );
  +    }
  +
  +    /*---------------------------------------------------------------
  +     * ECM vs. ContainerManager StartTimes
  +     *-------------------------------------------------------------*/
  +    /**
  +     * Compare the ECM and ContainerManager start times.
  +     */
  +    public void testCompare_ECM_ContainerManager_UseageTime()
  +        throws Exception
  +    {
  +        resetMemory(); // Start clean
  +
  +        long ecmStart = System.currentTimeMillis();
  +            ExcaliburComponentManager manager = new ExcaliburComponentManager();
  +            Context context = new DefaultContext();
  +            manager.setLogger(m_logKitLogger);
  +            manager.contextualize( context );
  +            DefaultLogKitManager logmanager = new DefaultLogKitManager();
  +            logmanager.setLogger(m_logKitLogger);
  +            logmanager.contextualize(context);
  +            logmanager.configure( getLogKitConfig() );
  +            manager.setLogKitManager(logmanager);
  +            manager.configure( getContainerConfig() );
  +            manager.initialize();
  +        long ecmStop = System.currentTimeMillis();
  +        long ecmDuration = ecmStop - ecmStart;
  +
  +        resetMemory(); // Start clean
  +
  +        long cmStart = System.currentTimeMillis();
  +            Parameters params = new Parameters();
  +            params.setParameter( ContainerManager.CONTAINER_CLASS, "org.apache.avalon.excalibur.system.test.TestContainer" );
  +            params.setParameter( ContainerManager.CONTEXT_DIRECTORY, "./" );
  +            params.setParameter( ContainerManager.WORK_DIRECTORY, "/tmp/" );
  +            params.setParameter( ContainerManager.CONTAINER_CONFIG, "resource://org/apache/avalon/excalibur/system/test/ContainerProfile.xconf" );
  +            params.setParameter( ContainerManager.LOG_CATEGORY, "test" );
  +            params.setParameter( ContainerManager.LOGKIT_CONFIG, "resource://org/apache/avalon/excalibur/system/test/ContainerProfile.xlog" );
  +            params.setParameter( ContainerManager.THREADS_CPU, "2" );
  +            params.makeReadOnly();
  +            ContainerManager cm = new ContainerManager( params, new NullLogger() );
  +            TestContainer container = (TestContainer) cm.getContainer();
  +            assertNotNull(container);
  +        long cmStop = System.currentTimeMillis();
  +        long cmDuration = cmStop - cmStart;
  +
  +        // Show a summary
  +        if ( m_logger.isInfoEnabled() )
  +        {
  +            m_logger.info( "Test Case: ECM_ContainerManager_StartTime" );
  +            m_logger.info( "     ECM time = " + ecmDuration + "ms." );
  +            m_logger.info( "     ContainerManager time = " + cmDuration + "ms." );
  +
  +            double mult;
  +            mult = ( cmDuration > 0 ? ( ecmDuration * 100 / cmDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  +            m_logger.info( "  => ContainerManager is " + mult + " X as fast as ExcaliburComponentManager on init." );
  +            mult = ( ecmDuration > 0 ? ( cmDuration * 100 / ecmDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  +            m_logger.info( "  => ExcaliburComponentManager is " + mult + " X as fast as ContainerManager on init." );
  +        }
  +
  +        resetMemory();
  +
  +        lookupTest( "Test Case: ECM_ContainerManager_UseageTime", container.getCM(), manager );
  +
  +        resetMemory();
  +
  +        ecmStart = System.currentTimeMillis();
  +            manager.dispose();
  +        ecmStop = System.currentTimeMillis();
  +        ecmDuration = ecmStop - ecmStart;
  +
  +        resetMemory();
  +
  +        cmStart = System.currentTimeMillis();
  +            cm.dispose();
  +        cmStop = System.currentTimeMillis();
  +        cmDuration = cmStop - cmStart;
  +
  +        // Show a summary
  +        if ( m_logger.isInfoEnabled() )
  +        {
  +            m_logger.info( "Test Case: ECM_ContainerManager_KillTime" );
  +            m_logger.info( "     ECM time = " + ecmDuration + "ms." );
  +            m_logger.info( "     ContainerManager time = " + cmDuration + "ms." );
  +
  +            double mult;
  +            mult = ( cmDuration > 0 ? ( ecmDuration * 100 / cmDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  +            m_logger.info( "  => ContainerManager is " + mult + " X as fast as ExcaliburComponentManager on dispose." );
  +            mult = ( ecmDuration > 0 ? ( cmDuration * 100 / ecmDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  +            m_logger.info( "  => ExcaliburComponentManager is " + mult + " X as fast as ContainerManager on dispose." );
  +        }
  +    }
  +
  +    /*---------------------------------------------------------------
  +     * Utility Methods
  +     *-------------------------------------------------------------*/
  +    protected void resetMemory()
  +    {
  +        System.gc();
  +        System.gc();
  +
  +        // Let the system settle down.
  +        try
  +        {
  +            Thread.sleep( 50 );
  +        }
  +        catch (InterruptedException e ) {}
  +        Runtime runtime = Runtime.getRuntime();
  +        m_logger.debug( "Memory: " + ( runtime.totalMemory() - runtime.freeMemory() ) );
  +    }
  +
  +    /**
  +     * Get the LogKitManager Config file
  +     */
  +    protected Configuration getLogKitConfig()
  +        throws Exception
  +    {
  +        final String resourceName = this.getClass().getName().replace( '.', '/' ) + ".xlog";
  +        URL resource = this.getClass().getClassLoader().getResource( resourceName );
  +        return loadConfig( resource );
  +    }
  +
  +    /**
  +     * Get the Container Config file
  +     */
  +    protected Configuration getContainerConfig()
  +        throws Exception
  +    {
  +        final String resourceName = this.getClass().getName().replace( '.', '/' ) + ".xconf";
  +        URL resource = this.getClass().getClassLoader().getResource( resourceName );
  +        return loadConfig( resource );
  +    }
  +
  +    /**
  +     * Load Config
  +     */
  +    protected Configuration loadConfig( URL path )
  +        throws Exception
  +    {
  +        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        return builder.build( path.openStream() );
  +    }
  +
  +    /**
  +     * Get the short class name
  +     */
  +    protected String getShortClassName( Object o )
  +    {
  +        String name = o.getClass().getName();
  +        int pos = name.lastIndexOf('.');
  +        if ( pos > 0 )
  +        {
  +            name = name.substring( pos + 1 );
  +        }
  +        return name;
  +    }
  +
  +    /**
  +     * The guts of the various test cases.  Will dispose the pools
  +     */
  +    protected void lookupTest(String name, ComponentManager cmA, ComponentManager cmB)
  +        throws Exception
  +    {
  +        m_logger.info( "Test Case: " + name );
  +
  +        // Get the short class names
  +        final String cmAName = getShortClassName( cmA );
  +        final String cmBName = getShortClassName( cmB );
  +
  +        // Start clean
  +        resetMemory();
  +
  +
  +        // Get the time for ecm
  +        final long cmADuration = getLookupRunTime( cmA );
  +        m_logger.info( "     " + cmAName + " time = " + cmADuration + "ms. to use " + TEST_SIZE + " calls on 3 components." );
  +        resetMemory();
  +
  +
  +        // Get the time for manager
  +        final long cmBDuration = getLookupRunTime( cmB );
  +        m_logger.info( "     " + cmBName + " time = " + cmBDuration + "ms. to use " + TEST_SIZE + " calls on 3 components." );
  +        resetMemory();
  +
  +        // Show a summary
  +        if ( m_logger.isInfoEnabled() )
  +        {
  +            double mult;
  +            mult = ( cmADuration > 0 ? ( cmBDuration * 100 / cmADuration ) / 100.0 : Float.POSITIVE_INFINITY );
  +            m_logger.info( "  => " + cmAName + " is " + mult + " X as fast as " + cmBName + "." );
  +
  +            mult = ( cmBDuration > 0 ? ( cmADuration * 100 / cmBDuration ) / 100.0 : Float.POSITIVE_INFINITY );
  +            m_logger.info( "  => " + cmBName + " is " + mult + " X as fast as " + cmAName + "." );
  +        }
  +    }
  +
  +    protected long getLookupRunTime( ComponentManager manager )
  +    {
  +        // Create the runnable
  +        LookupRunner runnable = new LookupRunner(manager, m_logger);
  +
  +        LatchedThreadGroup group = new LatchedThreadGroup( runnable, THREADS );
  +        group.enableLogging( m_logger );
  +
  +        long duration;
  +        try
  +        {
  +            duration = group.go();
  +        }
  +        catch ( Throwable t )
  +        {
  +            // Throwable could have been thrown by one of the tests.
  +            if (m_throwable == null) {
  +                m_throwable = t;
  +            }
  +            duration = 0;
  +        }
  +
  +        if ( m_throwable != null )
  +        {
  +            throw new CascadingAssertionFailedError( "Exception in test thread.", m_throwable );
  +        }
  +
  +        assertTrue( "m_getCount == 0 (" + m_getCount + ")", m_getCount == 0 );
  +
  +        return duration;
  +    }
  +
  +    private static class LookupRunner implements Runnable
  +    {
  +        private Logger m_logger;
  +        private ComponentManager m_manager;
  +        private int m_getCount = 0;
  +        private Throwable m_throwable = null;
  +
  +        public LookupRunner(ComponentManager manager, Logger logger)
  +        {
  +            m_manager = manager;
  +            m_logger = logger;
  +        }
  +
  +        public int getCount()
  +        {
  +            return m_getCount;
  +        }
  +
  +        public Throwable getThrowable()
  +        {
  +            return m_throwable;
  +        }
  +
  +        public void run()
  +        {
  +            // Perform this threads part of the test.
  +            final int loops = (TEST_SIZE / THREADS);
  +            for( int i = 0; i < loops; i++ )
  +            {
  +                Parser parser = null;
  +                DataSourceComponent datasource = null;
  +                Monitor monitor = null;
  +
  +                try
  +                {
  +                    parser = (Parser) m_manager.lookup(Parser.ROLE);
  +
  +                    // Make the loops hold the components longer than they are released, but only slightly.
  +                    Thread.yield();
  +                }
  +                catch (Throwable t)
  +                {
  +                    m_logger.error( "Unexpected error after " + m_getCount +
  +                                    " iterations retrieved for Parser", t );
  +
  +                    if (m_throwable == null) {
  +                        m_throwable = t;
  +                    }
  +                    return;
  +                }
  +                finally
  +                {
  +                    if ( null != parser )
  +                    {
  +                        m_manager.release( parser );
  +                    }
  +                }
  +                try
  +                {
  +                    datasource = (DataSourceComponent) m_manager.lookup(DataSourceComponent.ROLE);
  +
  +                    // Make the loops hold the components longer than they are released, but only slightly.
  +                    Thread.yield();
  +                }
  +                catch (Throwable t)
  +                {
  +                    m_logger.error( "Unexpected error after " + m_getCount +
  +                                    " iterations retrieved for DataSourceComponent", t );
  +
  +                    if (m_throwable == null) {
  +                        m_throwable = t;
  +                    }
  +                    return;
  +                }
  +                finally
  +                {
  +                    if ( null != datasource )
  +                    {
  +                        m_manager.release( datasource );
  +                    }
  +                }
  +
  +                try
  +                {
  +                    monitor = (Monitor) m_manager.lookup(Monitor.ROLE);
  +
  +                    // Make the loops hold the components longer than they are released, but only slightly.
  +                    Thread.yield();
  +                }
  +                catch (Throwable t)
  +                {
  +                    m_logger.error( "Unexpected error after " + m_getCount +
  +                                    " iterations retrieved for DataSourceComponent", t );
  +
  +                    if (m_throwable == null) {
  +                        m_throwable = t;
  +                    }
  +                    return;
  +                }
  +                finally
  +                {
  +                    if ( null != monitor )
  +                    {
  +                        m_manager.release( monitor );
  +                    }
  +                }
  +            }
  +        }
  +    }
  +
  +    public static final void main(String[] args)
  +    {
  +         TestRunner.run( ContainerProfile.class );
  +    }
  +}
  +
  
  
  
  1.3       +29 -29    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/TestContainer.java
  
  Index: TestContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/TestContainer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestContainer.java	19 Feb 2002 14:03:22 -0000	1.2
  +++ TestContainer.java	26 Feb 2002 02:06:30 -0000	1.3
  @@ -1,29 +1,29 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.test;
  -
  -import org.apache.avalon.excalibur.system.*;
  -import org.apache.avalon.framework.component.ComponentManager;
  -
  -/**
  - * The Container is an interface used to mark the Containers in your system.  It
  - * exposes a protected getComponentManager() method so that the Container's
  - * Manager can expose that to the instantiating class.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/02/19 14:03:22 $
  - */
  -public final class TestContainer
  -   extends AbstractContainer
  -{
  -    public ComponentManager getCM()
  -    {
  -        return getComponentManager();
  -    }
  -}
  -
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.test;
  +
  +import org.apache.avalon.excalibur.system.*;
  +import org.apache.avalon.framework.component.ComponentManager;
  +
  +/**
  + * The Container is an interface used to mark the Containers in your system.  It
  + * exposes a protected getComponentManager() method so that the Container's
  + * Manager can expose that to the instantiating class.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.3 $ $Date: 2002/02/26 02:06:30 $
  + */
  +public final class TestContainer
  +   extends AbstractContainer
  +{
  +    public ComponentManager getCM()
  +    {
  +        return getComponentManager();
  +    }
  +}
  +
  
  
  
  1.2       +247 -247  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/AbstractRoleManager.java
  
  Index: AbstractRoleManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/AbstractRoleManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractRoleManager.java	19 Feb 2002 20:48:04 -0000	1.1
  +++ AbstractRoleManager.java	26 Feb 2002 02:06:30 -0000	1.2
  @@ -1,247 +1,247 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.util;
  -
  -import org.apache.avalon.framework.component.Component;
  -
  -import java.util.ArrayList;
  -import java.util.Collections;
  -import java.util.List;
  -import java.util.Map;
  -
  -/**
  - * The Excalibur Role Manager is used for Excalibur Role Mappings.  All of the
  - * information is hard-coded.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/19 20:48:04 $
  - * @since 4.1
  - */
  -public abstract class AbstractRoleManager
  -    implements RoleManager
  -{
  -    protected static final String EMPTY_STRING = "";
  -
  -    protected final ClassLoader m_loader;
  -
  -    /** Map for shorthand to class mapping */
  -    protected       Map   m_shorthands;
  -
  -    /** Map for role to classname mapping */
  -    protected       Map   m_classNames;
  -
  -    /** Map for role to handler classname mapping */
  -    protected       Map   m_handlerNames;
  -
  -    /** Parent <code>RoleManager</code> for nested resolution */
  -    protected final RoleManager m_parent;
  -
  -    /**
  -     * Default constructor--this RoleManager has no parent.
  -     */
  -    public AbstractRoleManager()
  -    {
  -        this( null );
  -    }
  -
  -    /**
  -     * Alternate constructor--this RoleManager has the specified
  -     * parent.
  -     *
  -     * @param parent  The parent <code>RoleManager</code>.
  -     */
  -    public AbstractRoleManager(RoleManager parent)
  -    {
  -        this( parent, Thread.currentThread().getContextClassLoader() );
  -    }
  -
  -    /**
  -     * Alternate constructor--this RoleManager has the specified
  -     * parent.
  -     *
  -     * @param parent  The parent <code>RoleManager</code>.
  -     */
  -    public AbstractRoleManager(RoleManager parent, ClassLoader loader)
  -    {
  -        ClassLoader thisLoader = loader;
  -
  -        if ( null == thisLoader )
  -        {
  -            thisLoader = Thread.currentThread().getContextClassLoader();
  -        }
  -
  -        m_loader = thisLoader;
  -        m_parent = parent;
  -    }
  -
  -    protected void setup( Map shorts, Map classes, Map handlers,
  -                        String shortName, String role, String className,
  -                        String handlerClassName )
  -    {
  -        final Class klass;
  -        Class handlerKlass;
  -
  -        try
  -        {
  -            klass = m_loader.loadClass( className );
  -
  -            if ( ! Component.class.isAssignableFrom( klass ) )
  -            {
  -                // Do not store reference if it is not a Component
  -                return;
  -            }
  -        }
  -        catch ( Exception e )
  -        {
  -            // Do not store reference if class does not exist.
  -            return;
  -        }
  -
  -        try
  -        {
  -            handlerKlass = m_loader.loadClass( handlerClassName );
  -        }
  -        catch ( Exception e )
  -        {
  -            handlerKlass = org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler.class;
  -        }
  -
  -        shorts.put( shortName, klass );
  -        shorts.put( klass, shortName );
  -        classes.put( klass,
  -                     role );
  -
  -        List classList = (List) classes.get( role );
  -
  -        if ( null == classList )
  -        {
  -            classList = new ArrayList(5);
  -        }
  -
  -        classList.add( klass );
  -        classes.put( role, classList );
  -
  -        handlers.put( klass, handlerKlass );
  -    }
  -
  -    /**
  -     * Find the Class for the given shorthand name.  If there is no
  -     * correspondence between the class and the shorthand name, the method
  -     * returns <code>null</code>.  If this RoleManager does not have the match,
  -     * and there is a parent RoleManager, the parent will be asked to resolve
  -     * the request.
  -     */
  -    public final Class getClassForName( final String shorthandName )
  -    {
  -        if (shorthandName == null) return null;
  -
  -        final Class component = (Class)m_shorthands.get( shorthandName );
  -
  -        if( null == component && null != m_parent )
  -        {
  -            return m_parent.getClassForName( shorthandName );
  -        }
  -
  -        return component;
  -    }
  -
  -    /**
  -     * Retrieves the real role name from a shorthand name.  Usually
  -     * the shorthand name refers to a configuration element name.  If
  -     * this RoleManager does not have the match, and there is a parent
  -     * RoleManager, the parent will be asked to resolve the role.
  -     *
  -     * @param shorthandName  The shortname that is an alias for the role.
  -     * @return the official role name.
  -     */
  -    public final String getNameForClass( final Class klass )
  -    {
  -        final String shorthandName = (String)m_shorthands.get( klass );
  -
  -        if( null == shorthandName && null != m_parent )
  -        {
  -            return m_parent.getNameForClass( klass );
  -        }
  -
  -        return shorthandName;
  -    }
  -
  -    /**
  -     * Retrieves the handler class name for the specified class name.  This
  -     * is called for every ComponentImplementation.  If this RoleManager does
  -     * not have the match, and there is a parent RoleManager, the parent will be
  -     * asked to resolve the handler's class name.
  -     *
  -     * @param role  The role that has a default implementation.
  -     * @return the Fully Qualified Class Name (FQCN) for the role.
  -     */
  -    public final Class getHandlerClassForClass( final Class className )
  -    {
  -        final Class handler = (Class)m_handlerNames.get( className );
  -
  -        if( null == handler && null != m_parent )
  -        {
  -            return m_parent.getHandlerClassForClass( className );
  -        }
  -
  -        return handler;
  -    }
  -
  -    /**
  -     * Retrieves the default class name for the specified role.  This
  -     * is only called when the configuration does not specify the
  -     * class explicitly.  If this RoleManager does not have the match,
  -     * and there is a parent RoleManager, the parent will be asked
  -     * to resolve the class name.
  -     *
  -     * @param role  The role that has a default implementation.
  -     * @return the Fully Qualified Class Name (FQCN) for the role.
  -     */
  -    public final Class[] getClassesForRole( final String role )
  -    {
  -        final List classes = (List)m_classNames.get( role );
  -
  -        if( null == classes && null != m_parent )
  -        {
  -            return m_parent.getClassesForRole( role );
  -        }
  -
  -        return (Class []) classes.toArray( new Class[] {} );
  -    }
  -
  -    /**
  -     * Retrieves a default class name for a role/hint combination.
  -     * This is only called when a role is mapped to a
  -     * DefaultComponentSelector, and the configuration elements use
  -     * shorthand names for the type of component.  If this RoleManager
  -     * does not have the match, and there is a parent RoleManager, the
  -     * parent will be asked to resolve the class name.
  -     *
  -     * @param role  The role that this shorthand refers to.
  -     * @param shorthand  The shorthand name for the type of Component
  -     * @return the FQCN for the role/hint combination.
  -     */
  -    public final String getRoleForClass( final Class klass )
  -    {
  -        final String role = (String)m_classNames.get( klass );
  -
  -        if( null == role )
  -        {
  -            if( null != m_parent )
  -            {
  -                return m_parent.getRoleForClass( klass );
  -            }
  -            else
  -            {
  -                return EMPTY_STRING;
  -            }
  -        }
  -
  -        return role;
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.util;
  +
  +import org.apache.avalon.framework.component.Component;
  +
  +import java.util.ArrayList;
  +import java.util.Collections;
  +import java.util.List;
  +import java.util.Map;
  +
  +/**
  + * The Excalibur Role Manager is used for Excalibur Role Mappings.  All of the
  + * information is hard-coded.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/26 02:06:30 $
  + * @since 4.1
  + */
  +public abstract class AbstractRoleManager
  +    implements RoleManager
  +{
  +    protected static final String EMPTY_STRING = "";
  +
  +    protected final ClassLoader m_loader;
  +
  +    /** Map for shorthand to class mapping */
  +    protected       Map   m_shorthands;
  +
  +    /** Map for role to classname mapping */
  +    protected       Map   m_classNames;
  +
  +    /** Map for role to handler classname mapping */
  +    protected       Map   m_handlerNames;
  +
  +    /** Parent <code>RoleManager</code> for nested resolution */
  +    protected final RoleManager m_parent;
  +
  +    /**
  +     * Default constructor--this RoleManager has no parent.
  +     */
  +    public AbstractRoleManager()
  +    {
  +        this( null );
  +    }
  +
  +    /**
  +     * Alternate constructor--this RoleManager has the specified
  +     * parent.
  +     *
  +     * @param parent  The parent <code>RoleManager</code>.
  +     */
  +    public AbstractRoleManager(RoleManager parent)
  +    {
  +        this( parent, Thread.currentThread().getContextClassLoader() );
  +    }
  +
  +    /**
  +     * Alternate constructor--this RoleManager has the specified
  +     * parent.
  +     *
  +     * @param parent  The parent <code>RoleManager</code>.
  +     */
  +    public AbstractRoleManager(RoleManager parent, ClassLoader loader)
  +    {
  +        ClassLoader thisLoader = loader;
  +
  +        if ( null == thisLoader )
  +        {
  +            thisLoader = Thread.currentThread().getContextClassLoader();
  +        }
  +
  +        m_loader = thisLoader;
  +        m_parent = parent;
  +    }
  +
  +    protected void setup( Map shorts, Map classes, Map handlers,
  +                        String shortName, String role, String className,
  +                        String handlerClassName )
  +    {
  +        final Class klass;
  +        Class handlerKlass;
  +
  +        try
  +        {
  +            klass = m_loader.loadClass( className );
  +
  +            if ( ! Component.class.isAssignableFrom( klass ) )
  +            {
  +                // Do not store reference if it is not a Component
  +                return;
  +            }
  +        }
  +        catch ( Exception e )
  +        {
  +            // Do not store reference if class does not exist.
  +            return;
  +        }
  +
  +        try
  +        {
  +            handlerKlass = m_loader.loadClass( handlerClassName );
  +        }
  +        catch ( Exception e )
  +        {
  +            handlerKlass = org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler.class;
  +        }
  +
  +        shorts.put( shortName, klass );
  +        shorts.put( klass, shortName );
  +        classes.put( klass,
  +                     role );
  +
  +        List classList = (List) classes.get( role );
  +
  +        if ( null == classList )
  +        {
  +            classList = new ArrayList(5);
  +        }
  +
  +        classList.add( klass );
  +        classes.put( role, classList );
  +
  +        handlers.put( klass, handlerKlass );
  +    }
  +
  +    /**
  +     * Find the Class for the given shorthand name.  If there is no
  +     * correspondence between the class and the shorthand name, the method
  +     * returns <code>null</code>.  If this RoleManager does not have the match,
  +     * and there is a parent RoleManager, the parent will be asked to resolve
  +     * the request.
  +     */
  +    public final Class getClassForName( final String shorthandName )
  +    {
  +        if (shorthandName == null) return null;
  +
  +        final Class component = (Class)m_shorthands.get( shorthandName );
  +
  +        if( null == component && null != m_parent )
  +        {
  +            return m_parent.getClassForName( shorthandName );
  +        }
  +
  +        return component;
  +    }
  +
  +    /**
  +     * Retrieves the real role name from a shorthand name.  Usually
  +     * the shorthand name refers to a configuration element name.  If
  +     * this RoleManager does not have the match, and there is a parent
  +     * RoleManager, the parent will be asked to resolve the role.
  +     *
  +     * @param shorthandName  The shortname that is an alias for the role.
  +     * @return the official role name.
  +     */
  +    public final String getNameForClass( final Class klass )
  +    {
  +        final String shorthandName = (String)m_shorthands.get( klass );
  +
  +        if( null == shorthandName && null != m_parent )
  +        {
  +            return m_parent.getNameForClass( klass );
  +        }
  +
  +        return shorthandName;
  +    }
  +
  +    /**
  +     * Retrieves the handler class name for the specified class name.  This
  +     * is called for every ComponentImplementation.  If this RoleManager does
  +     * not have the match, and there is a parent RoleManager, the parent will be
  +     * asked to resolve the handler's class name.
  +     *
  +     * @param role  The role that has a default implementation.
  +     * @return the Fully Qualified Class Name (FQCN) for the role.
  +     */
  +    public final Class getHandlerClassForClass( final Class className )
  +    {
  +        final Class handler = (Class)m_handlerNames.get( className );
  +
  +        if( null == handler && null != m_parent )
  +        {
  +            return m_parent.getHandlerClassForClass( className );
  +        }
  +
  +        return handler;
  +    }
  +
  +    /**
  +     * Retrieves the default class name for the specified role.  This
  +     * is only called when the configuration does not specify the
  +     * class explicitly.  If this RoleManager does not have the match,
  +     * and there is a parent RoleManager, the parent will be asked
  +     * to resolve the class name.
  +     *
  +     * @param role  The role that has a default implementation.
  +     * @return the Fully Qualified Class Name (FQCN) for the role.
  +     */
  +    public final Class[] getClassesForRole( final String role )
  +    {
  +        final List classes = (List)m_classNames.get( role );
  +
  +        if( null == classes && null != m_parent )
  +        {
  +            return m_parent.getClassesForRole( role );
  +        }
  +
  +        return (Class []) classes.toArray( new Class[] {} );
  +    }
  +
  +    /**
  +     * Retrieves a default class name for a role/hint combination.
  +     * This is only called when a role is mapped to a
  +     * DefaultComponentSelector, and the configuration elements use
  +     * shorthand names for the type of component.  If this RoleManager
  +     * does not have the match, and there is a parent RoleManager, the
  +     * parent will be asked to resolve the class name.
  +     *
  +     * @param role  The role that this shorthand refers to.
  +     * @param shorthand  The shorthand name for the type of Component
  +     * @return the FQCN for the role/hint combination.
  +     */
  +    public final String getRoleForClass( final Class klass )
  +    {
  +        final String role = (String)m_classNames.get( klass );
  +
  +        if( null == role )
  +        {
  +            if( null != m_parent )
  +            {
  +                return m_parent.getRoleForClass( klass );
  +            }
  +            else
  +            {
  +                return EMPTY_STRING;
  +            }
  +        }
  +
  +        return role;
  +    }
  +}
  
  
  
  1.2       +102 -102  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ConfigurableRoleManager.java
  
  Index: ConfigurableRoleManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ConfigurableRoleManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigurableRoleManager.java	19 Feb 2002 20:48:04 -0000	1.1
  +++ ConfigurableRoleManager.java	26 Feb 2002 02:06:30 -0000	1.2
  @@ -1,102 +1,102 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.util;
  -
  -import java.util.Collections;
  -import java.util.HashMap;
  -import java.util.Map;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
  -
  -/**
  - * Configurable RoleManager implementation.  It populates the RoleManager
  - * from a configuration hierarchy.  This is based on the DefaultRoleManager
  - * in the org.apache.avalon.component package.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/19 20:48:04 $
  - * @since 4.1
  - */
  -public class ConfigurableRoleManager
  -    extends AbstractRoleManager
  -    implements Configurable
  -{
  -    /**
  -     * Default constructor--this RoleManager has no parent.
  -     */
  -    public ConfigurableRoleManager()
  -    {
  -        super( null );
  -    }
  -
  -
  -    /**
  -     * Alternate constructor--this RoleManager has the specified
  -     * parent.
  -     *
  -     * @param parent  The parent <code>RoleManager</code>.
  -     */
  -    public ConfigurableRoleManager(RoleManager parent)
  -    {
  -        super( parent, Thread.currentThread().getContextClassLoader() );
  -    }
  -
  -    /**
  -     * Alternate constructor--this RoleManager has the specified
  -     * parent and a classloader.
  -     *
  -     * @param parent  The parent <code>RoleManager</code>.
  -     */
  -    public ConfigurableRoleManager(RoleManager parent, ClassLoader loader)
  -    {
  -        super( parent, loader );
  -    }
  -
  -
  -    /**
  -     * Reads a configuration object and creates the role, shorthand,
  -     * and class name mapping.
  -     *
  -     * @param configuration  The configuration object.
  -     * @throws ConfigurationException if the configuration is malformed
  -     */
  -    public final void configure( final Configuration configuration )
  -        throws ConfigurationException
  -    {
  -        final Map shorts = new HashMap();
  -        final Map classes = new HashMap();
  -        final Map handlers = new HashMap();
  -        final Map hintclasses = new HashMap();
  -
  -        final Configuration[] roles = configuration.getChildren( "role" );
  -
  -        for( int i = 0; i < roles.length; i++ )
  -        {
  -            final String role = roles[ i ].getAttribute( "name" );
  -            Configuration[] components = roles[i].getChildren( "component" );
  -
  -            for ( int j = 0; j < components.length; j++)
  -            {
  -                final String shorthand = components[ j ].getAttribute( "shorthand" );
  -                final String className =
  -                    components[ j ].getAttribute( "class", null );
  -                final String handlerClassName =
  -                    components[ j ].getAttribute( "handler",
  -                    "org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" );
  -
  -                setup( shorts, classes, handlers, shorthand, role, className, handlerClassName );
  -            }
  -        }
  -
  -        m_shorthands = Collections.unmodifiableMap( shorts );
  -        m_classNames = Collections.unmodifiableMap( classes );
  -        m_handlerNames = Collections.unmodifiableMap( handlers );
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.util;
  +
  +import java.util.Collections;
  +import java.util.HashMap;
  +import java.util.Map;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.logger.AbstractLoggable;
  +
  +/**
  + * Configurable RoleManager implementation.  It populates the RoleManager
  + * from a configuration hierarchy.  This is based on the DefaultRoleManager
  + * in the org.apache.avalon.component package.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/26 02:06:30 $
  + * @since 4.1
  + */
  +public class ConfigurableRoleManager
  +    extends AbstractRoleManager
  +    implements Configurable
  +{
  +    /**
  +     * Default constructor--this RoleManager has no parent.
  +     */
  +    public ConfigurableRoleManager()
  +    {
  +        super( null );
  +    }
  +
  +
  +    /**
  +     * Alternate constructor--this RoleManager has the specified
  +     * parent.
  +     *
  +     * @param parent  The parent <code>RoleManager</code>.
  +     */
  +    public ConfigurableRoleManager(RoleManager parent)
  +    {
  +        super( parent, Thread.currentThread().getContextClassLoader() );
  +    }
  +
  +    /**
  +     * Alternate constructor--this RoleManager has the specified
  +     * parent and a classloader.
  +     *
  +     * @param parent  The parent <code>RoleManager</code>.
  +     */
  +    public ConfigurableRoleManager(RoleManager parent, ClassLoader loader)
  +    {
  +        super( parent, loader );
  +    }
  +
  +
  +    /**
  +     * Reads a configuration object and creates the role, shorthand,
  +     * and class name mapping.
  +     *
  +     * @param configuration  The configuration object.
  +     * @throws ConfigurationException if the configuration is malformed
  +     */
  +    public final void configure( final Configuration configuration )
  +        throws ConfigurationException
  +    {
  +        final Map shorts = new HashMap();
  +        final Map classes = new HashMap();
  +        final Map handlers = new HashMap();
  +        final Map hintclasses = new HashMap();
  +
  +        final Configuration[] roles = configuration.getChildren( "role" );
  +
  +        for( int i = 0; i < roles.length; i++ )
  +        {
  +            final String role = roles[ i ].getAttribute( "name" );
  +            Configuration[] components = roles[i].getChildren( "component" );
  +
  +            for ( int j = 0; j < components.length; j++)
  +            {
  +                final String shorthand = components[ j ].getAttribute( "shorthand" );
  +                final String className =
  +                    components[ j ].getAttribute( "class", null );
  +                final String handlerClassName =
  +                    components[ j ].getAttribute( "handler",
  +                    "org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" );
  +
  +                setup( shorts, classes, handlers, shorthand, role, className, handlerClassName );
  +            }
  +        }
  +
  +        m_shorthands = Collections.unmodifiableMap( shorts );
  +        m_classNames = Collections.unmodifiableMap( classes );
  +        m_handlerNames = Collections.unmodifiableMap( handlers );
  +    }
  +}
  
  
  
  1.3       +182 -182  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ContextManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContextManager.java	20 Feb 2002 15:24:22 -0000	1.2
  +++ ContextManager.java	26 Feb 2002 02:06:30 -0000	1.3
  @@ -1,182 +1,182 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.util;
  -
  -import org.apache.avalon.excalibur.system.*;
  -import org.apache.avalon.framework.context.*;
  -import org.apache.avalon.framework.parameters.*;
  -import org.apache.avalon.excalibur.logger.LoggerManager;
  -import org.apache.avalon.excalibur.event.Queue;
  -import org.apache.avalon.excalibur.mpool.PoolManager;
  -
  -import java.io.File;
  -
  -
  -/**
  - * The ContextManager is used to manage the values in a Container's Context.
  - * Use this helper class to create the initial context to pass into the
  - * ContainerManager.  Its purpose is to add the default values, and give
  - * convenient methods to override those defaults.  Once you get an instance
  - * of the Context, it is made read-only and returned.  No further operations
  - * will be possible on it.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/02/20 15:24:22 $
  - * @since 4.1
  - */
  -public class ContextManager
  -{
  -    private final Context        m_rootContext;
  -    private       DefaultContext m_currContext;
  -
  -    public ContextManager()
  -    {
  -        this( defaultParameters() );
  -    }
  -
  -    public ContextManager( Parameters params )
  -    {
  -        this( params, Thread.currentThread().getContextClassLoader() );
  -    }
  -
  -    public ContextManager( Parameters params, ClassLoader contextClassLoader )
  -    {
  -        this( defaultContext( params, contextClassLoader ) );
  -    }
  -
  -    public ContextManager( Context context )
  -    {
  -        m_rootContext = context;
  -        m_currContext = new DefaultContext( m_rootContext );
  -    }
  -
  -    public Context getContextInstance()
  -        throws ContextException
  -    {
  -        m_currContext.get( ContainerManager.CONTAINER_CLASS );
  -
  -        try
  -        {
  -            m_currContext.get( ContainerManager.LOGKIT_CONFIG );
  -        }
  -        catch (Exception e)
  -        {
  -            m_currContext.get( Container.LOGGER_MANAGER );
  -        }
  -
  -        m_currContext.makeReadOnly();
  -        return m_currContext;
  -    }
  -
  -    public void setContainerClass( String className )
  -    {
  -        m_currContext.put( ContainerManager.CONTAINER_CLASS, className );
  -    }
  -
  -    public void setContextDirectory( File file )
  -    {
  -        m_currContext.put( Container.CONTEXT_DIRECTORY, file );
  -    }
  -
  -    public void setWorkDirectory( File file )
  -    {
  -        m_currContext.put( Container.WORK_DIRECTORY, file );
  -    }
  -
  -    public void setContextClassLoader( ClassLoader loader )
  -    {
  -        m_currContext.put( Container.CONTEXT_CLASSLOADER, loader );
  -    }
  -
  -    public void setLogKitLoggerManagerConfiguration( String location )
  -    {
  -        m_currContext.put( ContainerManager.LOGKIT_CONFIG, location );
  -    }
  -
  -    public void setRoleManagerConfiguration( String location )
  -    {
  -        m_currContext.put( ContainerManager.ROLE_CONFIG, location );
  -    }
  -
  -    public void setContainerConfiguration( String location )
  -    {
  -        m_currContext.put( ContainerManager.CONTAINER_CONFIG, location );
  -    }
  -
  -    public void setLoggerCategory( String category )
  -    {
  -        m_currContext.put( ContainerManager.LOG_CATEGORY, category );
  -    }
  -
  -    public void setNumberOfThreadsPerCPU( int numberOfThreads )
  -    {
  -        m_currContext.put( ContainerManager.THREADS_CPU, new Integer( numberOfThreads ) );
  -    }
  -
  -    public void setThreadTimeout( long timeout )
  -    {
  -        m_currContext.put( ContainerManager.THREAD_TIMEOUT, new Long( timeout ) );
  -    }
  -
  -    public void setLoggerManager( LoggerManager logManager )
  -    {
  -        m_currContext.put( Container.LOGGER_MANAGER, logManager );
  -    }
  -
  -    public void setCommandQueue( Queue commandQueue )
  -    {
  -        m_currContext.put( Container.COMMAND_QUEUE, commandQueue );
  -    }
  -
  -    public void setPoolManager( PoolManager poolManager )
  -    {
  -        m_currContext.put( Container.POOL_MANAGER, poolManager );
  -    }
  -
  -    public void setRoleManager( RoleManager roleManager )
  -    {
  -        m_currContext.put( Container.ROLE_MANAGER, roleManager );
  -    }
  -
  -    private static final Parameters defaultParameters()
  -    {
  -        Parameters params = new Parameters();
  -        params.setParameter( ContainerManager.CONTEXT_DIRECTORY, "./" );
  -        params.setParameter( ContainerManager.WORK_DIRECTORY, "/tmp/" );
  -        params.setParameter( ContainerManager.LOG_CATEGORY, "test" );
  -        params.setParameter( ContainerManager.THREADS_CPU, "2" );
  -        params.setParameter( ContainerManager.THREAD_TIMEOUT, "1000" );
  -        params.makeReadOnly();
  -
  -        return params;
  -    }
  -
  -    private static final Context defaultContext( Parameters params,
  -                                          ClassLoader contextClassLoader )
  -    {
  -        DefaultContext context = new DefaultContext();
  -
  -        String[] keys = params.getNames();
  -        for (int i = 0; i < keys.length; i++)
  -        {
  -            context.put( keys[i], params.getParameter( keys[i], null ) );
  -        }
  -
  -        context.put( ContainerManager.CONTEXT_DIRECTORY,
  -                     new File( params.getParameter( ContainerManager.CONTEXT_DIRECTORY, "./" ) ) );
  -        context.put( ContainerManager.WORK_DIRECTORY,
  -                     new File( params.getParameter( ContainerManager.CONTEXT_DIRECTORY, "/tmp" ) ));
  -        context.put( ContainerManager.LOG_CATEGORY,
  -                params.getParameter(ContainerManager.LOG_CATEGORY, null)
  -        );
  -        context.put( Container.CONTEXT_CLASSLOADER, contextClassLoader );
  -        context.makeReadOnly();
  -
  -        return context;
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.util;
  +
  +import org.apache.avalon.excalibur.system.*;
  +import org.apache.avalon.framework.context.*;
  +import org.apache.avalon.framework.parameters.*;
  +import org.apache.avalon.excalibur.logger.LoggerManager;
  +import org.apache.avalon.excalibur.event.Queue;
  +import org.apache.avalon.excalibur.mpool.PoolManager;
  +
  +import java.io.File;
  +
  +
  +/**
  + * The ContextManager is used to manage the values in a Container's Context.
  + * Use this helper class to create the initial context to pass into the
  + * ContainerManager.  Its purpose is to add the default values, and give
  + * convenient methods to override those defaults.  Once you get an instance
  + * of the Context, it is made read-only and returned.  No further operations
  + * will be possible on it.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.3 $ $Date: 2002/02/26 02:06:30 $
  + * @since 4.1
  + */
  +public class ContextManager
  +{
  +    private final Context        m_rootContext;
  +    private       DefaultContext m_currContext;
  +
  +    public ContextManager()
  +    {
  +        this( defaultParameters() );
  +    }
  +
  +    public ContextManager( Parameters params )
  +    {
  +        this( params, Thread.currentThread().getContextClassLoader() );
  +    }
  +
  +    public ContextManager( Parameters params, ClassLoader contextClassLoader )
  +    {
  +        this( defaultContext( params, contextClassLoader ) );
  +    }
  +
  +    public ContextManager( Context context )
  +    {
  +        m_rootContext = context;
  +        m_currContext = new DefaultContext( m_rootContext );
  +    }
  +
  +    public Context getContextInstance()
  +        throws ContextException
  +    {
  +        m_currContext.get( ContainerManager.CONTAINER_CLASS );
  +
  +        try
  +        {
  +            m_currContext.get( ContainerManager.LOGKIT_CONFIG );
  +        }
  +        catch (Exception e)
  +        {
  +            m_currContext.get( Container.LOGGER_MANAGER );
  +        }
  +
  +        m_currContext.makeReadOnly();
  +        return m_currContext;
  +    }
  +
  +    public void setContainerClass( String className )
  +    {
  +        m_currContext.put( ContainerManager.CONTAINER_CLASS, className );
  +    }
  +
  +    public void setContextDirectory( File file )
  +    {
  +        m_currContext.put( Container.CONTEXT_DIRECTORY, file );
  +    }
  +
  +    public void setWorkDirectory( File file )
  +    {
  +        m_currContext.put( Container.WORK_DIRECTORY, file );
  +    }
  +
  +    public void setContextClassLoader( ClassLoader loader )
  +    {
  +        m_currContext.put( Container.CONTEXT_CLASSLOADER, loader );
  +    }
  +
  +    public void setLogKitLoggerManagerConfiguration( String location )
  +    {
  +        m_currContext.put( ContainerManager.LOGKIT_CONFIG, location );
  +    }
  +
  +    public void setRoleManagerConfiguration( String location )
  +    {
  +        m_currContext.put( ContainerManager.ROLE_CONFIG, location );
  +    }
  +
  +    public void setContainerConfiguration( String location )
  +    {
  +        m_currContext.put( ContainerManager.CONTAINER_CONFIG, location );
  +    }
  +
  +    public void setLoggerCategory( String category )
  +    {
  +        m_currContext.put( ContainerManager.LOG_CATEGORY, category );
  +    }
  +
  +    public void setNumberOfThreadsPerCPU( int numberOfThreads )
  +    {
  +        m_currContext.put( ContainerManager.THREADS_CPU, new Integer( numberOfThreads ) );
  +    }
  +
  +    public void setThreadTimeout( long timeout )
  +    {
  +        m_currContext.put( ContainerManager.THREAD_TIMEOUT, new Long( timeout ) );
  +    }
  +
  +    public void setLoggerManager( LoggerManager logManager )
  +    {
  +        m_currContext.put( Container.LOGGER_MANAGER, logManager );
  +    }
  +
  +    public void setCommandQueue( Queue commandQueue )
  +    {
  +        m_currContext.put( Container.COMMAND_QUEUE, commandQueue );
  +    }
  +
  +    public void setPoolManager( PoolManager poolManager )
  +    {
  +        m_currContext.put( Container.POOL_MANAGER, poolManager );
  +    }
  +
  +    public void setRoleManager( RoleManager roleManager )
  +    {
  +        m_currContext.put( Container.ROLE_MANAGER, roleManager );
  +    }
  +
  +    private static final Parameters defaultParameters()
  +    {
  +        Parameters params = new Parameters();
  +        params.setParameter( ContainerManager.CONTEXT_DIRECTORY, "./" );
  +        params.setParameter( ContainerManager.WORK_DIRECTORY, "/tmp/" );
  +        params.setParameter( ContainerManager.LOG_CATEGORY, "test" );
  +        params.setParameter( ContainerManager.THREADS_CPU, "2" );
  +        params.setParameter( ContainerManager.THREAD_TIMEOUT, "1000" );
  +        params.makeReadOnly();
  +
  +        return params;
  +    }
  +
  +    private static final Context defaultContext( Parameters params,
  +                                          ClassLoader contextClassLoader )
  +    {
  +        DefaultContext context = new DefaultContext();
  +
  +        String[] keys = params.getNames();
  +        for (int i = 0; i < keys.length; i++)
  +        {
  +            context.put( keys[i], params.getParameter( keys[i], null ) );
  +        }
  +
  +        context.put( ContainerManager.CONTEXT_DIRECTORY,
  +                     new File( params.getParameter( ContainerManager.CONTEXT_DIRECTORY, "./" ) ) );
  +        context.put( ContainerManager.WORK_DIRECTORY,
  +                     new File( params.getParameter( ContainerManager.CONTEXT_DIRECTORY, "/tmp" ) ));
  +        context.put( ContainerManager.LOG_CATEGORY,
  +                params.getParameter(ContainerManager.LOG_CATEGORY, null)
  +        );
  +        context.put( Container.CONTEXT_CLASSLOADER, contextClassLoader );
  +        context.makeReadOnly();
  +
  +        return context;
  +    }
  +}
  
  
  
  1.2       +132 -132  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ExcaliburRoleManager.java
  
  Index: ExcaliburRoleManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ExcaliburRoleManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExcaliburRoleManager.java	19 Feb 2002 20:48:04 -0000	1.1
  +++ ExcaliburRoleManager.java	26 Feb 2002 02:06:30 -0000	1.2
  @@ -1,132 +1,132 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.util;
  -
  -import org.apache.avalon.framework.component.Component;
  -
  -import java.util.ArrayList;
  -import java.util.Collections;
  -import java.util.HashMap;
  -import java.util.List;
  -import java.util.Map;
  -
  -/**
  - * The Excalibur Role Manager is used for Excalibur Role Mappings.  All of the
  - * information is hard-coded.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/19 20:48:04 $
  - * @since 4.1
  - */
  -public class ExcaliburRoleManager
  -    extends AbstractRoleManager
  -{
  -    /**
  -     * Default constructor--this RoleManager has no parent.
  -     */
  -    public ExcaliburRoleManager()
  -    {
  -        super( null );
  -    }
  -
  -    /**
  -     * Alternate constructor--this RoleManager has the specified
  -     * parent.
  -     *
  -     * @param parent  The parent <code>RoleManager</code>.
  -     */
  -    public ExcaliburRoleManager(RoleManager parent)
  -    {
  -        super( parent, Thread.currentThread().getContextClassLoader() );
  -    }
  -
  -    /**
  -     * Alternate constructor--this RoleManager has the specified
  -     * parent and a classloader.
  -     *
  -     * @param parent  The parent <code>RoleManager</code>.
  -     */
  -    public ExcaliburRoleManager(RoleManager parent, ClassLoader loader)
  -    {
  -        super( parent, loader );
  -
  -        HashMap shorts = new HashMap( 10 );
  -        HashMap classes = new HashMap( 10 );
  -        HashMap handlers = new HashMap( 10 );
  -
  -        /* Set up Cache relations */
  -        setup( shorts, classes, handlers, "cache",
  -               "org.apache.avalon.excalibur.cache.Cache",
  -               "org.apache.avalon.excalibur.cache.DefaultCache",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -        setup( shorts, classes, handlers, "lru-cache",
  -               "org.apache.avalon.excalibur.cache.Cache",
  -               "org.apache.avalon.excalibur.cache.LRUCache",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -
  -        /* Set up DataSource relations */
  -        setup( shorts, classes, handlers, "jdbc-datasource",
  -               "org.apache.avalon.excalibur.datasource.DataSourceComponent",
  -               "org.apache.avalon.excalibur.datasource.JdbcDataSource",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -        setup( shorts, classes, handlers, "j2ee-datasource",
  -               "org.apache.avalon.excalibur.datasource.DataSourceComponent",
  -               "org.apache.avalon.excalibur.datasource.J2eeDataSource",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -        setup( shorts, classes, handlers, "informix-datasource",
  -               "org.apache.avalon.excalibur.datasource.DataSourceComponent",
  -               "org.apache.avalon.excalibur.datasource.InformixDataSource",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -
  -        /* Set up i18n relations */
  -        setup( shorts, classes, handlers, "i18n",
  -               "org.apache.avalon.excalibur.i18n.BundleSelector",
  -               "org.apache.avalon.excalibur.i18n.BundleSelector",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -
  -        /* Set up Monitor relations */
  -        setup( shorts, classes, handlers, "monitor",
  -               "org.apache.avalon.excalibur.monitor.Monitor",
  -               "org.apache.avalon.excalibur.monitor.ActiveMonitor",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -        setup( shorts, classes, handlers, "passive-monitor",
  -               "org.apache.avalon.excalibur.monitor.Monitor",
  -               "org.apache.avalon.excalibur.monitor.PassiveMonitor",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -
  -        /* Set up XPath relations */
  -        setup( shorts, classes, handlers, "xalan-xpath",
  -               "org.apache.avalon.excalibur.xml.xpath.XPathProcessor",
  -               "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -        setup( shorts, classes, handlers, "jaxpath",
  -               "org.apache.avalon.excalibur.xml.xpath.XPathProcessor",
  -               "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -
  -        /* Set up SourceResolver relations */
  -        setup( shorts, classes, handlers, "resolver",
  -               "org.apache.avalon.excalibur.source.SourceResolver",
  -               "org.apache.avalon.excalibur.source.SourceResolverImpl",
  -               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  -
  -        /* Set up XML parser relations */
  -        setup( shorts, classes, handlers, "parser",
  -               "org.apache.avalon.excalibur.xml.Parser",
  -               "org.apache.avalon.excalibur.xml.JaxpParser",
  -               "org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" );
  -        setup( shorts, classes, handlers, "xerces-parser",
  -               "org.apache.avalon.excalibur.xml.Parser",
  -               "org.apache.avalon.excalibur.xml.XercesParser",
  -               "org.apache.avalon.excalibur.system.handler.FactoryComponentHandler" );
  -
  -        m_shorthands = Collections.unmodifiableMap( shorts );
  -        m_classNames = Collections.unmodifiableMap( classes );
  -        m_handlerNames = Collections.unmodifiableMap( handlers );
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.util;
  +
  +import org.apache.avalon.framework.component.Component;
  +
  +import java.util.ArrayList;
  +import java.util.Collections;
  +import java.util.HashMap;
  +import java.util.List;
  +import java.util.Map;
  +
  +/**
  + * The Excalibur Role Manager is used for Excalibur Role Mappings.  All of the
  + * information is hard-coded.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/26 02:06:30 $
  + * @since 4.1
  + */
  +public class ExcaliburRoleManager
  +    extends AbstractRoleManager
  +{
  +    /**
  +     * Default constructor--this RoleManager has no parent.
  +     */
  +    public ExcaliburRoleManager()
  +    {
  +        super( null );
  +    }
  +
  +    /**
  +     * Alternate constructor--this RoleManager has the specified
  +     * parent.
  +     *
  +     * @param parent  The parent <code>RoleManager</code>.
  +     */
  +    public ExcaliburRoleManager(RoleManager parent)
  +    {
  +        super( parent, Thread.currentThread().getContextClassLoader() );
  +    }
  +
  +    /**
  +     * Alternate constructor--this RoleManager has the specified
  +     * parent and a classloader.
  +     *
  +     * @param parent  The parent <code>RoleManager</code>.
  +     */
  +    public ExcaliburRoleManager(RoleManager parent, ClassLoader loader)
  +    {
  +        super( parent, loader );
  +
  +        HashMap shorts = new HashMap( 10 );
  +        HashMap classes = new HashMap( 10 );
  +        HashMap handlers = new HashMap( 10 );
  +
  +        /* Set up Cache relations */
  +        setup( shorts, classes, handlers, "cache",
  +               "org.apache.avalon.excalibur.cache.Cache",
  +               "org.apache.avalon.excalibur.cache.DefaultCache",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        setup( shorts, classes, handlers, "lru-cache",
  +               "org.apache.avalon.excalibur.cache.Cache",
  +               "org.apache.avalon.excalibur.cache.LRUCache",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
  +        /* Set up DataSource relations */
  +        setup( shorts, classes, handlers, "jdbc-datasource",
  +               "org.apache.avalon.excalibur.datasource.DataSourceComponent",
  +               "org.apache.avalon.excalibur.datasource.JdbcDataSource",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        setup( shorts, classes, handlers, "j2ee-datasource",
  +               "org.apache.avalon.excalibur.datasource.DataSourceComponent",
  +               "org.apache.avalon.excalibur.datasource.J2eeDataSource",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        setup( shorts, classes, handlers, "informix-datasource",
  +               "org.apache.avalon.excalibur.datasource.DataSourceComponent",
  +               "org.apache.avalon.excalibur.datasource.InformixDataSource",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
  +        /* Set up i18n relations */
  +        setup( shorts, classes, handlers, "i18n",
  +               "org.apache.avalon.excalibur.i18n.BundleSelector",
  +               "org.apache.avalon.excalibur.i18n.BundleSelector",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
  +        /* Set up Monitor relations */
  +        setup( shorts, classes, handlers, "monitor",
  +               "org.apache.avalon.excalibur.monitor.Monitor",
  +               "org.apache.avalon.excalibur.monitor.ActiveMonitor",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        setup( shorts, classes, handlers, "passive-monitor",
  +               "org.apache.avalon.excalibur.monitor.Monitor",
  +               "org.apache.avalon.excalibur.monitor.PassiveMonitor",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
  +        /* Set up XPath relations */
  +        setup( shorts, classes, handlers, "xalan-xpath",
  +               "org.apache.avalon.excalibur.xml.xpath.XPathProcessor",
  +               "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        setup( shorts, classes, handlers, "jaxpath",
  +               "org.apache.avalon.excalibur.xml.xpath.XPathProcessor",
  +               "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
  +        /* Set up SourceResolver relations */
  +        setup( shorts, classes, handlers, "resolver",
  +               "org.apache.avalon.excalibur.source.SourceResolver",
  +               "org.apache.avalon.excalibur.source.SourceResolverImpl",
  +               "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
  +        /* Set up XML parser relations */
  +        setup( shorts, classes, handlers, "parser",
  +               "org.apache.avalon.excalibur.xml.Parser",
  +               "org.apache.avalon.excalibur.xml.JaxpParser",
  +               "org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" );
  +        setup( shorts, classes, handlers, "xerces-parser",
  +               "org.apache.avalon.excalibur.xml.Parser",
  +               "org.apache.avalon.excalibur.xml.XercesParser",
  +               "org.apache.avalon.excalibur.system.handler.FactoryComponentHandler" );
  +
  +        m_shorthands = Collections.unmodifiableMap( shorts );
  +        m_classNames = Collections.unmodifiableMap( classes );
  +        m_handlerNames = Collections.unmodifiableMap( handlers );
  +    }
  +}
  
  
  
  1.2       +63 -63    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/RoleManager.java
  
  Index: RoleManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/RoleManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RoleManager.java	19 Feb 2002 20:48:04 -0000	1.1
  +++ RoleManager.java	26 Feb 2002 02:06:30 -0000	1.2
  @@ -1,63 +1,63 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.util;
  -
  -/**
  - * RoleManager Interface, use this to specify the Components and how they
  - * correspond to easy shorthand names.  The RoleManager assumes a flat
  - * relationship of shorthand names to classes, and classes to roles.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/19 20:48:04 $
  - * @since 4.1
  - */
  -public interface RoleManager
  -{
  -    /**
  -     * Find the Class for the given shorthand name.  If there is no
  -     * correspondence between the class and the shorthand name, the method
  -     * returns <code>null</code>.  If this RoleManager does not have the match,
  -     * and there is a parent RoleManager, the parent will be asked to resolve
  -     * the request.
  -     */
  -    Class getClassForName( final String shorthandName );
  -
  -    /**
  -     * This method is merely a hint for serialization.  If this RoleManager does
  -     * not have the match, and there is a parent RoleManager, the parent will be
  -     * asked to resolve the request.
  -     */
  -    String getNameForClass( final Class component );
  -
  -    /**
  -     * Get the Role name for a specific class.  If the class does not belong to
  -     * a Component, or the Role is not easily determinable, this method will return
  -     * <code>null</code>.  If this RoleManager does not have the match, and
  -     * there is a parent RoleManager, the parent will be asked to resolve the
  -     * request.
  -     */
  -    String getRoleForClass( final Class component );
  -
  -    /**
  -     * Get an array of classes registered with the role manager that implement a
  -     * role.  If this RoleManager does not have the match, and there is a parent
  -     * RoleManager, the parent will be asked to resolve the request.
  -     */
  -    Class[] getClassesForRole( final String role );
  -
  -    /**
  -     * Retrieves the handler class name for the specified class.  This
  -     * is called for every Component Implementation.  If this RoleManager does
  -     * not have the match, and there is a parent RoleManager, the parent will be
  -     * asked to resolve the handler's class name.
  -     *
  -     * @param class  The class of the Component in question.
  -     * @return the Class instance of the ComponentHandler.
  -     */
  -    Class getHandlerClassForClass( final Class className );
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.util;
  +
  +/**
  + * RoleManager Interface, use this to specify the Components and how they
  + * correspond to easy shorthand names.  The RoleManager assumes a flat
  + * relationship of shorthand names to classes, and classes to roles.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/26 02:06:30 $
  + * @since 4.1
  + */
  +public interface RoleManager
  +{
  +    /**
  +     * Find the Class for the given shorthand name.  If there is no
  +     * correspondence between the class and the shorthand name, the method
  +     * returns <code>null</code>.  If this RoleManager does not have the match,
  +     * and there is a parent RoleManager, the parent will be asked to resolve
  +     * the request.
  +     */
  +    Class getClassForName( final String shorthandName );
  +
  +    /**
  +     * This method is merely a hint for serialization.  If this RoleManager does
  +     * not have the match, and there is a parent RoleManager, the parent will be
  +     * asked to resolve the request.
  +     */
  +    String getNameForClass( final Class component );
  +
  +    /**
  +     * Get the Role name for a specific class.  If the class does not belong to
  +     * a Component, or the Role is not easily determinable, this method will return
  +     * <code>null</code>.  If this RoleManager does not have the match, and
  +     * there is a parent RoleManager, the parent will be asked to resolve the
  +     * request.
  +     */
  +    String getRoleForClass( final Class component );
  +
  +    /**
  +     * Get an array of classes registered with the role manager that implement a
  +     * role.  If this RoleManager does not have the match, and there is a parent
  +     * RoleManager, the parent will be asked to resolve the request.
  +     */
  +    Class[] getClassesForRole( final String role );
  +
  +    /**
  +     * Retrieves the handler class name for the specified class.  This
  +     * is called for every Component Implementation.  If this RoleManager does
  +     * not have the match, and there is a parent RoleManager, the parent will be
  +     * asked to resolve the handler's class name.
  +     *
  +     * @param class  The class of the Component in question.
  +     * @return the Class instance of the ComponentHandler.
  +     */
  +    Class getHandlerClassForClass( final Class className );
  +}
  
  
  
  1.2       +167 -167  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/test/ConfigurableRoleManagerTestCase.java
  
  Index: ConfigurableRoleManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/test/ConfigurableRoleManagerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigurableRoleManagerTestCase.java	19 Feb 2002 20:48:04 -0000	1.1
  +++ ConfigurableRoleManagerTestCase.java	26 Feb 2002 02:06:31 -0000	1.2
  @@ -1,167 +1,167 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.util.test;
  -
  -import org.apache.avalon.excalibur.system.util.ConfigurableRoleManager;
  -import org.apache.avalon.framework.configuration.*;
  -
  -import junit.framework.TestCase;
  -
  -/**
  - * Configurable RoleManager implementation.  It populates the RoleManager
  - * from a configuration hierarchy.  This is based on the DefaultRoleManager
  - * in the org.apache.avalon.component package.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/19 20:48:04 $
  - * @since 4.1
  - */
  -public class ConfigurableRoleManagerTestCase
  -    extends TestCase
  -{
  -    /**
  -     * Default constructor--this RoleManager has no parent.
  -     */
  -    public ConfigurableRoleManagerTestCase( String name )
  -    {
  -        super( name );
  -    }
  -
  -    /**
  -     * Test the shorthand return values.
  -     */
  -    public void testShorthandReturnValues()
  -        throws Exception
  -    {
  -        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  -        roles.configure( builder.build(this.getClass().getClassLoader()
  -                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  -
  -        assertEquals(
  -            roles.getClassForName( "datasource" ),
  -            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "monitor" ),
  -            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "parser" ),
  -            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  -        );
  -    }
  -
  -    /**
  -     * Test the shorthand return values.
  -     */
  -    public void testShorthandRemapReturnValues()
  -        throws Exception
  -    {
  -        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  -        roles.configure( builder.build(this.getClass().getClassLoader()
  -                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  -
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  -            "datasource"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  -            "monitor"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  -            "parser"
  -        );
  -    }
  -
  -    /**
  -     * Test the shorthand return values.
  -     */
  -    public void testRoleForClass()
  -        throws Exception
  -    {
  -        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  -        roles.configure( builder.build(this.getClass().getClassLoader()
  -                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  -
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  -            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  -            "org.apache.avalon.excalibur.monitor.Monitor"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  -            "org.apache.avalon.excalibur.xml.Parser"
  -        );
  -    }
  -
  -    /**
  -     * Test the shorthand return values.
  -     */
  -    public void testClassesForRole()
  -        throws Exception
  -    {
  -        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  -        roles.configure( builder.build(this.getClass().getClassLoader()
  -                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  -
  -        Class[] classes = roles.getClassesForRole( "org.apache.avalon.excalibur.datasource.DataSourceComponent" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  -        );
  -
  -        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.monitor.Monitor" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  -        );
  -
  -        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.Parser" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  -        );
  -    }
  -
  -    /**
  -     * Test the handler class return values.
  -     */
  -    public void testHandlerClassReturnValues()
  -        throws Exception
  -    {
  -        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  -        roles.configure( builder.build(this.getClass().getClassLoader()
  -                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  -
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.PoolableComponentHandler" )
  -        );
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.util.test;
  +
  +import org.apache.avalon.excalibur.system.util.ConfigurableRoleManager;
  +import org.apache.avalon.framework.configuration.*;
  +
  +import junit.framework.TestCase;
  +
  +/**
  + * Configurable RoleManager implementation.  It populates the RoleManager
  + * from a configuration hierarchy.  This is based on the DefaultRoleManager
  + * in the org.apache.avalon.component package.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/26 02:06:31 $
  + * @since 4.1
  + */
  +public class ConfigurableRoleManagerTestCase
  +    extends TestCase
  +{
  +    /**
  +     * Default constructor--this RoleManager has no parent.
  +     */
  +    public ConfigurableRoleManagerTestCase( String name )
  +    {
  +        super( name );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testShorthandReturnValues()
  +        throws Exception
  +    {
  +        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  +        roles.configure( builder.build(this.getClass().getClassLoader()
  +                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  +
  +        assertEquals(
  +            roles.getClassForName( "datasource" ),
  +            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "monitor" ),
  +            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "parser" ),
  +            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  +        );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testShorthandRemapReturnValues()
  +        throws Exception
  +    {
  +        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  +        roles.configure( builder.build(this.getClass().getClassLoader()
  +                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  +
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  +            "datasource"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  +            "monitor"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  +            "parser"
  +        );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testRoleForClass()
  +        throws Exception
  +    {
  +        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  +        roles.configure( builder.build(this.getClass().getClassLoader()
  +                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  +
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  +            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  +            "org.apache.avalon.excalibur.monitor.Monitor"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  +            "org.apache.avalon.excalibur.xml.Parser"
  +        );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testClassesForRole()
  +        throws Exception
  +    {
  +        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  +        roles.configure( builder.build(this.getClass().getClassLoader()
  +                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  +
  +        Class[] classes = roles.getClassesForRole( "org.apache.avalon.excalibur.datasource.DataSourceComponent" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.monitor.Monitor" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.Parser" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  +        );
  +    }
  +
  +    /**
  +     * Test the handler class return values.
  +     */
  +    public void testHandlerClassReturnValues()
  +        throws Exception
  +    {
  +        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
  +        roles.configure( builder.build(this.getClass().getClassLoader()
  +                         .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles" ) ) );
  +
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.PoolableComponentHandler" )
  +        );
  +    }
  +}
  
  
  
  1.2       +363 -363  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/test/ExcaliburRoleManagerTestCase.java
  
  Index: ExcaliburRoleManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/test/ExcaliburRoleManagerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExcaliburRoleManagerTestCase.java	19 Feb 2002 20:48:04 -0000	1.1
  +++ ExcaliburRoleManagerTestCase.java	26 Feb 2002 02:06:31 -0000	1.2
  @@ -1,363 +1,363 @@
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.system.util.test;
  -
  -import org.apache.avalon.excalibur.system.util.ExcaliburRoleManager;
  -
  -import junit.framework.TestCase;
  -
  -/**
  - * Configurable RoleManager implementation.  It populates the RoleManager
  - * from a configuration hierarchy.  This is based on the DefaultRoleManager
  - * in the org.apache.avalon.component package.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/02/19 20:48:04 $
  - * @since 4.1
  - */
  -public class ExcaliburRoleManagerTestCase
  -    extends TestCase
  -{
  -    /**
  -     * Default constructor--this RoleManager has no parent.
  -     */
  -    public ExcaliburRoleManagerTestCase( String name )
  -    {
  -        super( name );
  -    }
  -
  -    /**
  -     * Test the shorthand return values.
  -     */
  -    public void testShorthandReturnValues()
  -        throws Exception
  -    {
  -        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  -
  -        assertEquals(
  -            roles.getClassForName( "cache" ),
  -            Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "lru-cache" ),
  -            Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "jdbc-datasource" ),
  -            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "j2ee-datasource" ),
  -            Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "informix-datasource" ),
  -            Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "i18n" ),
  -            Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "monitor" ),
  -            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "passive-monitor" ),
  -            Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "xalan-xpath" ),
  -            Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "jaxpath" ),
  -            Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "resolver" ),
  -            Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "parser" ),
  -            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  -        );
  -        assertEquals(
  -            roles.getClassForName( "xerces-parser" ),
  -            Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" )
  -        );
  -    }
  -
  -    /**
  -     * Test the shorthand return values.
  -     */
  -    public void testShorthandRemapReturnValues()
  -        throws Exception
  -    {
  -        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  -
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" ) ),
  -            "cache"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" ) ),
  -            "lru-cache"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  -            "jdbc-datasource"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" ) ),
  -            "j2ee-datasource"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" ) ),
  -            "informix-datasource"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" ) ),
  -            "i18n"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  -            "monitor"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" ) ),
  -            "passive-monitor"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" ) ),
  -            "xalan-xpath"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" ) ),
  -            "jaxpath"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" ) ),
  -            "resolver"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  -            "parser"
  -        );
  -        assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" ) ),
  -            "xerces-parser"
  -        );
  -    }
  -
  -    /**
  -     * Test the shorthand return values.
  -     */
  -    public void testRoleForClass()
  -        throws Exception
  -    {
  -        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  -
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" ) ),
  -            "org.apache.avalon.excalibur.cache.Cache"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" ) ),
  -            "org.apache.avalon.excalibur.cache.Cache"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  -            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" ) ),
  -            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" ) ),
  -            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" ) ),
  -            "org.apache.avalon.excalibur.i18n.BundleSelector"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  -            "org.apache.avalon.excalibur.monitor.Monitor"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" ) ),
  -            "org.apache.avalon.excalibur.monitor.Monitor"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" ) ),
  -            "org.apache.avalon.excalibur.xml.xpath.XPathProcessor"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" ) ),
  -            "org.apache.avalon.excalibur.xml.xpath.XPathProcessor"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" ) ),
  -            "org.apache.avalon.excalibur.source.SourceResolver"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  -            "org.apache.avalon.excalibur.xml.Parser"
  -        );
  -        assertEquals(
  -            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" ) ),
  -            "org.apache.avalon.excalibur.xml.Parser"
  -        );
  -    }
  -
  -    /**
  -     * Test the shorthand return values.
  -     */
  -    public void testClassesForRole()
  -        throws Exception
  -    {
  -        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  -
  -        Class[] classes = roles.getClassesForRole( "org.apache.avalon.excalibur.cache.Cache" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" )
  -        );
  -        assertEquals(
  -            classes[1],
  -            Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" )
  -        );
  -
  -        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.datasource.DataSourceComponent" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  -        );
  -        assertEquals(
  -            classes[1],
  -            Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" )
  -        );
  -        assertEquals(
  -            classes[2],
  -            Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" )
  -        );
  -
  -        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.i18n.BundleSelector" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" )
  -        );
  -
  -        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.monitor.Monitor" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  -        );
  -        assertEquals(
  -            classes[1],
  -            Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" )
  -        );
  -
  -        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.xpath.XPathProcessor" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" )
  -        );
  -        assertEquals(
  -            classes[1],
  -            Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" )
  -        );
  -
  -        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.source.SourceResolver" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" )
  -        );
  -
  -        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.Parser" );
  -
  -        assertEquals(
  -            classes[0],
  -            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  -        );
  -        assertEquals(
  -            classes[1],
  -            Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" )
  -        );
  -    }
  -
  -    /**
  -     * Test the handler class return values.
  -     */
  -    public void testHandlerClassReturnValues()
  -        throws Exception
  -    {
  -        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  -
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" )
  -        );
  -        assertEquals(
  -            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" ) ),
  -            Class.forName( "org.apache.avalon.excalibur.system.handler.FactoryComponentHandler" )
  -        );
  -    }
  -}
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.system.util.test;
  +
  +import org.apache.avalon.excalibur.system.util.ExcaliburRoleManager;
  +
  +import junit.framework.TestCase;
  +
  +/**
  + * Configurable RoleManager implementation.  It populates the RoleManager
  + * from a configuration hierarchy.  This is based on the DefaultRoleManager
  + * in the org.apache.avalon.component package.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.2 $ $Date: 2002/02/26 02:06:31 $
  + * @since 4.1
  + */
  +public class ExcaliburRoleManagerTestCase
  +    extends TestCase
  +{
  +    /**
  +     * Default constructor--this RoleManager has no parent.
  +     */
  +    public ExcaliburRoleManagerTestCase( String name )
  +    {
  +        super( name );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testShorthandReturnValues()
  +        throws Exception
  +    {
  +        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  +
  +        assertEquals(
  +            roles.getClassForName( "cache" ),
  +            Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "lru-cache" ),
  +            Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "jdbc-datasource" ),
  +            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "j2ee-datasource" ),
  +            Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "informix-datasource" ),
  +            Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "i18n" ),
  +            Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "monitor" ),
  +            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "passive-monitor" ),
  +            Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "xalan-xpath" ),
  +            Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "jaxpath" ),
  +            Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "resolver" ),
  +            Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "parser" ),
  +            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  +        );
  +        assertEquals(
  +            roles.getClassForName( "xerces-parser" ),
  +            Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" )
  +        );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testShorthandRemapReturnValues()
  +        throws Exception
  +    {
  +        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  +
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" ) ),
  +            "cache"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" ) ),
  +            "lru-cache"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  +            "jdbc-datasource"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" ) ),
  +            "j2ee-datasource"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" ) ),
  +            "informix-datasource"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" ) ),
  +            "i18n"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  +            "monitor"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" ) ),
  +            "passive-monitor"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" ) ),
  +            "xalan-xpath"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" ) ),
  +            "jaxpath"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" ) ),
  +            "resolver"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  +            "parser"
  +        );
  +        assertEquals(
  +            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" ) ),
  +            "xerces-parser"
  +        );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testRoleForClass()
  +        throws Exception
  +    {
  +        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  +
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" ) ),
  +            "org.apache.avalon.excalibur.cache.Cache"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" ) ),
  +            "org.apache.avalon.excalibur.cache.Cache"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  +            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" ) ),
  +            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" ) ),
  +            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" ) ),
  +            "org.apache.avalon.excalibur.i18n.BundleSelector"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  +            "org.apache.avalon.excalibur.monitor.Monitor"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" ) ),
  +            "org.apache.avalon.excalibur.monitor.Monitor"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" ) ),
  +            "org.apache.avalon.excalibur.xml.xpath.XPathProcessor"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" ) ),
  +            "org.apache.avalon.excalibur.xml.xpath.XPathProcessor"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" ) ),
  +            "org.apache.avalon.excalibur.source.SourceResolver"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  +            "org.apache.avalon.excalibur.xml.Parser"
  +        );
  +        assertEquals(
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" ) ),
  +            "org.apache.avalon.excalibur.xml.Parser"
  +        );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testClassesForRole()
  +        throws Exception
  +    {
  +        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  +
  +        Class[] classes = roles.getClassesForRole( "org.apache.avalon.excalibur.cache.Cache" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.datasource.DataSourceComponent" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" )
  +        );
  +        assertEquals(
  +            classes[2],
  +            Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.i18n.BundleSelector" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.monitor.Monitor" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.xpath.XPathProcessor" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.source.SourceResolver" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.Parser" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" )
  +        );
  +    }
  +
  +    /**
  +     * Test the handler class return values.
  +     */
  +    public void testHandlerClassReturnValues()
  +        throws Exception
  +    {
  +        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader() );
  +
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" )
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" ) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.FactoryComponentHandler" )
  +        );
  +    }
  +}
  
  
  
  1.3       +100 -100  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/util/system/Linux.java
  
  Index: Linux.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/util/system/Linux.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Linux.java	12 Feb 2002 14:54:25 -0000	1.2
  +++ Linux.java	26 Feb 2002 02:06:31 -0000	1.3
  @@ -1,100 +1,100 @@
  -
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.util.system;
  -
  -import org.apache.avalon.excalibur.util.CPUParser;
  -import org.apache.avalon.excalibur.util.StringUtil;
  -
  -import java.io.FileReader;
  -import java.io.BufferedReader;
  -import java.util.Properties;
  -
  -
  -/**
  - * Parses the Linux environment--Uses the proc filesystem to determine all the
  - * CPU information.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/02/12 14:54:25 $
  - */
  -public final class Linux implements CPUParser
  -{
  -    private final int    m_processors;
  -    private final String m_cpuInfo;
  -
  -    public Linux()
  -    {
  -        int procs = 1;
  -        String info = "";
  -
  -        try
  -        {
  -            BufferedReader reader = new BufferedReader(new FileReader( "/proc/cpuinfo" ) );
  -            procs = 0;
  -
  -            Properties props = new Properties();
  -            String line = null;
  -
  -            while ( ( line = reader.readLine() ) != null )
  -            {
  -                String[] args = StringUtil.split( line, ":\t" );
  -
  -                if (args.length > 1)
  -                {
  -                    props.setProperty( args[0].trim(), args[1].trim() );
  -                    if ( args[0].trim().equals( "processor" ) )
  -                    {
  -                        procs++;
  -                    }
  -                }
  -            }
  -
  -            StringBuffer buf = new StringBuffer();
  -            buf.append( props.getProperty( "model name" ) );
  -            buf.append( " Family " );
  -            buf.append( props.getProperty( "cpu family" ) );
  -            buf.append( " Model " );
  -            buf.append( props.getProperty( "model" ) );
  -            buf.append( " Stepping " );
  -            buf.append( props.getProperty( "stepping" ) );
  -            buf.append( ", " );
  -            buf.append( props.getProperty( "vendor_id" ) );
  -
  -            info = buf.toString();
  -        }
  -        catch (Exception e)
  -        {
  -            procs = 1;
  -            e.printStackTrace();
  -        }
  -
  -        m_processors = procs;
  -        m_cpuInfo = info;
  -    }
  -
  -    /**
  -     * Return the number of processors available on the machine
  -     */
  -    public int numProcessors()
  -    {
  -        return m_processors;
  -    }
  -
  -    /**
  -     * Return the cpu info for the processors (assuming symetric multiprocessing
  -     * which means that all CPUs are identical).  The format is:
  -     *
  -     * ${arch} family ${family} Model ${model} Stepping ${stepping}, ${identifier}
  -     */
  -    public String cpuInfo()
  -    {
  -        return m_cpuInfo;
  -    }
  -}
  -
  +
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.util.system;
  +
  +import org.apache.avalon.excalibur.util.CPUParser;
  +import org.apache.avalon.excalibur.util.StringUtil;
  +
  +import java.io.FileReader;
  +import java.io.BufferedReader;
  +import java.util.Properties;
  +
  +
  +/**
  + * Parses the Linux environment--Uses the proc filesystem to determine all the
  + * CPU information.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.3 $ $Date: 2002/02/26 02:06:31 $
  + */
  +public final class Linux implements CPUParser
  +{
  +    private final int    m_processors;
  +    private final String m_cpuInfo;
  +
  +    public Linux()
  +    {
  +        int procs = 1;
  +        String info = "";
  +
  +        try
  +        {
  +            BufferedReader reader = new BufferedReader(new FileReader( "/proc/cpuinfo" ) );
  +            procs = 0;
  +
  +            Properties props = new Properties();
  +            String line = null;
  +
  +            while ( ( line = reader.readLine() ) != null )
  +            {
  +                String[] args = StringUtil.split( line, ":\t" );
  +
  +                if (args.length > 1)
  +                {
  +                    props.setProperty( args[0].trim(), args[1].trim() );
  +                    if ( args[0].trim().equals( "processor" ) )
  +                    {
  +                        procs++;
  +                    }
  +                }
  +            }
  +
  +            StringBuffer buf = new StringBuffer();
  +            buf.append( props.getProperty( "model name" ) );
  +            buf.append( " Family " );
  +            buf.append( props.getProperty( "cpu family" ) );
  +            buf.append( " Model " );
  +            buf.append( props.getProperty( "model" ) );
  +            buf.append( " Stepping " );
  +            buf.append( props.getProperty( "stepping" ) );
  +            buf.append( ", " );
  +            buf.append( props.getProperty( "vendor_id" ) );
  +
  +            info = buf.toString();
  +        }
  +        catch (Exception e)
  +        {
  +            procs = 1;
  +            e.printStackTrace();
  +        }
  +
  +        m_processors = procs;
  +        m_cpuInfo = info;
  +    }
  +
  +    /**
  +     * Return the number of processors available on the machine
  +     */
  +    public int numProcessors()
  +    {
  +        return m_processors;
  +    }
  +
  +    /**
  +     * Return the cpu info for the processors (assuming symetric multiprocessing
  +     * which means that all CPUs are identical).  The format is:
  +     *
  +     * ${arch} family ${family} Model ${model} Stepping ${stepping}, ${identifier}
  +     */
  +    public String cpuInfo()
  +    {
  +        return m_cpuInfo;
  +    }
  +}
  +
  
  
  
  1.4       +68 -68    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/util/system/Windows98.java
  
  Index: Windows98.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/util/system/Windows98.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Windows98.java	12 Feb 2002 15:21:00 -0000	1.3
  +++ Windows98.java	26 Feb 2002 02:06:31 -0000	1.4
  @@ -1,68 +1,68 @@
  -
  -/*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  - *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE.txt file.
  - */
  -package org.apache.avalon.excalibur.util.system;
  -
  -import org.apache.avalon.excalibur.util.CPUParser;
  -
  -import java.io.InputStreamReader;
  -import java.io.BufferedReader;
  -
  -
  -/**
  - * Parses the Windows 98 environment--the same class should work for other
  - * Windows versions, but I only have one to test.  Windows 9x environments
  - * can only use one processor--even if there are more installed in the system.
  - *
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2002/02/12 15:21:00 $
  - */
  -public final class Windows98 implements CPUParser
  -{
  -    private final int    m_processors = 1;
  -    private final String m_cpuInfo;
  -
  -    public Windows98()
  -    {
  -        String info = "";
  -
  -        try
  -        {
  -            // This is not the propper environment variable for Win 9x
  -            Runtime rt = Runtime.getRuntime();
  -            Process proc = rt.exec("command.com /C echo %PROCESSOR_IDENTIFIER%");
  -            BufferedReader reader = new BufferedReader(new InputStreamReader( proc.getInputStream() ) );
  -            info = reader.readLine();
  -        }
  -        catch (Exception e)
  -        {
  -        }
  -
  -        m_cpuInfo = info;
  -    }
  -
  -    /**
  -     * Return the number of processors available on the machine
  -     */
  -    public int numProcessors()
  -    {
  -        return m_processors;
  -    }
  -
  -    /**
  -     * Return the cpu info for the processors (assuming symetric multiprocessing
  -     * which means that all CPUs are identical).  The format is:
  -     *
  -     * ${arch} family ${family} Model ${model} Stepping ${stepping}, ${identifier}
  -     */
  -    public String cpuInfo()
  -    {
  -        return m_cpuInfo;
  -    }
  -}
  -
  +
  +/*
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included with this distribution in
  + * the LICENSE.txt file.
  + */
  +package org.apache.avalon.excalibur.util.system;
  +
  +import org.apache.avalon.excalibur.util.CPUParser;
  +
  +import java.io.InputStreamReader;
  +import java.io.BufferedReader;
  +
  +
  +/**
  + * Parses the Windows 98 environment--the same class should work for other
  + * Windows versions, but I only have one to test.  Windows 9x environments
  + * can only use one processor--even if there are more installed in the system.
  + *
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.4 $ $Date: 2002/02/26 02:06:31 $
  + */
  +public final class Windows98 implements CPUParser
  +{
  +    private final int    m_processors = 1;
  +    private final String m_cpuInfo;
  +
  +    public Windows98()
  +    {
  +        String info = "";
  +
  +        try
  +        {
  +            // This is not the propper environment variable for Win 9x
  +            Runtime rt = Runtime.getRuntime();
  +            Process proc = rt.exec("command.com /C echo %PROCESSOR_IDENTIFIER%");
  +            BufferedReader reader = new BufferedReader(new InputStreamReader( proc.getInputStream() ) );
  +            info = reader.readLine();
  +        }
  +        catch (Exception e)
  +        {
  +        }
  +
  +        m_cpuInfo = info;
  +    }
  +
  +    /**
  +     * Return the number of processors available on the machine
  +     */
  +    public int numProcessors()
  +    {
  +        return m_processors;
  +    }
  +
  +    /**
  +     * Return the cpu info for the processors (assuming symetric multiprocessing
  +     * which means that all CPUs are identical).  The format is:
  +     *
  +     * ${arch} family ${family} Model ${model} Stepping ${stepping}, ${identifier}
  +     */
  +    public String cpuInfo()
  +    {
  +        return m_cpuInfo;
  +    }
  +}
  +
  
  
  

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


Mime
View raw message