avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craft...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model RoleRef.java Definition.java
Date Mon, 07 Oct 2002 17:13:18 GMT
crafterm    2002/10/07 10:13:18

  Modified:    xfc/src/java/org/apache/excalibur/xfc/modules Fortress.java
                        ECM.java
               xfc/src/java/org/apache/excalibur/xfc/model RoleRef.java
                        Definition.java
  Log:
  * Updated Model to support shorthands at the Role reference object level
    (as well as in the Definition class for component selector hints).
  * Fixed REVISIT for ComponentSelector generation in ECM module serialization.
  * Fixed ECM module serialization bug for ComponentSelectors (thanks testcase! :) )
  
  Revision  Changes    Path
  1.3       +19 -24    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Fortress.java	4 Oct 2002 14:46:35 -0000	1.2
  +++ Fortress.java	7 Oct 2002 17:13:17 -0000	1.3
  @@ -98,11 +98,21 @@
       // Map of fortress/type handlers
       private static final Map m_handlers = new HashMap();
   
  -    // <role-list>
  -    //  <role name="">
  -    //   <component shorthand="" class="" handler="">
  -    //  </role>
  -    // </role-list>
  +    // Normalized mappings for Fortress component handlers
  +    static
  +    {
  +        // Fortress -> Normalized
  +        m_handlers.put( FACTORY, TRANSIENT );
  +        m_handlers.put( PERTHREAD, THREAD );
  +        m_handlers.put( POOLABLE, POOLED );
  +        m_handlers.put( THREADSAFE, SINGLETON );
  +
  +        // Normalized -> Fortress
  +        m_handlers.put( TRANSIENT, FACTORY );
  +        m_handlers.put( THREAD, PERTHREAD );
  +        m_handlers.put( POOLED, POOLABLE );
  +        m_handlers.put( SINGLETON, THREADSAFE );
  +    }
   
       /**
        * Method to construct a {@link RoleRef} object from
  @@ -122,14 +132,13 @@
           {
               definitions[i] =
                   new Definition(
  -                    getRole( role ),
                       getHintClass( hints[i] ),
                       getShorthand( hints[i] ),
                       getHandler( getHintClass( hints[i] ) )
                   );
           }
   
  -        return new RoleRef( getRole( role ), definitions );
  +        return new RoleRef( getRole( role ), getShorthand( role ), definitions );
       }
   
       /**
  @@ -200,6 +209,7 @@
       protected Configuration buildSingleComponentRole( final RoleRef ref )
           throws Exception
       {
  +        // single role definitions are the same as multiple definitions
           return buildMultipleComponentRole( ref );
       }
   
  @@ -230,23 +240,8 @@
           }
   
           role.setAttribute( "name", ref.getRole() );
  +        role.setAttribute( "shorthand", ref.getShorthand() );
   
           return role;
  -    }
  -
  -    // Default mappings for Fortress and Type component handlers
  -    static
  -    {
  -        // Fortress -> Type
  -        m_handlers.put( FACTORY, TRANSIENT );
  -        m_handlers.put( PERTHREAD, THREAD );
  -        m_handlers.put( POOLABLE, POOLED );
  -        m_handlers.put( THREADSAFE, SINGLETON );
  -
  -        // Type -> Fortress
  -        m_handlers.put( TRANSIENT, FACTORY );
  -        m_handlers.put( THREAD, PERTHREAD );
  -        m_handlers.put( POOLED, POOLABLE );
  -        m_handlers.put( SINGLETON, THREADSAFE );
       }
   }
  
  
  
  1.4       +16 -17    jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/ECM.java
  
  Index: ECM.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/ECM.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ECM.java	4 Oct 2002 21:26:38 -0000	1.3
  +++ ECM.java	7 Oct 2002 17:13:17 -0000	1.4
  @@ -100,6 +100,16 @@
   
       private static Map m_handlers = new HashMap();
   
  +    // Normalized mappings for ECM lifestyles
  +    static
  +    {
  +        // ECM -> Normalized
  +        m_handlers.put( SINGLETHREADED, TRANSIENT );
  +        m_handlers.put( POOLABLE, POOLED );
  +        m_handlers.put( RECYCLABLE, POOLED );
  +        m_handlers.put( THREADSAFE, SINGLETON );
  +    }
  +
       /**
        * Generates a {@link Model} based on an a given ECM style
        * Context.
  @@ -213,13 +223,12 @@
       {
           Definition def =
               new Definition(
  -                getRole( role ),
                   getDefaultClass( role ),
                   getShorthand( role ),
                   getHandler( getDefaultClass( role ) )
               );
   
  -        return new RoleRef( getRole( role ), def );
  +        return new RoleRef( getRole( role ), getShorthand( role ), def );
       }
   
       /**
  @@ -240,14 +249,13 @@
           {
               definitions[i] =
                   new Definition(
  -                    getRole( role ),
                       getHintClass( hints[i] ),
                       getShorthand( hints[i] ),
                       getHandler( getHintClass( hints[i] ) )
                   );
           }
   
  -        return new RoleRef( getRole( role ), definitions );
  +        return new RoleRef( getRole( role ), getShorthand( role ), definitions );
       }
   
       /**
  @@ -433,10 +441,11 @@
               DefaultConfiguration hint = new DefaultConfiguration( "hint", "" );
               hint.setAttribute( "shorthand", defs[i].getShorthand() );
               hint.setAttribute( "class", defs[i].getDefaultClass() );
  +            role.addChild( hint );
           }
   
           role.setAttribute( "name", ref.getRole() );
  -        role.setAttribute( "shorthand", "REVISIT" ); // REVISIT(MC) ?
  +        role.setAttribute( "shorthand", ref.getShorthand() );
           role.setAttribute( "default-class", ECS );
   
           return role;
  @@ -458,7 +467,7 @@
   
           // there is only 1 provider, use index 0 directly
           role.setAttribute( "name", ref.getRole() );
  -        role.setAttribute( "shorthand", defs[0].getShorthand() );
  +        role.setAttribute( "shorthand", ref.getShorthand() );
           role.setAttribute( "default-class", defs[0].getDefaultClass() );
   
           return role;
  @@ -479,15 +488,5 @@
                   "Module requires the role and xconf filename " +
                   "separated by a '" + CONTEXT_SEPARATOR + "' character"
               );
  -    }
  -
  -    // Normalized mappings for ECM lifestyles
  -    static
  -    {
  -        // ECM -> Type
  -        m_handlers.put( SINGLETHREADED, TRANSIENT );
  -        m_handlers.put( POOLABLE, POOLED );
  -        m_handlers.put( RECYCLABLE, POOLED );
  -        m_handlers.put( THREADSAFE, SINGLETON );
       }
   }
  
  
  
  1.3       +18 -3     jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/RoleRef.java
  
  Index: RoleRef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/RoleRef.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RoleRef.java	4 Oct 2002 14:36:24 -0000	1.2
  +++ RoleRef.java	7 Oct 2002 17:13:17 -0000	1.3
  @@ -68,16 +68,19 @@
       // internals
       private final List m_definitions = new ArrayList();
       private final String m_role;
  +    private final String m_shorthand;
   
       /**
        * Creates a new <code>RoleRef</code> instance.
        *
        * @param role role name
  +     * @param shorthand shorthand name
        * @param definition a {@link Definition} instance
        */
  -    public RoleRef( final String role, final Definition definition )
  +    public RoleRef( final String role, final String shorthand, final Definition definition
)
       {
           m_role = role;
  +        m_shorthand = shorthand;
           m_definitions.add( definition );
       }
   
  @@ -85,11 +88,13 @@
        * Creates a new <code>RoleRef</code> instance.
        *
        * @param role role name
  +     * @param role shorthand name
        * @param definitions a {@link Definition} array
        */
  -    public RoleRef( final String role, final Definition[] definitions )
  +    public RoleRef( final String role, final String shorthand, final Definition[] definitions
)
       {
           m_role = role;
  +        m_shorthand = shorthand;
   
           for ( int i = 0; i < definitions.length; ++i )
           {
  @@ -105,6 +110,16 @@
       public String getRole()
       {
           return m_role;
  +    }
  +
  +    /**
  +     * Obtain the shorthand name of this role
  +     *
  +     * @return a <code>String</code> value
  +     */
  +    public String getShorthand()
  +    {
  +        return m_shorthand;
       }
   
       /**
  
  
  
  1.2       +1 -15     jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/Definition.java
  
  Index: Definition.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/Definition.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Definition.java	2 Oct 2002 17:32:28 -0000	1.1
  +++ Definition.java	7 Oct 2002 17:13:17 -0000	1.2
  @@ -58,7 +58,6 @@
   public final class Definition
   {
       // internals
  -    private final String m_role;
       private final String m_clazz;
       private final String m_shorthand;
       private final String m_handler;
  @@ -66,34 +65,21 @@
       /**
        * Creates a new <code>Definition</code> instance.
        *
  -     * @param role a <code>String</code> value
        * @param clazz a <code>String</code> value
        * @param shorthand a <code>String</code> value
        * @param handler a <code>String</code> value
        */
       public Definition(
  -        final String role, 
           final String clazz,
           final String shorthand,
           final String handler
       )
       {
  -        m_role = role;
           m_clazz = clazz;
           m_shorthand = shorthand;
           m_handler = handler;
       }
   
  -    /**
  -     * Obtain this Component role name.
  -     *
  -     * @return a <code>String</code> value
  -     */
  -    public String getRole() 
  -    {
  -        return m_role;
  -    }
  -    
       /**
        * Obtain this Component's default implementing class.
        *
  
  
  

--
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