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/repository/spi/src/test/org/apache/avalon/repository/meta MetaTest.java
Date Mon, 24 Nov 2003 09:43:31 GMT
mcconnell    2003/11/24 01:43:31

  Modified:    repository/impl/src/java/org/apache/avalon/repository/impl
                        DefaultFactory.java DefaultRepositoryCriteria.java
               repository/main/src/java/org/apache/avalon/repository/main
                        InitialRepositoryFactory.java
               repository/spi/src/java/org/apache/avalon/repository/criteria
                        ValidationException.java
               repository/spi/src/java/org/apache/avalon/repository/meta
                        ApplicationDescriptor.java ArtifactDescriptor.java
               repository/spi/src/test/org/apache/avalon/repository/meta
                        MetaTest.java
  Log:
  Housekeeping.
  
  Revision  Changes    Path
  1.8       +1 -2      avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java
  
  Index: DefaultFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultFactory.java	24 Nov 2003 08:19:09 -0000	1.7
  +++ DefaultFactory.java	24 Nov 2003 09:43:31 -0000	1.8
  @@ -74,7 +74,6 @@
   import org.apache.avalon.repository.criteria.Factory ;
   import org.apache.avalon.repository.criteria.Criteria ;
   import org.apache.avalon.repository.criteria.Parameter ;
  -import org.apache.avalon.repository.criteria.Template ;
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  
  
  
  1.2       +8 -110    avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepositoryCriteria.java
  
  Index: DefaultRepositoryCriteria.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepositoryCriteria.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultRepositoryCriteria.java	24 Nov 2003 08:22:07 -0000	1.1
  +++ DefaultRepositoryCriteria.java	24 Nov 2003 09:43:31 -0000	1.2
  @@ -63,8 +63,8 @@
   import org.apache.avalon.repository.RepositoryCriteria;
   import org.apache.avalon.repository.criteria.Criteria;
   import org.apache.avalon.repository.criteria.Parameter;
  -import org.apache.avalon.repository.criteria.Template;
   import org.apache.avalon.repository.criteria.ValidationException;
  +import org.apache.avalon.repository.criteria.AbstractCriteria;
   
   import org.apache.avalon.defaults.Defaults;
   import org.apache.avalon.defaults.DefaultsFinder;
  @@ -79,7 +79,7 @@
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$
    */
  -public class DefaultRepositoryCriteria implements RepositoryCriteria
  +public class DefaultRepositoryCriteria extends AbstractCriteria implements RepositoryCriteria
   {
       //--------------------------------------------------------------
       // static
  @@ -109,12 +109,6 @@
       };
   
       //--------------------------------------------------------------
  -    // state
  -    //--------------------------------------------------------------
  -
  -     private final Hashtable m_bindings = new Hashtable();
  -
  -    //--------------------------------------------------------------
       // constructor
       //--------------------------------------------------------------
   
  @@ -157,14 +151,14 @@
                cache = ".cache";
           }
   
  -        m_bindings.put( REPOSITORY_CACHE_DIR.getKey(),
  +        setValue( REPOSITORY_CACHE_DIR.getKey(),
               new File( home, cache ) );
   
           try
           {
               String[] hosts = 
                 defaults.getEnumerated( REPOSITORY_REMOTE_HOSTS.getKey() );
  -            m_bindings.put( REPOSITORY_REMOTE_HOSTS.getKey(), hosts );
  +            setValue( REPOSITORY_REMOTE_HOSTS.getKey(), hosts );
           }
           catch ( Throwable e )
           {
  @@ -175,27 +169,27 @@
   
           if( defaults.containsKey( REPOSITORY_PROXY_HOST.getKey() ) )
           {    
  -            m_bindings.put(
  +            setValue(
                 REPOSITORY_PROXY_HOST.getKey(), 
                 new Integer( defaults.getProperty( REPOSITORY_PROXY_HOST.getKey() ) ) );
   
               if( defaults.containsKey( REPOSITORY_PROXY_PORT.getKey() ) )
               {
  -                m_bindings.put(
  +                setValue(
                     REPOSITORY_PROXY_PORT.getKey(), 
                     new Integer( defaults.getProperty( REPOSITORY_PROXY_PORT.getKey() ) )
);
               }
   
               if( defaults.containsKey( REPOSITORY_PROXY_USERNAME.getKey() ) )
               {
  -                m_bindings.put(
  +                setValue(
                     REPOSITORY_PROXY_USERNAME.getKey(), 
                     defaults.getProperty( REPOSITORY_PROXY_USERNAME.getKey() ) );
               }
   
               if( defaults.containsKey( REPOSITORY_PROXY_PASSWORD.getKey() ) )
               {
  -                m_bindings.put(
  +                setValue(
                     REPOSITORY_PROXY_PASSWORD.getKey(), 
                     defaults.getProperty( REPOSITORY_PROXY_PASSWORD.getKey() ) );
               }
  @@ -216,50 +210,6 @@
           return PARAMS;
       }
   
  -   /**
  -    * Set a named parameter of the criteria to a value.
  -    * @param key the parameter key
  -    * @param value the value to assign to the key
  -    * @exception ValidationException if the supplied value fails
  -    *    the validation test for its associated parameter
  -    */
  -    public void setValue( final String key, final Object value ) 
  -      throws ValidationException
  -    {
  -        Parameter p = getParameter( key );
  -        verify( p, value );
  -        m_bindings.put( key, value );
  -    }
  -
  -   /**
  -    * Return the currently assigned value for a key.
  -    * @return the assigned value
  -    */
  -    public Object getValue( final String key )
  -    {
  -        getParameter( key ); // verify key
  -        return m_bindings.get( key );
  -    }
  -
  -   /**
  -    * Return the current state of the criteria as a map.
  -    * @return the criteria as a map
  -    */
  -    public Map getMap()
  -    {
  -        Hashtable map = new Hashtable();
  -        for( int i=0; i<PARAMS.length; i++ )
  -        {
  -            final String key = PARAMS[i].getKey();
  -            Object value = m_bindings.get( key );
  -            if( value != null )
  -            {
  -                map.put( key, value );
  -            }
  -        }
  -        return map;
  -    }
  -
       public String toString()
       {
           return "[repository: " + getMap() + "]";
  @@ -295,57 +245,5 @@
                "Failed to load implementation defaults resource: "
                + DEFAULTS, e );
           }
  -    }
  -
  -   /**
  -    * Verify a value relative to the parameter constraints.
  -    * @param value the value to verify
  -    * @exception ValidationException if the value is invalid
  -    */
  -    public void verify( Parameter param, Object value )
  -      throws ValidationException
  -    {
  -        Class c = getParameterClass( param );
  -        if( value == null ) return;
  -        if( !c.isInstance( value ) )
  -        {
  -            final String error =
  -              "Value of class: [" 
  -              + value.getClass().getName() 
  -              + "] supplied for key [" 
  -              + param.getKey() 
  -              + "] is not an instance of type: [" 
  -              + param.getClassname()
  -              + "].";
  -            throw new ValidationException( error );
  -        }
  -    }
  -
  -    private Class getParameterClass( Parameter param ) 
  -      throws ValidationException
  -    {
  -        try
  -        {
  -            ClassLoader loader = Thread.currentThread().getContextClassLoader();
  -            return loader.loadClass( param.getClassname() );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Unable to resolve parameter class: " 
  -              + param.getClassname();
  -            throw new ValidationException( error, e );
  -        }
  -    }
  -
  -    public Parameter getParameter( final String key )
  -    {
  -        for( int i=0; i<PARAMS.length; i++ )
  -        {
  -            Parameter parameter = PARAMS[i];
  -            if( parameter.getKey().equals( key ) ) return parameter;
  -        }
  -        final String error = "Unknown key: [" + key + "].";
  -        throw new IllegalArgumentException( error );
       }
   }
  
  
  
  1.3       +13 -7     avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/main/InitialRepositoryFactory.java
  
  Index: InitialRepositoryFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/main/InitialRepositoryFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InitialRepositoryFactory.java	24 Nov 2003 09:11:43 -0000	1.2
  +++ InitialRepositoryFactory.java	24 Nov 2003 09:43:31 -0000	1.3
  @@ -365,7 +365,8 @@
           {
               final String error = 
                 "Internal error. " 
  -              + "Unable to locate the standard repository impl directive from the path:
" 
  +              + "Unable to locate the standard repository "
  +              + "impl directive from the path: " 
                 + path;
               RepositoryException re = new RepositoryException( error, e );
               re.printStackTrace( System.err ) ;
  @@ -378,17 +379,22 @@
           Properties properties = null;
           try
           {
  -            properties = RepositoryUtils.getProperties( hosts, STANDARD_REF );
  +            properties = 
  +              RepositoryUtils.getProperties( hosts, STANDARD_REF );
           }
           catch( RepositoryException re )
           {
               properties = createDefaultProperties();
           }
   
  -        final String group = properties.getProperty( TargetMeta.GROUP_KEY );
  -        final String name = properties.getProperty( TargetMeta.NAME_KEY  );
  -        final String version = properties.getProperty( TargetMeta.VERSION_KEY );
  -        return ClassicArtifact.createJarArtifact( group, name, version );
  +        final String group = 
  +          properties.getProperty( ApplicationDescriptor.GROUP_KEY );
  +        final String name = 
  +          properties.getProperty( ApplicationDescriptor.NAME_KEY  );
  +        final String version = 
  +          properties.getProperty( ApplicationDescriptor.VERSION_KEY );
  +        return ClassicArtifact.createJarArtifact( 
  +          group, name, version );
       }
   
   }
  
  
  
  1.2       +5 -10     avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/ValidationException.java
  
  Index: ValidationException.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/ValidationException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ValidationException.java	23 Nov 2003 15:24:12 -0000	1.1
  +++ ValidationException.java	24 Nov 2003 09:43:31 -0000	1.2
  @@ -48,16 +48,17 @@
   
   */
   
  -package org.apache.avalon.repository.criteria ;
  +package org.apache.avalon.repository.criteria;
  +
  +import org.apache.avalon.repository.RepositoryException;
   
   /**
    * 
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$
    */
  -public class ValidationException extends Exception
  +public class ValidationException extends RepositoryException
   {
  -     private final Throwable m_cause;
   
       /**
        * Creation of a new criteria.
  @@ -72,13 +73,7 @@
        */
       public ValidationException( String message, Throwable cause )
       {
  -        super( message );
  -        m_cause = cause;
  -    }
  -
  -    public Throwable getCause()
  -    {
  -        return m_cause;
  +        super( message, cause );
       }
   
   }
  
  
  
  1.2       +2 -2      avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/meta/ApplicationDescriptor.java
  
  Index: ApplicationDescriptor.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/meta/ApplicationDescriptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplicationDescriptor.java	24 Nov 2003 09:11:43 -0000	1.1
  +++ ApplicationDescriptor.java	24 Nov 2003 09:43:31 -0000	1.2
  @@ -171,10 +171,10 @@
       */
       public boolean equals( Object other )
       {
  -        boolean isEqual = other instanceof TargetMeta;
  +        boolean isEqual = other instanceof ApplicationDescriptor;
           if ( isEqual )
           {
  -            TargetMeta meta = (TargetMeta) other;
  +            ApplicationDescriptor meta = (ApplicationDescriptor) other;
               isEqual = isEqual && c_implementation.equals( meta.c_implementation
);
               isEqual = isEqual && c_factory.equals( meta.c_factory );
               isEqual = isEqual && super.equals( meta );
  
  
  
  1.2       +3 -3      avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/meta/ArtifactDescriptor.java
  
  Index: ArtifactDescriptor.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/meta/ArtifactDescriptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArtifactDescriptor.java	24 Nov 2003 09:11:43 -0000	1.1
  +++ ArtifactDescriptor.java	24 Nov 2003 09:43:31 -0000	1.2
  @@ -94,7 +94,7 @@
        * @exception NullPointerException if the domain, classifier
        *   or version attribute is undefined
        */
  -    public Meta( Attributes attributes ) 
  +    public ArtifactDescriptor( Attributes attributes ) 
         throws MetaException
       {
           if( null == attributes )
  @@ -177,10 +177,10 @@
       */
       public boolean equals( Object other )
       {
  -        boolean isEqual = other instanceof Meta;
  +        boolean isEqual = other instanceof ArtifactDescriptor;
           if ( isEqual )
           {
  -            Meta meta = (Meta) other;
  +            ArtifactDescriptor meta = (ArtifactDescriptor) other;
               isEqual = isEqual && c_domain.equals( meta.c_domain );
               isEqual = isEqual && c_classifier.equals( meta.c_classifier );
               isEqual = isEqual && c_version.equals( meta.c_version );
  
  
  
  1.2       +6 -6      avalon-sandbox/repository/spi/src/test/org/apache/avalon/repository/meta/MetaTest.java
  
  Index: MetaTest.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/spi/src/test/org/apache/avalon/repository/meta/MetaTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MetaTest.java	23 Nov 2003 15:24:13 -0000	1.1
  +++ MetaTest.java	24 Nov 2003 09:43:31 -0000	1.2
  @@ -85,7 +85,7 @@
       {
           try
           {
  -            Meta meta = new Meta( null );
  +            ArtifactDescriptor meta = new ArtifactDescriptor( null );
               fail( "constructor using null should throw an NPE" );
           }
           catch( NullPointerException e )
  @@ -103,7 +103,7 @@
           Attributes attributes = new BasicAttributes();
           try
           {
  -            Meta meta = new Meta( attributes );
  +            ArtifactDescriptor meta = new ArtifactDescriptor( attributes );
               fail( "missing attributes should fail" );
           }
           catch( MetaException e )
  @@ -123,13 +123,13 @@
           String version = "123";
   
           Attributes attributes = new BasicAttributes();
  -        attributes.put( Meta.DOMAIN_KEY, domain );
  -        attributes.put( Meta.CLASSIFIER_KEY, classifier );
  -        attributes.put( Meta.VERSION_KEY, version );
  +        attributes.put( ArtifactDescriptor.DOMAIN_KEY, domain );
  +        attributes.put( ArtifactDescriptor.CLASSIFIER_KEY, classifier );
  +        attributes.put( ArtifactDescriptor.VERSION_KEY, version );
   
           try
           {
  -            Meta meta = new Meta( attributes );
  +            ArtifactDescriptor meta = new ArtifactDescriptor( attributes );
               assertEquals( "domain", meta.getDomain(), domain );
               assertEquals( "classifier", meta.getClassifier(), classifier );
               assertEquals( "version", meta.getVersion(), version );
  
  
  

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


Mime
View raw message