avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/meta/tools/src/java/org/apache/avalon/meta/info/builder/tags ContextTag.java
Date Mon, 28 Jul 2003 13:27:00 GMT
mcconnell    2003/07/28 06:26:59

  Modified:    merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl
                        ContextBuilder.java
               merlin/composition/src/java/org/apache/avalon/composition/model/impl
                        DefaultContextModel.java
               merlin/merlin-platform/tutorials/context_casting build.xml
               meta/api/src/java/org/apache/avalon/meta/info
                        ContextDescriptor.java
               meta/api/src/test/org/apache/avalon/meta/info/test
                        ContextDescriptorTestCase.java TypeTestCase.java
               meta/impl/src/java/org/apache/avalon/meta/info/builder
                        XMLLegacyCreator.java XMLTypeCreator.java
               meta/impl/src/java/org/apache/avalon/meta/info/writer
                        XMLTypeWriter.java
               meta/tools/src/java/org/apache/avalon/meta/info/builder/tags
                        ContextTag.java
  Log:
  Update of the context descriptor so that it does not reference ReferenceDescriptor, but
simply reference the interface type-safe classname.
  
  Revision  Changes    Path
  1.5       +17 -16    avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/ContextBuilder.java
  
  Index: ContextBuilder.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/ContextBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContextBuilder.java	19 Jul 2003 01:54:35 -0000	1.4
  +++ ContextBuilder.java	28 Jul 2003 13:26:53 -0000	1.5
  @@ -144,7 +144,8 @@
           // entries declared within a service definition if one exists
           //
   
  -        EntryDescriptor[] entries = getMergedEntries( services, descriptor );
  +        //EntryDescriptor[] entries = getMergedEntries( services, descriptor );
  +        EntryDescriptor[] entries = descriptor.getEntries();
   
           //
           // commence population of the map
  @@ -284,20 +285,20 @@
           return map;
       }
   
  -    private static EntryDescriptor[] getMergedEntries(
  -            ServiceRepository services, ContextDescriptor descriptor )
  -            throws IllegalArgumentException
  -    {
  -        try
  -        {
  -            Service service = services.getService( descriptor.getReference() );
  -            EntryDescriptor[] result = descriptor.merge( service.getEntries() );
  -            return result;
  -        } catch( UnknownServiceException e )
  -        {
  -            return descriptor.getEntries();
  -        }
  -    }
  +    //private static EntryDescriptor[] getMergedEntries(
  +    //        ServiceRepository services, ContextDescriptor descriptor )
  +    //        throws IllegalArgumentException
  +    //{
  +    //    try
  +    //    {
  +    //        Service service = services.getService( descriptor.getReference() );
  +    //        EntryDescriptor[] result = descriptor.merge( service.getEntries() );
  +    //        return result;
  +    //    } catch( UnknownServiceException e )
  +    //    {
  +    //        return descriptor.getEntries();
  +    //    }
  +    //}
   
       /**
        * Internal utility to get a context value or null if the context key
  
  
  
  1.7       +2 -2      avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContextModel.java
  
  Index: DefaultContextModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContextModel.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultContextModel.java	26 Jul 2003 16:28:21 -0000	1.6
  +++ DefaultContextModel.java	28 Jul 2003 13:26:53 -0000	1.7
  @@ -427,7 +427,7 @@
           Class castingClass = null;
   
           final String castingClassName = 
  -          descriptor.getReference().getClassname();
  +          descriptor.getContextInterfaceClassname();
   
           if( castingClassName != null )
           {
  
  
  
  1.2       +6 -3      avalon-sandbox/merlin/merlin-platform/tutorials/context_casting/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/context_casting/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	10 Jun 2003 02:12:22 -0000	1.1
  +++ build.xml	28 Jul 2003 13:26:54 -0000	1.2
  @@ -14,12 +14,15 @@
     <property environment="env"/>
     <property name="merlin.home"  value="${env.MERLIN_HOME}"/>
   
  -  <property name="framework.jar"
  -    value="${merlin.home}/lib/shared/avalon-framework-4.1.4.jar" />
  +  <property name="framework-api.jar"
  +    value="${merlin.home}/lib/shared/avalon-framework-api-SNAPSHOT.jar" />
  +  <property name="framework-impl.jar"
  +    value="${merlin.home}/lib/system/avalon-framework-impl-SNAPSHOT.jar" />
   
     <path id="project.class.path">
       <pathelement path="${java.class.path}" />
  -    <pathelement location="${framework.jar}"/>
  +    <pathelement location="${framework-api.jar}"/>
  +    <pathelement location="${framework-impl.jar}"/>
       <fileset dir="${classes.dir}"/>
     </path>
   
  
  
  
  1.8       +36 -18    avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ContextDescriptor.java
  
  Index: ContextDescriptor.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ContextDescriptor.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ContextDescriptor.java	24 Jul 2003 12:12:00 -0000	1.7
  +++ ContextDescriptor.java	28 Jul 2003 13:26:55 -0000	1.8
  @@ -115,11 +115,17 @@
       public static final String STRATEGY_KEY =
               "urn:avalon:context.strategy";
   
  +   /**
  +    * Context interface classname.
  +    */
  +    public static final String AVALON_CONTEXT_CLASSNAME =
  +            "org.apache.avalon.framework.context.Context";
  +
       //---------------------------------------------------------
       // immutable state
       //---------------------------------------------------------
   
  -    private final ReferenceDescriptor m_reference;
  +    private final String m_classname;
   
       private final EntryDescriptor[] m_entries;
   
  @@ -128,25 +134,34 @@
       //---------------------------------------------------------
   
       /**
  +     * Create a standard descriptor without attributes.
  +     * @param classname the classname of a castable interface 
  +     * @param entries the set of entries required within the context
  +     */
  +    public ContextDescriptor( final EntryDescriptor[] entries )
  +    {
  +        this( null, entries, null );
  +    }
  +
  +    /**
        * Create a descriptor without attributes.
  -     * @param reference the classname of the context class
  +     * @param classname the classname of a castable interface 
        * @param entries the set of entries required within the context
        */
  -    public ContextDescriptor( final ReferenceDescriptor reference,
  +    public ContextDescriptor( final String classname,
                                 final EntryDescriptor[] entries )
       {
  -        this( reference, entries, null );
  +        this( classname, entries, null );
       }
   
       /**
        * Create a descriptor.
  -     * @param reference the reference descriptor describing the context type
  +     * @param classname the classname of a castable interface 
        * @param entries the set of entries required within the context
        * @param attributes supplimentary attributes associated with the context
  -     * @exception NullPointerException if type or entries argument is null
  -     * @exception IllegalArgumentException if the classname format is invalid
  +     * @exception NullPointerException if the entries argument is null
        */
  -    public ContextDescriptor( final ReferenceDescriptor reference,
  +    public ContextDescriptor( final String classname,
                                 final EntryDescriptor[] entries,
                                 final Properties attributes )
               throws NullPointerException, IllegalArgumentException
  @@ -157,12 +172,15 @@
           {
               throw new NullPointerException( "entries" );
           }
  -        if ( null == reference )
  +
  +        if ( null == classname )
  +        {
  +            m_classname = AVALON_CONTEXT_CLASSNAME;
  +        }
  +        else
           {
  -            throw new NullPointerException( "reference" );
  +            m_classname = classname;
           }
  -
  -        m_reference = reference;
           m_entries = entries;
       }
   
  @@ -171,15 +189,15 @@
       //---------------------------------------------------------
   
       /**
  -     * Return the reference decription for the context
  +     * Return the classname of the context
        * object interface that the supplied context argument
        * supports under a type-safe cast.
        *
        * @return the reference descriptor.
        */
  -    public ReferenceDescriptor getReference()
  +    public String getContextInterfaceClassname()
       {
  -        return m_reference;
  +        return m_classname;
       }
   
       /**
  @@ -277,7 +295,7 @@
           if( isEqual )
           {
               ContextDescriptor entity = (ContextDescriptor) other;
  -            isEqual = isEqual && m_reference.equals( entity.m_reference );
  +            isEqual = isEqual && m_classname.equals( entity.m_classname );
               for( int i=0; i<m_entries.length; i++ )
               {
                   isEqual = isEqual && m_entries[i].equals( entity.m_entries[i] );
  @@ -294,7 +312,7 @@
       {
           int hash = super.hashCode();
           hash >>>= 7;
  -        hash ^= m_reference.hashCode();
  +        hash ^= m_classname.hashCode();
           for( int i=0; i<m_entries.length; i++ )
           {
               hash >>>= 7;
  
  
  
  1.4       +4 -4      avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/ContextDescriptorTestCase.java
  
  Index: ContextDescriptorTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/ContextDescriptorTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContextDescriptorTestCase.java	10 Jul 2003 21:01:10 -0000	1.3
  +++ ContextDescriptorTestCase.java	28 Jul 2003 13:26:56 -0000	1.4
  @@ -63,7 +63,7 @@
    */
   public class ContextDescriptorTestCase extends AbstractDescriptorTestCase
   {
  -    private ReferenceDescriptor m_reference;
  +    private String m_classname;
       private EntryDescriptor[] m_entries;
   
       public ContextDescriptorTestCase( String name )
  @@ -73,7 +73,7 @@
   
       protected Descriptor getDescriptor()
       {
  -        return new ContextDescriptor( m_reference, m_entries, getProperties() );
  +        return new ContextDescriptor( m_classname, m_entries, getProperties() );
       }
   
       protected void checkDescriptor( Descriptor desc )
  @@ -81,7 +81,7 @@
           super.checkDescriptor( desc );
           ContextDescriptor ctxd = (ContextDescriptor) desc;
   
  -        assertEquals( m_reference, ctxd.getReference() );
  +        assertEquals( m_classname, ctxd.getContextInterfaceClassname() );
           assertEquals( m_entries.length, ctxd.getEntries().length );
   
           EntryDescriptor[] entries = ctxd.getEntries();
  @@ -126,7 +126,7 @@
   
       public void setUp()
       {
  -        m_reference = new ReferenceDescriptor( ContextDescriptorTestCase.class.getName(),
new Version( 1, 0, 0 ) );
  +        m_classname = "org.apache.avalon.playground.MyContext";
           m_entries = new EntryDescriptor[]{
               new EntryDescriptor( "key", String.class.getName() )
           };
  
  
  
  1.4       +2 -1      avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/TypeTestCase.java
  
  Index: TypeTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/TypeTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TypeTestCase.java	18 Jul 2003 08:26:30 -0000	1.3
  +++ TypeTestCase.java	28 Jul 2003 13:26:57 -0000	1.4
  @@ -89,7 +89,8 @@
           m_loggers = new CategoryDescriptor[] {
               new CategoryDescriptor("name", new Properties())
           };
  -        m_context = new ContextDescriptor(m_reference, new EntryDescriptor[0]);
  +        m_context = new ContextDescriptor( 
  +          TypeTestCase.class.getName(), new EntryDescriptor[0]);
           m_services = new ServiceDescriptor[] {
               new ServiceDescriptor(m_reference)
           };
  
  
  
  1.9       +5 -8      avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLLegacyCreator.java
  
  Index: XMLLegacyCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLLegacyCreator.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XMLLegacyCreator.java	24 Jul 2003 12:12:01 -0000	1.8
  +++ XMLLegacyCreator.java	28 Jul 2003 13:26:57 -0000	1.9
  @@ -207,9 +207,6 @@
   
       private ContextDescriptor buildPhoenixContext()
       {
  -        ReferenceDescriptor reference = 
  -           createReference( "org.apache.avalon.framework.context.Context" );
  -
           EntryDescriptor name = 
             new EntryDescriptor( 
               ContextDescriptor.NAME_KEY, 
  @@ -224,15 +221,15 @@
               "java.io.File", false, false, "app.home" );
   
           return new ContextDescriptor( 
  -          reference, new EntryDescriptor[]{ name, partition, home }, null );
  +          null, new EntryDescriptor[]{ name, partition, home }, null );
       }
   
       /**
        * A utility method to build an array of {@link ServiceDescriptor}
  -     * objects from specified configuraiton.
  +     * objects from specified configuration.
        *
  -     * @param servicesSet the services configuration
  -     * @return the created ServiceDescriptor
  +     * @param depSet the set of dependency configurations
  +     * @return the created dependency descriptor
        * @throws ConfigurationException if an error occurs
        */
       protected DependencyDescriptor[] buildBlockDependencies( final Configuration depSet
)
  
  
  
  1.10      +2 -3      avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLTypeCreator.java
  
  Index: XMLTypeCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLTypeCreator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XMLTypeCreator.java	26 Jul 2003 11:10:11 -0000	1.9
  +++ XMLTypeCreator.java	28 Jul 2003 13:26:58 -0000	1.10
  @@ -386,8 +386,7 @@
           final Properties attributes =
             buildAttributes( context.getChild( "attributes" ) );
   
  -        ReferenceDescriptor reference = 
  -          buildReferenceDescriptor( context, Context.class.getName() );
  +        String reference = context.getAttribute( "type", null );
   
           return new ContextDescriptor( reference, entrys, attributes );
       }
  
  
  
  1.12      +2 -2      avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/writer/XMLTypeWriter.java
  
  Index: XMLTypeWriter.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/writer/XMLTypeWriter.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLTypeWriter.java	26 Jul 2003 11:10:11 -0000	1.11
  +++ XMLTypeWriter.java	28 Jul 2003 13:26:58 -0000	1.12
  @@ -235,7 +235,7 @@
                                  final ContextDescriptor context )
           throws IOException
       {
  -        final String type = context.getReference().getClassname();
  +        final String type = context.getContextInterfaceClassname();
           final EntryDescriptor[] entrys = context.getEntries();
           final int count = context.getAttributeNames().length;
   
  
  
  
  1.3       +4 -7      avalon-sandbox/meta/tools/src/java/org/apache/avalon/meta/info/builder/tags/ContextTag.java
  
  Index: ContextTag.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/tools/src/java/org/apache/avalon/meta/info/builder/tags/ContextTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContextTag.java	11 Jul 2003 04:49:33 -0000	1.2
  +++ ContextTag.java	28 Jul 2003 13:26:58 -0000	1.3
  @@ -122,11 +122,9 @@
       {
           final JavaMethod[] methods =
               getLifecycleMethods( "contextualize", CONTEXT_CLASS );
  -        if( methods.length == 0 )//null == method )
  +        if( methods.length == 0 )
           {
  -            return new ContextDescriptor(
  -              new ReferenceDescriptor( CONTEXT_CLASS  ),
  -              new EntryDescriptor[0], null );
  +            return new ContextDescriptor( null, new EntryDescriptor[0] );
           }
           else
           {
  @@ -157,8 +155,7 @@
               }
               final EntryDescriptor[] entries =
                 (EntryDescriptor[])list.toArray( new EntryDescriptor[ list.size() ] );
  -            return new ContextDescriptor(
  -              new ReferenceDescriptor( type ), entries, null );
  +            return new ContextDescriptor( type, entries );
           }
       }
   
  
  
  

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


Mime
View raw message