donaldp     2002/11/10 17:53:30

  Modified:    fortress/src/java/org/apache/excalibur/fortress/container
                        DefaultContainer.java
  Log:
  update to use new helper methods in configuration
  
  Revision  Changes    Path
  1.13      +17 -28    
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/container/DefaultContainer.java
  
  Index: DefaultContainer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/container/DefaultContainer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultContainer.java     11 Nov 2002 00:10:01 -0000      1.12
  +++ DefaultContainer.java     11 Nov 2002 01:53:30 -0000      1.13
  @@ -131,49 +131,38 @@
        * it makes it easier to handle ComponentSelector hierarchies.  It is
        * meant to either return a ComponentHandler or a ServiceSelector.
        *
  -     * @param configItem  The configuration snippet to translate into the
  +     * @param config  The configuration snippet to translate into the
        *                    standard format.
        *
        * @return <code>Configuration</code> representing the native format.
        *
        * @throws ConfigurationException  if the configuration is invalid
        */
  -    protected Configuration rewriteConfiguration( final Configuration 
configItem )
  +    protected Configuration rewriteConfiguration( final Configuration config 
)
           throws ConfigurationException
       {
  -        DefaultConfiguration temp =
  -            new DefaultConfiguration( "component",
  -                                      "AbstractContainer-rewrite [name: " + 
configItem.getName()
  -                                      + ", location: " + 
configItem.getLocation() + "]" );
  -
  -        final RoleEntry roleEntry = m_roleManager.getRoleForShortName( 
configItem.getName() );
  +        final RoleEntry roleEntry = m_roleManager.getRoleForShortName( 
config.getName() );
           if( null == roleEntry )
           {
  -            throw new ConfigurationException( "No class found matching 
configuration name "
  -                                              + "[name: " + 
configItem.getName()
  -                                              + ", location: " + 
configItem.getLocation() + "]" );
  +            final String message = "No class found matching configuration 
name " +
  +                "[name: " + config.getName() + ", location: " + 
config.getLocation() + "]";
  +            throw new ConfigurationException( message );
           }
   
  -        //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( "class", roleEntry.getComponentClass().getName() 
);
  -        temp.setValue( configItem.getValue( null ) );
  +        final String location = "AbstractContainer-rewrite [name: " +
  +            config.getName() + ", location: " + config.getLocation() + "]";
  +        final DefaultConfiguration newConfig =
  +            new DefaultConfiguration( "component", location );
   
  -        String[] attributes = configItem.getAttributeNames();
  -        for( int i = 0; i < attributes.length; i++ )
  -        {
  -            temp.setAttribute( attributes[ i ], configItem.getAttribute( 
attributes[ i ] ) );
  -        }
  +        newConfig.addAll( config );
   
  -        Configuration[] children = configItem.getChildren();
  -        for( int i = 0; i < children.length; i++ )
  -        {
  -            temp.addChild( children[ i ] );
  -        }
  +        //We set these before copying all other attributes so the class / 
handler can be overriden if needed if
  +        //the shorthand name is used
  +        newConfig.setAttribute( "class", 
roleEntry.getComponentClass().getName() );
   
  -        temp.makeReadOnly();
  +        newConfig.makeReadOnly();
   
  -        return temp;
  +        return newConfig;
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to