You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by cr...@apache.org on 2002/10/08 12:42:32 UTC

cvs commit: jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules Fortress.java

crafterm    2002/10/08 03:42:32

  Modified:    xfc/src/java/org/apache/excalibur/xfc/modules Fortress.java
  Log:
  Fixed RoleRef generation to work correctly for single definition
  components, in particular how shorthands are treated.
  
  Revision  Changes    Path
  1.4       +46 -4     jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/Fortress.java
  
  Index: Fortress.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/Fortress.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Fortress.java	7 Oct 2002 17:13:17 -0000	1.3
  +++ Fortress.java	8 Oct 2002 10:42:32 -0000	1.4
  @@ -126,6 +126,27 @@
           throws Exception
       {
           Configuration[] hints = role.getChildren( "component" );
  +
  +        if ( hints.length > 1 )
  +        {
  +            return buildMultipleComponentRoleRef( role );
  +        }
  +
  +        return buildSingleComponentRoleRef( role );
  +    }
  +
  +    /**
  +     * Method to construct a {@link RoleRef} object from a Configuration
  +     * definition that defines a multiple component based role.
  +     *
  +     * @param role a <code>Configuration</code> definition of a role
  +     * @return a {@link RoleRef} instance
  +     * @exception Exception if an error occurs
  +     */
  +    private RoleRef buildMultipleComponentRoleRef( final Configuration role )
  +        throws Exception
  +    {
  +        Configuration[] hints = role.getChildren( "component" );
           Definition[] definitions = new Definition[ hints.length ];
   
           for ( int i = 0; i < hints.length; ++i )
  @@ -134,11 +155,33 @@
                   new Definition(
                       getHintClass( hints[i] ),
                       getShorthand( hints[i] ),
  -                    getHandler( getHintClass( hints[i] ) )
  +                    getHandler( hints[i] )
                   );
           }
   
  -        return new RoleRef( getRole( role ), getShorthand( role ), definitions );
  +        return new RoleRef( getRole( role ), "UNKNOWN-REVISIT", definitions );
  +    }
  +
  +    /**
  +     * Method to create a {@link RoleRef} object for a Configuration 
  +     * definition that defines a single component based role.
  +     *
  +     * @param role a <code>Configuration</code> definition of a role
  +     * @return a {@link RoleRef} instance
  +     * @exception Exception if an error occurs
  +     */
  +    private RoleRef buildSingleComponentRoleRef( final Configuration role )
  +        throws Exception
  +    {
  +        Configuration config = role.getChild( "component" );
  +        Definition definition =
  +            new Definition(
  +                getHintClass( config ),
  +                getShorthand( config ),
  +                getHandler( config )
  +            );
  +
  +        return new RoleRef( getRole( role ), getShorthand( config ), definition );
       }
   
       /**
  @@ -240,7 +283,6 @@
           }
   
           role.setAttribute( "name", ref.getRole() );
  -        role.setAttribute( "shorthand", ref.getShorthand() );
   
           return role;
       }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>