Heads up.

On Mon, 11 Nov 2002 11:10, [EMAIL PROTECTED] wrote:
> donaldp     2002/11/10 16:10:01
>
>   Modified:    fortress/src/java/org/apache/excalibur/fortress/container
>                         AbstractContainer.java DefaultContainer.java
>                fortress/src/java/org/apache/excalibur/fortress/role
>                         AbstractRoleManager.java RoleManager.java
>                fortress/src/test/org/apache/excalibur/fortress/test
>                         ContainerProfile.xconf
>                fortress/src/test/org/apache/excalibur/fortress/test/data
>                         test1.roles test1.xconf
>   Log:
>   Remove handler/role attributes from within the .xconf file. These are
> derivable from the values stored in the roles file and thus there is no
> need to try and duplicate the same data across multiple places.
>
>   Revision  Changes    Path
>   1.17      +28 -16   
> jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/co
>ntainer/AbstractContainer.java
>
>   Index: AbstractContainer.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/f
>ortress/container/AbstractContainer.java,v retrieving revision 1.16
>   retrieving revision 1.17
>   diff -u -r1.16 -r1.17
>   --- AbstractContainer.java  10 Nov 2002 16:16:43 -0000      1.16
>   +++ AbstractContainer.java  11 Nov 2002 00:10:01 -0000      1.17
>   @@ -81,6 +81,7 @@
>    import org.apache.excalibur.fortress.lookup.FortressServiceSelector;
>    import org.apache.excalibur.fortress.role.ExcaliburRoleManager;
>    import org.apache.excalibur.fortress.role.RoleManager;
>   +import org.apache.excalibur.fortress.role.RoleEntry;
>    import org.apache.excalibur.instrument.InstrumentManager;
>    import org.apache.excalibur.instrument.Instrumentable;
>    import org.apache.excalibur.mpool.ObjectFactory;
>   @@ -241,14 +242,22 @@
>                throw new IllegalArgumentException( message );
>            }
>
>   -        String role = component.getAttribute( "role", null );
>   -        String klass = component.getAttribute( "class", null );
>   +        final String classname = component.getAttribute( "class", null
> ); boolean isLazy = isLazyComponentHandler( component );
>   -        ComponentHandler handler = getComponentHandler(
>   -            component.getAttribute( "handler", null ), klass, component,
> isLazy -        );
>
>   -        if( null != role && null != klass && null != handler )
>   +        final RoleEntry roleEntry = m_roleManager.getRoleForClassname(
> classname ); +        if( null == roleEntry )
>   +        {
>   +            final String message = "No role defined for " + classname;
>   +            throw new IllegalArgumentException( message );
>   +        }
>   +
>   +        final ComponentHandler handler =
>   +            getComponentHandler( roleEntry, component, isLazy );
>   +
>   +        final String role = roleEntry.getRole();
>   +
>   +        if( null != role && null != classname && null != handler )
>            {
>                Map hintMap = (StaticBucketMap)m_mapper.get( role );
>
>   @@ -319,20 +328,19 @@
>         * Get a ComponentHandler with the standard
>         * <code>HANDLER_CONSTRUCTOR</code>  for the component class passed
> in. */
>   -    private ComponentHandler getComponentHandler( final String
> handlerClassName, -                                                  final
> String classname, +    private ComponentHandler getComponentHandler( final
> RoleEntry roleEntry, final Configuration configuration, final boolean
> isLazy ) {
>            ComponentHandler handler = null;
>   +        final String classname =
> roleEntry.getComponentClass().getName(); try
>            {
>   -            final Class handlerClazz = m_classLoader.loadClass(
> handlerClassName ); final ObjectFactory factory =
>                    createObjectFactory( classname, configuration );
>
>                final ComponentHandler targetHandler =
>   -                (ComponentHandler)handlerClazz.newInstance();
>   +               
> (ComponentHandler)roleEntry.getHandlerClass().newInstance();
>
>                ContainerUtil.contextualize( targetHandler, m_context );
>
>   @@ -359,16 +367,20 @@
>            {
>                if( getLogger().isDebugEnabled() )
>                {
>   -                getLogger().debug( "Could not create the '" +
> handlerClassName + -                                   "' handler for the
> '" + classname + -                                   "' component.", e );
>   +                final String message =
>   +                    "Could not create the handler for the '" +
>   +                    classname + "' component.";
>   +                getLogger().debug( message, e );
>                }
>   +            return null;
>            }
>
>            if( getLogger().isDebugEnabled() )
>            {
>   -            getLogger().debug( "Component " + classname +
>   -                               " uses handler " + handlerClassName );
>   +            final String message =
>   +                "Component " + classname +
>   +                " uses handler " +
> roleEntry.getHandlerClass().getName(); +            getLogger().debug(
> message );
>            }
>
>            final ComponentHandlerEntry entry =
>
>
>
>   1.12      +1 -4     
> jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/co
>ntainer/DefaultContainer.java
>
>   Index: DefaultContainer.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/f
>ortress/container/DefaultContainer.java,v retrieving revision 1.11
>   retrieving revision 1.12
>   diff -u -r1.11 -r1.12
>   --- DefaultContainer.java   10 Nov 2002 16:16:43 -0000      1.11
>   +++ DefaultContainer.java   11 Nov 2002 00:10:01 -0000      1.12
>   @@ -156,10 +156,7 @@
>
>            //We set these before copying all other attributes so the class
> / handler can be overriden if needed if //the shorthand name is used
>   -        temp.setAttribute( "role", roleEntry.getRole() );
>            temp.setAttribute( "class",
> roleEntry.getComponentClass().getName() ); -        temp.setAttribute(
> "handler", roleEntry.getHandlerClass().getName() ); -
>            temp.setValue( configItem.getValue( null ) );
>
>            String[] attributes = configItem.getAttributeNames();
>
>
>
>   1.4       +25 -1    
> jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/ro
>le/AbstractRoleManager.java
>
>   Index: AbstractRoleManager.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/f
>ortress/role/AbstractRoleManager.java,v retrieving revision 1.3
>   retrieving revision 1.4
>   diff -u -r1.3 -r1.4
>   --- AbstractRoleManager.java        10 Nov 2002 16:16:43 -0000      1.3
>   +++ AbstractRoleManager.java        11 Nov 2002 00:10:01 -0000      1.4
>   @@ -74,6 +74,11 @@
>        private Map m_shorthands = new Hashtable();
>
>        /**
>   +     * Map for classname to RoleEntry
>   +     */
>   +    private Map m_classnames = new Hashtable();
>   +
>   +    /**
>         * Parent <code>RoleManager</code> for nested resolution
>         */
>        private final RoleManager m_parent;
>   @@ -164,11 +169,30 @@
>
>            final RoleEntry entry = new RoleEntry( role, clazz, handlerKlass
> ); m_shorthands.put( shortName, entry );
>   +        m_classnames.put( className, entry );
>        }
>
>        protected Class guessHandlerFor( final Class clazz )
>        {
>            return PerThreadComponentHandler.class;
>   +    }
>   +
>   +
>   +    public RoleEntry getRoleForClassname( final String classname )
>   +    {
>   +        final RoleEntry roleEntry = (RoleEntry)m_classnames.get(
> classname ); +        if( null != roleEntry )
>   +        {
>   +            return roleEntry;
>   +        }
>   +        else if( null != m_parent )
>   +        {
>   +            return m_parent.getRoleForClassname( classname );
>   +        }
>   +        else
>   +        {
>   +            return null;
>   +        }
>        }
>
>        public RoleEntry getRoleForShortName( final String shortname )
>
>
>
>   1.4       +3 -1     
> jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/ro
>le/RoleManager.java
>
>   Index: RoleManager.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/f
>ortress/role/RoleManager.java,v retrieving revision 1.3
>   retrieving revision 1.4
>   diff -u -r1.3 -r1.4
>   --- RoleManager.java        10 Nov 2002 16:16:43 -0000      1.3
>   +++ RoleManager.java        11 Nov 2002 00:10:01 -0000      1.4
>   @@ -64,4 +64,6 @@
>        String ROLE = RoleManager.class.getName();
>
>        RoleEntry getRoleForShortName( String shortname );
>   +
>   +    RoleEntry getRoleForClassname( String classname );
>    }
>
>
>
>   1.8       +5 -24    
> jakarta-avalon-excalibur/fortress/src/test/org/apache/excalibur/fortress/te
>st/ContainerProfile.xconf
>
>   Index: ContainerProfile.xconf
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/fortress/src/test/org/apache/excalibur/f
>ortress/test/ContainerProfile.xconf,v retrieving revision 1.7
>   retrieving revision 1.8
>   diff -u -r1.7 -r1.8
>   --- ContainerProfile.xconf  24 Sep 2002 21:45:10 -0000      1.7
>   +++ ContainerProfile.xconf  11 Nov 2002 00:10:01 -0000      1.8
>   @@ -1,33 +1,14 @@
>    <test>
>   -<!--
>   -  <component id="test1"
>   -        class="org.apache.avalon.excalibur.datasource.JdbcDataSource"
>   -   role="org.apache.avalon.excalibur.datasource.DataSourceComponent"
>  
> -     handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler
>" -        logger="test">
>   -    <pool-controller min="5" max="10">
>   -      <keep-alive>SELECT 1 FROM groups</keep-alive>
>   -    </pool-controller>
>   -    <driver>@test.jdbc.driver@</driver>
>   -    <dburl>@test.jdbc.url@</dburl>
>   -    <user>@test.jdbc.user@</user>
>   -    <password>@test.jdbc.password@</password>
>   -  </component>
>   --->
>      <component id="test2"
>            class="org.apache.avalon.excalibur.monitor.ActiveMonitor"
>   -   role="org.apache.avalon.excalibur.monitor.Monitor"
>  
> -     handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler
>" -    logger="test"
>   -    activation="startup">
>   +       logger="test"
>   +        activation="startup">
>        <thread priority="10" frequency="1"/>
>      </component>
>      <component id="test3"
>   -        class="org.apache.avalon.excalibur.xml.JaxpParser"
>   -   role="org.apache.avalon.excalibur.xml.Parser"
>  
> -     handler="org.apache.excalibur.fortress.handler.PoolableComponentHandler"
> -     logger="test"
>   -    activation="startup">
>   +             class="org.apache.avalon.excalibur.xml.JaxpParser"
>   +            logger="test"
>   +             activation="startup">
>        <parameter name="validate" value="false"/>
>        <parameter name="namespace-prefixes" value="false"/>
>        <parameter name="reuse-parsers" value="true"/>
>
>
>
>   1.2       +3 -3     
> jakarta-avalon-excalibur/fortress/src/test/org/apache/excalibur/fortress/te
>st/data/test1.roles
>
>   Index: test1.roles
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/fortress/src/test/org/apache/excalibur/f
>ortress/test/data/test1.roles,v retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- test1.roles     10 Nov 2002 12:39:04 -0000      1.1
>   +++ test1.roles     11 Nov 2002 00:10:01 -0000      1.2
>   @@ -7,17 +7,17 @@
>        <role name="org.apache.excalibur.fortress.test.data.Role2">
>            <component shorthand="component2"
>                class="org.apache.excalibur.fortress.test.data.Component2"
>   -           
> handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler"/
>> +           
> handler="org.apache.excalibur.fortress.handler.PoolableComponentHandler"/>
> </role>
>        <role name="org.apache.excalibur.fortress.test.data.Role3">
>            <component shorthand="component3"
>                class="org.apache.excalibur.fortress.test.data.Component3"
>   -           
> handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler"/
>> +           
> handler="org.apache.excalibur.fortress.handler.PerThreadComponentHandler"/>
> </role>
>        <role name="org.apache.excalibur.fortress.test.data.Role4">
>            <component shorthand="component4"
>                class="org.apache.excalibur.fortress.test.data.Component4"
>   -           
> handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler"/
>> +           
> handler="org.apache.excalibur.fortress.handler.FactoryComponentHandler"/>
> </role>
>    </test>
>
>
>
>
>   1.3       +0 -8     
> jakarta-avalon-excalibur/fortress/src/test/org/apache/excalibur/fortress/te
>st/data/test1.xconf
>
>   Index: test1.xconf
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/fortress/src/test/org/apache/excalibur/f
>ortress/test/data/test1.xconf,v retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- test1.xconf     10 Nov 2002 12:43:57 -0000      1.2
>   +++ test1.xconf     11 Nov 2002 00:10:01 -0000      1.3
>   @@ -1,27 +1,19 @@
>    <test>
>        <component id="component1"
>            class="org.apache.excalibur.fortress.test.data.Component1"
>   -        role="org.apache.excalibur.fortress.test.data.Role1"
>   -       
> handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler"
> logger="component1"
>            activation="startup"/>
>        <component id="component2"
>            class="org.apache.excalibur.fortress.test.data.Component2"
>   -        role="org.apache.excalibur.fortress.test.data.Role2"
>   -       
> handler="org.apache.excalibur.fortress.handler.PoolableComponentHandler"
> logger="component2"
>            pool-min="2"
>            activation="startup"/>
>        <component id="component3"
>            class="org.apache.excalibur.fortress.test.data.Component3"
>   -        role="org.apache.excalibur.fortress.test.data.Role3"
>   -       
> handler="org.apache.excalibur.fortress.handler.PerThreadComponentHandler"
> logger="component3"
>            activation="startup"/>
>        <component id="component4"
>            class="org.apache.excalibur.fortress.test.data.Component4"
>   -        role="org.apache.excalibur.fortress.test.data.Role4"
>   -       
> handler="org.apache.excalibur.fortress.handler.FactoryComponentHandler"
> logger="component4"
>            activation="startup"/>
>    </test>

-- 
Cheers,

Peter Donald
----------------------------------------
"Liberty means responsibility. That is 
      why most men dread it." - Locke
---------------------------------------- 


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

Reply via email to