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/util/src/java/org/apache/avalon/repository/util RepositoryUtils.java DefaultRepositoryContext.java
Date Mon, 24 Nov 2003 05:19:54 GMT
mcconnell    2003/11/23 21:19:54

  Modified:    repository/impl project.xml
               repository/impl/src/java/org/apache/avalon/repository/impl
                        ArtifactDatabaseImpl.java
                        DefaultFileRepository.java
               repository/main maven.xml
               repository/main/src/java/org/apache/avalon/repository
                        Bootstrapper.java InitialRepositoryFactory.java
                        Loader.java
               repository/plugin plugin.jelly
               repository/site/src logic.sxd
               repository/site/xdocs/about api.xml
               repository/site/xdocs/images logic.gif
               repository/site/xdocs/start/install cvs.xml
               repository/spi/src/java/org/apache/avalon/repository/criteria
                        Factory.java Parameter.java
               repository/test maven.xml
               repository/test/src/test/org/apache/avalon/repository
                        InitialRepositoryFactoryTest.java LoaderTest.java
               repository/util/src/java/org/apache/avalon/repository/util
                        RepositoryUtils.java
  Added:       repository/impl/src/java/org/apache/avalon/repository/impl
                        DefaultCriteria.java DefaultFactory.java
                        Resources.properties default.properties
               repository/test/conf repo.meta
               repository/test/src/test/org/apache/avalon/repository
                        StandardTest.java
  Removed:     repository/impl/src/java/org/apache/avalon/repository/impl
                        DefaultRepositoryFactory.java defaults.properties
               repository/main/src/java/org/apache/avalon/repository
                        TargetReference.java
               repository/spi/src/java/org/apache/avalon/repository
                        RepositoryContext.java RepositoryFactory.java
               repository/test/src/test/org/apache/avalon/repository
                        TargetReferenceTest.java
               repository/util/src/java/org/apache/avalon/repository/util
                        DefaultRepositoryContext.java
  Log:
  Refactoring to bring the repo impl in line with generic deployable apps, updating of the context model (to enable dynamimc inspection and validation of parameters), and reworking of the Artifact verus Meta notions.
  
  Revision  Changes    Path
  1.6       +4 -0      avalon-sandbox/repository/impl/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/impl/project.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- project.xml	20 Nov 2003 04:17:55 -0000	1.5
  +++ project.xml	24 Nov 2003 05:19:53 -0000	1.6
  @@ -34,6 +34,10 @@
         <artifactId>avalon-util-defaults</artifactId>
         <version>1.0-dev</version>
       </dependency>
  +    <dependency>
  +      <id>excalibur-i18n</id>
  +      <version>1.1</version>
  +    </dependency>
     </dependencies>
   
   </project>
  
  
  
  1.8       +27 -16    avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/ArtifactDatabaseImpl.java
  
  Index: ArtifactDatabaseImpl.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/ArtifactDatabaseImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ArtifactDatabaseImpl.java	23 Nov 2003 02:00:43 -0000	1.7
  +++ ArtifactDatabaseImpl.java	24 Nov 2003 05:19:53 -0000	1.8
  @@ -91,30 +91,35 @@
       /**
        * Creates an artifact database for a set of replicated remote repositories.
        * 
  -     * @param a_remoteRepoBase the base urls of the replicas
  +     * @param repositories the base urls of the replicas
        */
  -    public ArtifactDatabaseImpl( String [] a_remoteRepoBase )
  +    public ArtifactDatabaseImpl( String [] repositories )
       {
  -        m_remoteRepoBase = a_remoteRepoBase ;
  +        if( null == repositories )
  +          throw new NullPointerException( "repositories" );
  +
  +        m_remoteRepoBase = repositories;
       }
       
       
       /**
        * Creates an artifact database for a set of replicated remote repositories.
        * 
  -     * @param a_remoteRepoBase the base urls of the replicas
  +     * @param repositories the base urls of the replicas
        */
  -    public ArtifactDatabaseImpl( URL [] a_remoteRepoBase )
  +    public ArtifactDatabaseImpl( URL [] repositories )
       {
  -        m_remoteRepoBase = new String[ a_remoteRepoBase.length ] ;
  +        if( null == repositories )
  +          throw new NullPointerException( "repositories" );
  +
  +        m_remoteRepoBase = new String[ repositories.length ] ;
           
  -        for ( int ii = 0; ii < a_remoteRepoBase.length; ii++ )
  +        for ( int ii = 0; ii < repositories.length; ii++ )
           {
  -            m_remoteRepoBase[ii] = a_remoteRepoBase[ii].toExternalForm() ; 
  +            m_remoteRepoBase[ii] = repositories[ii].toExternalForm() ; 
           }
       }
       
  -    
       /**
        * @see org.apache.avalon.repository.ArtifactDatabase#
        * getArtifactAttributes(org.apache.avalon.repository.Artifact)
  @@ -122,6 +127,9 @@
       public Attributes getArtifactAttributes( Artifact artifact )
           throws RepositoryException
       {
  +        if( null == artifact )
  +          throw new NullPointerException( "artifact" );
  +
           return RepositoryUtils.getAsAttributes( 
             RepositoryUtils.getProperties( m_remoteRepoBase, artifact ) ) ;
       }
  @@ -133,6 +141,9 @@
       public Artifact[] getDependencies( Artifact artifact ) 
          throws RepositoryException 
       {
  +        if( null == artifact )
  +          throw new NullPointerException( "artifact" );
  +
           return getDependencies( artifact, DEPENDENCY );
       }
   
  @@ -143,19 +154,19 @@
       public Artifact[] getDependencies( Artifact artifact, String key ) 
          throws RepositoryException 
       {
  +        if( null == artifact )
  +          throw new NullPointerException( "artifact" );
  +        if( null == key )
  +          throw new NullPointerException( "key" );
           String spec = null ;
           Artifact[] dependencies = null ;
           Attributes attributes = getArtifactAttributes( artifact ) ;
           
  -        //
  -        // TODO: something strange here if the supplied key does not 
  -        // match - we get back a null value (probably on attribute)
  -        // which is throwing an NPE - need to check into this
  -        //
  -
           try
           {
               Attribute attribute = attributes.get( key ) ;
  +            if( null == attribute ) return new Artifact[0];
  +
               dependencies = new Artifact[ attribute.size() ] ;
               for ( int ii = 0; ii < dependencies.length; ii++ )
               {
  
  
  
  1.14      +1 -48     avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFileRepository.java
  
  Index: DefaultFileRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFileRepository.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultFileRepository.java	23 Nov 2003 02:00:43 -0000	1.13
  +++ DefaultFileRepository.java	24 Nov 2003 05:19:53 -0000	1.14
  @@ -249,54 +249,7 @@
           }
   
           return LOADER.getResource( artifact, m_roots, m_base, true );
  -
  -        /*
  -        final String path = artifact.getURL( "" );
  -        File file = new File( m_base, path );
  -        getFile( path );
  -System.out.println("RESOURCE: " + path + "(" + new File( m_base, path ).exists() + ")" );
  -        try
  -        {
  -            return file.toURL();
  -        }
  -        catch( MalformedURLException mue )
  -        {
  -            final String error =
  -              "Cannot covert file to url: " + file;
  -            throw new RepositoryRuntimeException( error, mue );
  -        }
  -        */
       }
  -
  -    /*
  -    private boolean getFile( String path ) throws RepositoryException 
  -    {
  -        final File local = new File( m_base, path );
  -        try
  -        {
  -            for( int i=0; i<m_hosts.length; i++ )
  -            {
  -                URL host = m_hosts[i];
  -                try
  -                {
  -                    String uri = host.toString() + path;
  -                    return HttpController.getFile( uri, local, true );
  -                }
  -                catch( Throwable ignore )
  -                {
  -                    // ignore and try next
  -                }
  -            }
  -            return false;
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Replication failue on target: " + path;
  -            throw new RepositoryException( error, e );
  -        }
  -    }
  -    */
           
       /**
        * Get a resource relative to the supplied artifact name where the artifact 
  
  
  
  1.1                  avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultCriteria.java
  
  Index: DefaultCriteria.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.repository.impl;
  
  import java.io.IOException;
  import java.io.File;
  import java.io.InputStream;
  import java.util.Properties;
  import java.util.Hashtable;
  import java.util.Map;
  import java.net.URL;
  import java.net.MalformedURLException;
  
  import org.apache.avalon.repository.RepositoryException;
  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.defaults.Defaults;
  import org.apache.avalon.defaults.DefaultsFinder;
  import org.apache.avalon.defaults.SimpleDefaultsFinder;
  import org.apache.avalon.defaults.SystemDefaultsFinder;
  
  
  /**
   * A Criteria is a class holding the values supplied by a user 
   * for application to a factory.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $
   */
  public class DefaultCriteria implements Criteria
  {
      //--------------------------------------------------------------
      // static
      //--------------------------------------------------------------
  
     /** 
      * The name of the static defaults property resource.
      */
      public static final String DEFAULTS = "default.properties";
  
     /** 
      * recognized single keys
      */
      private static final String [] SINGLE_KEYS = {
          DefaultFactory.REPOSITORY_CACHE_DIR.getKey(),
          DefaultFactory.REPOSITORY_PROXY_HOST.getKey(),
          DefaultFactory.REPOSITORY_PROXY_PORT.getKey(),
          DefaultFactory.REPOSITORY_PROXY_USERNAME.getKey(),
          DefaultFactory.REPOSITORY_PROXY_PASSWORD.getKey()
      };
  
     /** 
      * regognized multivalue keys
      */
      public static final String [] MULTI_VALUE_KEYS = {
          DefaultFactory.REPOSITORY_REMOTE_HOSTS.getKey()
      };
  
      //--------------------------------------------------------------
      // state
      //--------------------------------------------------------------
  
       private final Template m_template;
       private final Hashtable m_bindings = new Hashtable();
  
      //--------------------------------------------------------------
      // constructor
      //--------------------------------------------------------------
  
      /**
       * Creation of a new criteria.
       * @param template the template containing the validation parameters
       */
      public DefaultCriteria( Template template ) throws RepositoryException
      {
          if( null == template ) 
           throw new NullPointerException( "template" ); 
  
          m_template = template;
          Properties bootstrap = getDefaultProperties();
  
          //
          // Create the finder (discovery policy), construct the defaults, and
          // macro expand the values.
          //
  
          final DefaultsFinder[] finders = {
              new SimpleDefaultsFinder( new Properties[] { bootstrap }, false ), 
              new SystemDefaultsFinder() };
          
          Defaults defaults = new Defaults( SINGLE_KEYS, MULTI_VALUE_KEYS, finders );
          Defaults.macroExpand( defaults, new Properties[]{ System.getProperties() } );
  
          //
          // Here we start to populate the empty repository configuration using
          // the values stored in the defaults.
          //
  
          // TODO: currently assigning the cache as a subdirectory of user.home.
          // That's ok, but we really should be translating a value 
          // ${user.home}/.avalon and avoid the assumption in the first place
          // but this assumes that macro expansion is doing its job (and I havn't 
          // figured this one out yet).
  
          final File home = new File( System.getProperty( "user.home" ) );
          String cache = 
            defaults.getProperty( 
              DefaultFactory.REPOSITORY_CACHE_DIR.getKey() );
          if( null == cache )
          {
               cache = ".cache";
          }
  
          m_bindings.put(
              DefaultFactory.REPOSITORY_CACHE_DIR.getKey(),
              new File( home, cache ) );
  
          try
          {
              String[] hosts = 
                defaults.getEnumerated( 
                  DefaultFactory.REPOSITORY_REMOTE_HOSTS.getKey() );
              m_bindings.put(
                  DefaultFactory.REPOSITORY_REMOTE_HOSTS.getKey(),
                  hosts );
          }
          catch ( Throwable e )
          {
              final String error = 
                "Failed to set remote repositories.";
              throw new RepositoryException( error, e );
          }
  
          final String PHOST = DefaultFactory.REPOSITORY_PROXY_HOST.getKey();
          final String PPORT = DefaultFactory.REPOSITORY_PROXY_PORT.getKey();
          final String UNAME = DefaultFactory.REPOSITORY_PROXY_USERNAME.getKey();
          final String PWORD = DefaultFactory.REPOSITORY_PROXY_PASSWORD.getKey();
  
          if( defaults.containsKey( PHOST ) )
          {    
              m_bindings.put(
                PHOST, new Integer( defaults.getProperty( PHOST ) ) );
  
              if( defaults.containsKey( PPORT ) )
              {
                  m_bindings.put(
                    PPORT, new Integer( defaults.getProperty( PPORT ) ) );
              }
  
              if( defaults.containsKey( UNAME ) )
              {
                  m_bindings.put(
                    UNAME, defaults.getProperty( UNAME ) );
              }
  
              if( defaults.containsKey( PWORD ) )
              {
                  m_bindings.put(
                    PWORD, defaults.getProperty( PWORD ) );
              }
          }
      }
  
  
      //--------------------------------------------------------------
      // Criteria
      //--------------------------------------------------------------
  
     /**
      * Return the template backing the criteria.
      * @return the template
      */
      public Template getTemplate()
      {
          return m_template;
      }
  
     /**
      * 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 = m_template.getParameter( key );
          p.verify( value );
          m_bindings.put( key, value );
      }
  
     /**
      * Return the currently assigned value for a key.
      * @return the assigned value
      */
      public Object getValue( final String key )
      {
          m_template.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();
          String[] keys = getTemplate().getKeys();
          for( int i=0; i<keys.length; i++ )
          {
              final String key = keys[i];
              Object value = getValue( key );
              if( value != null )
              {
                  map.put( key, value );
              }
          }
          return map;
      }
  
      public String toString()
      {
          return "[repository: " + getMap() + "]";
      }
  
      //--------------------------------------------------------------
      // private
      //--------------------------------------------------------------
  
      private Properties getDefaultProperties() throws RepositoryException
      {
          Properties bootstrap = new Properties();
          try
          {
              InputStream input = 
                DefaultCriteria.class.getResourceAsStream( DEFAULTS );
              if( input == null )
              {
                  final String error = 
                    "Internal error, unable to locate enbedded resource: " 
                    + DEFAULTS 
                    + " from the resource: " 
                    + DefaultCriteria.class.getProtectionDomain()
                        .getCodeSource().getLocation();
                  throw new IllegalStateException( error );
              }
              bootstrap.load( input );
              return bootstrap;
          }
          catch ( IOException e )
          {
              throw new RepositoryException( 
               "Failed to load implementation defaults resource: "
               + DEFAULTS, e );
          }
      }
  }
  
  
  
  1.5       +215 -151  avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java
  
  
  
  
  1.1                  avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  
  repository-cache-dir=The directory to be used as the root of the local file system cache. If not supplied the value will default to "${user.home}/.avalon".
  repository-proxy-host=The proxy hostname.
  repository-proxy-port=The proxy port.
  repository-proxy-username=The proxy username.
  repository-proxy-password=The proxy password.
  repository-remote-hosts=A sequence of remote hosts.
  
  template-description=Avalon Repository RI.
  
  
  1.1                  avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/default.properties
  
  Index: default.properties
  ===================================================================
  # 
  # static implementation defaults
  # 
  
  avalon.repository.cache.dir = .avalon
  
  
  
  1.7       +7 -3      avalon-sandbox/repository/main/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/main/maven.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- maven.xml	23 Nov 2003 14:10:14 -0000	1.6
  +++ maven.xml	24 Nov 2003 05:19:53 -0000	1.7
  @@ -9,8 +9,12 @@
         <j:if test="${dep.getType()=='jar'}">
           <j:if test="${dep.getId() != 'avalon-repository:avalon-repository-impl'}">
             <unzip src="${pom.getDependencyPath( dep.getId() )}" 
  -            dest="${maven.build.dir}/classes"
  -            excludes="/meta-inf/**"/>
  +            dest="${maven.build.dir}/classes">
  +            <patternset>
  +              <exclude name="META-INF/**"/>
  +              <exclude name="*.meta"/>
  +            </patternset>
  +          </unzip>
           </j:if>
         </j:if>
       </j:forEach>
  @@ -49,7 +53,7 @@
   avalon.target.group = ${impl.groupId}
   avalon.target.name = ${impl.artifactId}
   avalon.target.version = ${impl.version}
  -avalon.target.factory = org.apache.avalon.repository.impl.DefaultRepositoryFactory
  +avalon.target.factory = org.apache.avalon.repository.impl.DefaultFactory
   
   #
   # EOF
  
  
  
  1.9       +3 -5      avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/Bootstrapper.java
  
  Index: Bootstrapper.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/Bootstrapper.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Bootstrapper.java	23 Nov 2003 02:00:43 -0000	1.8
  +++ Bootstrapper.java	24 Nov 2003 05:19:53 -0000	1.9
  @@ -58,6 +58,7 @@
   import java.lang.reflect.InvocationTargetException ;
   
   import org.apache.avalon.repository.ClassicArtifact;
  +import org.apache.avalon.repository.criteria.Criteria ;
   
   
   /**
  @@ -491,10 +492,7 @@
               System.out.println("initiating repository creation" );
               InitialRepositoryFactory l_factory = 
                   new InitialRepositoryFactory( l_repositories ) ;
  -            RepositoryContext l_context = l_factory.getDefaultContext();
  -
  -            l_repository = l_factory.create( l_context ) ;
  -
  +            l_repository = (Repository) l_factory.create( ) ;
               System.out.println("repository established" );
               System.out.println(
                 "cache: " 
  
  
  
  1.12      +148 -144  avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/InitialRepositoryFactory.java
  
  Index: InitialRepositoryFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/InitialRepositoryFactory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- InitialRepositoryFactory.java	23 Nov 2003 14:10:14 -0000	1.11
  +++ InitialRepositoryFactory.java	24 Nov 2003 05:19:53 -0000	1.12
  @@ -57,6 +57,7 @@
   import java.io.FileOutputStream ;
   
   import java.util.ArrayList ;
  +import java.util.Map ;
   import java.util.Properties ;
   import java.text.ParseException ;
   
  @@ -73,6 +74,9 @@
   import org.apache.avalon.repository.util.LOADER;
   import org.apache.avalon.repository.ClassicArtifact ;
   import org.apache.avalon.repository.util.RepositoryUtils ;
  +import org.apache.avalon.repository.criteria.Factory ;
  +import org.apache.avalon.repository.criteria.Criteria ;
  +import org.apache.avalon.repository.meta.TargetMeta ;
   
   /**
    * Sets up the environment to create repositories by downloading the required 
  @@ -83,104 +87,38 @@
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$
    */
  -public class InitialRepositoryFactory implements RepositoryFactory
  +public class InitialRepositoryFactory implements Factory
   {
  -    public static final String AVALON_ARTIFACT_DEPENDENCY = 
  -        "avalon.artifact.dependency";
  +    //------------------------------------------------------------------
  +    // static 
  +    //------------------------------------------------------------------
   
  -    public static final String REPOSITORY_GROUP_NAME = 
  +    public static final String STANDARD_GROUP = 
           "avalon-repository";
  -    public static final String REPOSITORY_APPLICATION_NAME = 
  -        "avalon-repository-main";
  -
  -    public static final String DEFAULT_FACTORY = 
  -        "org.apache.avalon.repository.impl.DefaultRepositoryFactory";
   
  +    public static final String STANDARD_NAME = 
  +        "avalon-repository-main";
   
  -   /**
  -    * Build the properties that declare the default repository
  -    * implementation that was assigned at build time.
  -    */
  -    private static Properties createDefaultProperties()
  -    {
  -        final String path = 
  -          REPOSITORY_GROUP_NAME + "/" 
  -          + REPOSITORY_APPLICATION_NAME 
  -          + ".meta";
  -
  -        try
  -        {
  -            Properties properties = new Properties();
  -            ClassLoader classloader = 
  -              Thread.currentThread().getContextClassLoader();
  -            InputStream input = classloader.getResourceAsStream( path );
  -            if( input == null ) 
  -            {
  -                final String error = 
  -                  "Missing resource: [" + path + "]";
  -                throw new Error( error );
  -            }
  -            properties.load( input ) ;
  -            return properties;
  -        }
  -        catch ( Throwable e )
  -        {
  -            final String error = 
  -              "Internal error. " 
  -              + "Unable to locate the standard repository impl directive from the path: " 
  -              + path;
  -            RepositoryException re = new RepositoryException( error, e );
  -            re.printStackTrace( System.err ) ;
  -            return null;
  -        }
  -    }
  -
  -    private static Artifact getDefaultImplementation( String[] hosts )
  -    {
  -        try
  -        {
  -            final TargetReference TARGET = 
  -              new TargetReference( 
  -                 REPOSITORY_GROUP_NAME, REPOSITORY_APPLICATION_NAME );
  -            return TARGET.getArtifact( hosts );
  -        }
  -        catch( RepositoryException re )
  -        {
  -            final Properties PROPERTIES = createDefaultProperties();
  -            final String group = 
  -              PROPERTIES.getProperty( TargetReference.GROUP_KEY );
  -            final String name = 
  -              PROPERTIES.getProperty( TargetReference.NAME_KEY  );
  -            final String version = 
  -              PROPERTIES.getProperty( TargetReference.VERSION_KEY );
  -            return ClassicArtifact.createJarArtifact( 
  -              group, name, version );
  -        }
  -    }
  +    public static final String AVALON_ARTIFACT_DEPENDENCY =
  +        "avalon.artifact.dependency";
   
  -    // ------------------------------------------------------------------------
  -    
  -    /** base property key for the urls of the required jars */
  -    public static final String URLS_BASE = "url" ;
  -    /** factory delegate implementation class name key */
  -    public static final String FACTORY_KEY = "factory" ;
  +    public static final Artifact STANDARD_REF =
  +        Artifact.createArtifact( STANDARD_GROUP, STANDARD_NAME );
   
  -    /** the properties file containing seed information */
  -    public static final String PROPS = "repository.properties" ;
   
  -    /** repository loader's bootstrap properties */
  -    private static Properties s_props = null ;
  -    
  +    //------------------------------------------------------------------
  +    // state 
  +    //------------------------------------------------------------------
  +        
       /** the delegate repository factory instantiated */
  -    private final RepositoryFactory m_delegate;
  +    private final Factory m_delegate;
   
       /** the supplied remote repositories */
       private final String[] m_repositories;
       
       // ------------------------------------------------------------------------
  -    // C O N S T R U C T O R S
  +    // constructors
       // ------------------------------------------------------------------------
  -    
   
       /**
        * Creates a repository which in turn instantiates a Repository 
  @@ -193,9 +131,11 @@
       public InitialRepositoryFactory( String[] repositories ) 
           throws RepositoryException
       {
  -         this( 
  -           getDefaultImplementation( repositories ), 
  -           repositories );
  +         //this( 
  +         //  getDefaultImplementation( repositories ), 
  +         //  repositories );
  +
  +         this( STANDARD_REF, repositories );
       }
       
       /**
  @@ -206,11 +146,13 @@
        * 
        * @throws RepositoryException
        */
  -    public InitialRepositoryFactory( Artifact implementation, String[] repositories ) 
  +    public InitialRepositoryFactory( Artifact reference, String[] repositories ) 
           throws RepositoryException
       {
  -         if( implementation == null ) throw new NullPointerException( "implementation" );
  -         if( repositories == null ) throw new NullPointerException( "repositories" );
  +        if( reference == null ) throw new NullPointerException( "reference" );
  +        if( repositories == null ) throw new NullPointerException( "repositories" );
  +
  +        m_repositories = repositories;
   
           //
           // Create the temporary directory to pull down files into
  @@ -227,37 +169,41 @@
           // which is default mechanism dependent.
           //
   
  -        m_repositories = repositories;
  -        Properties l_props = 
  -          RepositoryUtils.getProperties( m_repositories, implementation ) ;
  -        Attributes attributes = RepositoryUtils.getAsAttributes( l_props ) ;
  -        
  +        TargetMeta target = 
  +          new TargetMeta( 
  +            RepositoryUtils.getAttributes( repositories, reference )  );
  +
  +        Artifact implementation = target.getImplementation();
  +        String factory = target.getFactoryClassname();
  +
           //
           // Download every dependency referenced by the implementation into the
           // temporary cache to build the repository classloader with.
           //
   
  -        ArrayList l_urlList = new ArrayList() ;
  -        Artifact l_dep = null;
  -        String l_spec = null;
  -        File l_targetFile = null;
  +        Attributes attributes = RepositoryUtils.getAttributes( repositories, implementation ) ;
  +
  +        ArrayList list = new ArrayList() ;
  +        Artifact dependency = null;
  +        String spec = null;
  +        File file = null;
           try
           {
               NamingEnumeration l_list = 
                 attributes.get( AVALON_ARTIFACT_DEPENDENCY ).getAll() ;
               while ( l_list.hasMore() )
               {
  -                l_spec = ( String ) l_list.next() ;
  -                l_dep = ClassicArtifact.createJarArtifact( l_spec ) ;
  -                l_urlList.add( LOADER.getResource( 
  -                  l_dep, m_repositories, cache, true ) ) ;
  +                spec = ( String ) l_list.next() ;
  +                dependency = ClassicArtifact.createJarArtifact( spec ) ;
  +                list.add( LOADER.getResource( 
  +                  dependency, m_repositories, cache, true ) ) ;
               }
   
               //
               // add the actual implementation jar file
               //
   
  -            l_urlList.add( 
  +            list.add( 
                 LOADER.getResource( 
                   implementation, m_repositories, cache, true ) );
           }
  @@ -268,10 +214,10 @@
                 + implementation + "]."; 
               throw new RepositoryException( error, e ) ;
           }
  -        catch ( Exception e )
  +        catch ( Throwable e )
           {
               final String error = 
  -              "Unable to download dependent artifact [" + l_spec 
  +              "Unable to download dependent artifact [" + spec 
                 + "] for the implementation reference: [" + implementation + "]."; 
               throw new RepositoryException( error, e ) ;
           }
  @@ -280,8 +226,8 @@
           // create the classloader to load the implementation stack
           //
           
  -        ClassLoader l_loader = new URLClassLoader( 
  -           (URL[]) l_urlList.toArray( new URL [0] ), 
  +        ClassLoader classloader = new URLClassLoader( 
  +           (URL[]) list.toArray( new URL [0] ), 
              Thread.currentThread().getContextClassLoader() ) ;
   
           //
  @@ -290,24 +236,24 @@
           
           try
           {
  -            Class l_clazz = l_loader.loadClass( DEFAULT_FACTORY ) ;
  -            m_delegate = ( RepositoryFactory ) l_clazz.newInstance() ;
  +            Class l_clazz = classloader.loadClass( factory ) ;
  +            m_delegate = ( Factory ) l_clazz.newInstance() ;
           }
           catch( IllegalAccessException e )
           {
               throw new RepositoryException( "Could not default constructor on: " 
  -                + DEFAULT_FACTORY , e ) ;
  +                + factory , e ) ;
           }
           catch( InstantiationException e )
           {
               throw new RepositoryException( 
  -                "Could not instantiate the factory class: " + DEFAULT_FACTORY, e ) ;
  +                "Could not instantiate the factory class: " + factory, e ) ;
           }
           catch( ClassNotFoundException e )
           {
  -            printClassLoader( l_loader );
  +            printClassLoader( classloader );
               throw new RepositoryException( "Could not find the factory class: " 
  -                + DEFAULT_FACTORY, e ) ;
  +                + factory, e ) ;
           }
       }
   
  @@ -318,44 +264,45 @@
       }
   
       // ------------------------------------------------------------------------
  -    // RepositoryFactory
  +    // Factory
       // ------------------------------------------------------------------------
       
  -    /**
  -     * Creates a new Repository using a defaults. 
  -     * 
  -     * @return the newly created Repository
  -     * @throws RepositoryException if there is a problem creating the Repository
  -     */
  -    public Repository create() throws RepositoryException
  +   /**
  +    * Return a new instance of default criteria for the factory.
  +    * @return a new criteria instance
  +    */
  +    public Criteria createDefaultCriteria()
       {
  -        return create( getDefaultContext() );
  +        return m_delegate.createDefaultCriteria() ;
       }
   
  -    /**
  -     * Factory method that creates a repository by calling the delegate factory.
  -     * 
  -     * @param context a repository creation context
  -     * @return the newly created repository
  -     * @throws RepositoryException if there is a failure while creating the repo
  -     * @see org.apache.avalon.repository.RepositoryFactory
  -     * create(org.apache.avalon.repository.RepositoryContext)
  -     */
  -    public Repository create( RepositoryContext context ) 
  -        throws RepositoryException 
  +   /**
  +    * Create a new instance of an application.
  +    * @return the application instance
  +    */
  +    public Object create()
       {
  -        return m_delegate.create( context ) ;
  +        return create( createDefaultCriteria().getMap() );
       }
  -    
  -    /**
  -     * Factory method that creates a default repository configuration bean 
  -     * by calling the delegate factory.
  -     * 
  -     * @see org.apache.avalon.repository.RepositoryFactory#getDefaultContext()
  -     */
  -    public RepositoryContext getDefaultContext() throws RepositoryException
  +
  +   /**
  +    * Create a new instance of an application.
  +    * @param criteria the creation criteria
  +    * @return the application instance
  +    */
  +    public Object create( Criteria criteria )
       {
  -        return m_delegate.getDefaultContext() ;
  +        return create( criteria.getMap() );
  +    }
  +
  +   /**
  +    * Create a new instance of an application.
  +    * @param map the creatiob criteria
  +    * @return the application instance
  +    */
  +    public Object create( Map map )
  +    {
  +        return m_delegate.create( map ) ;
       }
       
       // ------------------------------------------------------------------------
  @@ -383,4 +330,61 @@
           ClassLoader parent = loader.getParent();
           printClassLoader( parent );
       }
  +
  +   /**
  +    * Build the properties that declare the default repository
  +    * implementation that was assigned at build time.
  +    */
  +    private static Properties createDefaultProperties()
  +    {
  +        final String path = 
  +          STANDARD_GROUP + "/" 
  +          + STANDARD_NAME 
  +          + ".meta";
  +
  +        try
  +        {
  +            Properties properties = new Properties();
  +            ClassLoader classloader = 
  +              Thread.currentThread().getContextClassLoader();
  +            InputStream input = classloader.getResourceAsStream( path );
  +            if( input == null ) 
  +            {
  +                final String error = 
  +                  "Missing resource: [" + path + "]";
  +                throw new Error( error );
  +            }
  +            properties.load( input ) ;
  +            return properties;
  +        }
  +        catch ( Throwable e )
  +        {
  +            final String error = 
  +              "Internal error. " 
  +              + "Unable to locate the standard repository impl directive from the path: " 
  +              + path;
  +            RepositoryException re = new RepositoryException( error, e );
  +            re.printStackTrace( System.err ) ;
  +            return null;
  +        }
  +    }
  +
  +    private static ClassicArtifact getDefaultImplementation( String[] hosts )
  +    {
  +        Properties properties = null;
  +        try
  +        {
  +            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 );
  +    }
  +
   }
  
  
  
  1.2       +2 -3      avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/Loader.java
  
  Index: Loader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/main/src/java/org/apache/avalon/repository/Loader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Loader.java	23 Nov 2003 02:00:43 -0000	1.1
  +++ Loader.java	24 Nov 2003 05:19:53 -0000	1.2
  @@ -153,8 +153,7 @@
               System.out.println("  Initiating repository creation." );
               InitialRepositoryFactory l_factory = 
                   new InitialRepositoryFactory( hosts ) ;
  -            repository = l_factory.create() ;
  -
  +            repository = (Repository) l_factory.create() ;
               System.out.println("  Repository established." );
               System.out.println(
                 "cache: " 
  
  
  
  1.2       +6 -2      avalon-sandbox/repository/plugin/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/plugin/plugin.jelly,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- plugin.jelly	20 Nov 2003 22:22:04 -0000	1.1
  +++ plugin.jelly	24 Nov 2003 05:19:53 -0000	1.2
  @@ -31,8 +31,8 @@
   # 
   
   meta.domain = avalon
  -meta.domain.classifier = artifact
  -meta.domain.classifier.version = 1.0
  +meta.classifier = artifact
  +meta.version = 1.0
   
   #
   # Artifact descriptor.
  @@ -103,6 +103,10 @@
         </j:forEach>
   
         <ant:echo file="${filename}" append="true">
  +
  +#
  +# EOF
  +#
   </ant:echo>
   
       <ant:property name="avalonArtifactDestination" 
  
  
  
  1.2       +57 -21    avalon-sandbox/repository/site/src/logic.sxd
  
  	<<Binary file>>
  
  
  1.2       +1 -1      avalon-sandbox/repository/site/xdocs/about/api.xml
  
  Index: api.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/site/xdocs/about/api.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- api.xml	23 Nov 2003 20:17:55 -0000	1.1
  +++ api.xml	24 Nov 2003 05:19:53 -0000	1.2
  @@ -131,7 +131,7 @@
         "merlin", "merlin-kernel-impl", "3.2.2" );
   
   ClassLoader classloader = 
  -    m_repository.getCLassLoader( artifact );</source>
  +    m_repository.getClassLoader( artifact );</source>
   
           </subsection>
         </section>
  
  
  
  1.2       +15 -5     avalon-sandbox/repository/site/xdocs/images/logic.gif
  
  	<<Binary file>>
  
  
  1.3       +2 -2      avalon-sandbox/repository/site/xdocs/start/install/cvs.xml
  
  Index: cvs.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/site/xdocs/start/install/cvs.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- cvs.xml	23 Nov 2003 20:32:32 -0000	1.2
  +++ cvs.xml	24 Nov 2003 05:19:53 -0000	1.3
  @@ -59,9 +59,9 @@
   
           <section name="Avalon Repository - CVS Build">
   
  -          <p>IN-PROGRESS - details concerning CVS build are in flus as the 
  +          <p>IN-PROGRESS - details concerning CVS build are in flux as the 
             Avalon Team finalize a number of aspects concerning repository 
  -          bootstrapping, API and SPI content, and related documentation.
  +          bootstrapping, API, SPI, and related documentation.
             In the meantime, the README.TXT from the CVS install provides a 
             description of the build process.</p>
   
  
  
  
  1.2       +16 -3     avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Factory.java
  
  Index: Factory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Factory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Factory.java	23 Nov 2003 15:24:12 -0000	1.1
  +++ Factory.java	24 Nov 2003 05:19:54 -0000	1.2
  @@ -69,9 +69,22 @@
   
      /**
       * Create a new instance of an application.
  -    * @param map the creatiob criteria
       * @return the application instance
       */
  -    Object create( Map map );
  +    Object create();
  +
  +   /**
  +    * Create a new instance of an application.
  +    * @param criteria the creation criteria
  +    * @return the application instance
  +    */
  +    Object create( Criteria criteria );
  +
  +   /**
  +    * Create a new instance of an application.
  +    * @param map the creation criteria
  +    * @return the application instance
  +    */
  +    Object create( Map map ); // required
   
   }
  
  
  
  1.2       +32 -1     avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Parameter.java
  
  Index: Parameter.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Parameter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Parameter.java	23 Nov 2003 15:24:12 -0000	1.1
  +++ Parameter.java	24 Nov 2003 05:19:54 -0000	1.2
  @@ -61,6 +61,7 @@
       private final String m_type;
       private final boolean m_required;
       private final String m_description;
  +    private final boolean m_multivalue;
   
       /**
        * Creation of a new parameter constraint.
  @@ -73,10 +74,26 @@
         final String key, final String type, boolean required, 
         String description ) 
       {
  +        this( key, type, required, false, description );
  +    }
  +
  +    /**
  +     * Creation of a new parameter constraint.
  +     * @param key the parameter key
  +     * @param type the name of a class constraining assigned values
  +     * @boolean required TRUE if the parameter is required
  +     * @param description a human readable parameter description 
  +     * @param initial an initial default value
  +     */
  +    public Parameter( 
  +      final String key, final String type, boolean required, 
  +      boolean multivalue, String description ) 
  +    {
           m_key = key;
           m_type = type;
           m_required = required;
           m_description = description;
  +        m_multivalue = multivalue ;
       }
   
      /**
  @@ -125,6 +142,15 @@
       }
   
      /**
  +    * Return TRUE if this parameter is multivalued.
  +    * @return the multivalue state
  +    */
  +    public boolean isMultivalue()
  +    {
  +        return m_multivalue;
  +    }
  +
  +   /**
       * Verify a value relative to the parameter constraints.
       * @param value the value to verify
       * @exception ValidationException if the value is invalid
  @@ -133,10 +159,15 @@
         throws ValidationException
       {
           Class c = getParameterClass();
  +        if( value == null ) return;
           if( !c.isInstance( value ) )
           {
               final String error =
  -              "Value is not an instance of type: [" 
  +              "Value of class: [" 
  +              + value.getClass().getName() 
  +              + "] supplied for key [" 
  +              + getKey() 
  +              + "] is not an instance of type: [" 
                 + getClassname()
                 + "].";
               throw new ValidationException( error );
  
  
  
  1.5       +3 -0      avalon-sandbox/repository/test/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/test/maven.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- maven.xml	23 Nov 2003 14:10:14 -0000	1.4
  +++ maven.xml	24 Nov 2003 05:19:54 -0000	1.5
  @@ -12,6 +12,9 @@
       <copy file="${basedir}/conf/test.meta" 
         toDir="${maven.build.dir}/repository/test"
         preserverlastmodified="true"/>
  +    <copy file="${basedir}/conf/repo.meta" 
  +      toDir="${maven.build.dir}/repository/test"
  +      preserverlastmodified="true"/>
     </preGoal>
   
   </project>
  
  
  
  1.1                  avalon-sandbox/repository/test/conf/repo.meta
  
  Index: repo.meta
  ===================================================================
  #
  # Meta classifier.
  # ================
  
  meta.domain = avalon
  meta.classifier = target
  meta.version = 1.0
  
  #
  # Implementation target description.
  # ----------------------------------
  # The following properties describe the implementation artifact
  # that will be used to establish the principal classloader chain.
  #
  
  avalon.target.group = avalon-repository
  avalon.target.name = avalon-repository-impl
  avalon.target.version = 1.2-dev
  avalon.target.factory = org.apache.avalon.repository.impl.DefaultFactory
  
  
  
  
  1.10      +15 -20    avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/InitialRepositoryFactoryTest.java
  
  Index: InitialRepositoryFactoryTest.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/InitialRepositoryFactoryTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- InitialRepositoryFactoryTest.java	23 Nov 2003 15:24:13 -0000	1.9
  +++ InitialRepositoryFactoryTest.java	24 Nov 2003 05:19:54 -0000	1.10
  @@ -51,11 +51,15 @@
   package org.apache.avalon.repository ;
   
   import java.io.File;
  +import java.net.URL;
   
   import junit.framework.TestCase ;
   
   import org.apache.avalon.repository.ClassicArtifact ;
  -import org.apache.avalon.repository.util.DefaultRepositoryContext ;
  +import org.apache.avalon.repository.criteria.Criteria ;
  +import org.apache.avalon.repository.criteria.Factory ;
  +import org.apache.avalon.repository.meta.TargetMeta ;
  +
   
   /**
    * 
  @@ -84,17 +88,14 @@
       public void testRepositoryBootstrap() throws Exception
       {
           String[] bootstrap = getBootstrapRepositorySet();
  -        RepositoryFactory factory = new InitialRepositoryFactory( bootstrap );
  +        Factory factory = new InitialRepositoryFactory( bootstrap );
           assertNotNull( factory );
   
  -        RepositoryContext defaults = factory.getDefaultContext();
  -        assertNotNull( defaults );
  -
  -        DefaultRepositoryContext context = new DefaultRepositoryContext( defaults );
  -
  +        Criteria criteria = factory.createDefaultCriteria();
           String[] repositories = getWorkingRepositorySet();
  -        context.setRemoteRepositoryUrls( repositories ) ;
  -        Repository repository = factory.create( context ) ;
  +        criteria.setValue( "avalon.repository.remote.url", repositories );
  +
  +        Repository repository = (Repository) factory.create( criteria ) ;
           assertNotNull( repository ) ;
           
           repository.getArtifact( 
  @@ -110,19 +111,13 @@
           //
   
           String[] bootstrap = getBootstrapRepositorySet();
  -        RepositoryFactory factory = 
  +        Factory factory = 
             new InitialRepositoryFactory( bootstrap );
  -        RepositoryContext defaults = factory.getDefaultContext();
  -        DefaultRepositoryContext context = new DefaultRepositoryContext( defaults );
   
  +        Criteria criteria = factory.createDefaultCriteria();
           String[] repositories = getWorkingRepositorySet();
  -        context.setRemoteRepositoryUrls( repositories ) ;
  -
  -        //
  -        // create the actual repository
  -        //
  -
  -        Repository repository = factory.create( context ) ;
  +        criteria.setValue( "avalon.repository.remote.url", repositories );
  +        Repository repository = (Repository) factory.create( criteria.getMap() ) ;
   
           //
           // create an artifact that contains a bunch of 
  
  
  
  1.4       +8 -8      avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/LoaderTest.java
  
  Index: LoaderTest.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/LoaderTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LoaderTest.java	23 Nov 2003 14:10:14 -0000	1.3
  +++ LoaderTest.java	24 Nov 2003 05:19:54 -0000	1.4
  @@ -51,6 +51,7 @@
   package org.apache.avalon.repository ;
   
   import java.io.File;
  +import java.net.URL;
   import javax.naming.directory.Attributes;
   import javax.naming.directory.Attribute;
   
  @@ -58,10 +59,9 @@
   
   import org.apache.avalon.repository.Artifact;
   import org.apache.avalon.repository.ClassicArtifact ;
  -import org.apache.avalon.repository.util.DefaultRepositoryContext ;
  -import org.apache.avalon.repository.meta.TargetMeta ;
   import org.apache.avalon.repository.criteria.Criteria ;
   import org.apache.avalon.repository.criteria.Factory ;
  +import org.apache.avalon.repository.meta.TargetMeta ;
   
   /**
    * 
  @@ -86,11 +86,11 @@
       protected void setUp() throws Exception
       {
           String[] bootstrap = getBootstrapRepositorySet();
  -        RepositoryFactory factory = new InitialRepositoryFactory( bootstrap );
  -        RepositoryContext defaults = factory.getDefaultContext();
  -        DefaultRepositoryContext context = new DefaultRepositoryContext( defaults );
  -        context.setRemoteRepositoryUrls( getWorkingRepositorySet() ) ;
  -        m_repository = factory.create( context );
  +        Factory factory = new InitialRepositoryFactory( bootstrap );
  +        Criteria criteria = factory.createDefaultCriteria();
  +        String[] repositories = getWorkingRepositorySet();
  +        criteria.setValue( "avalon.repository.remote.url", repositories );
  +        m_repository = (Repository) factory.create( criteria.getMap() ) ;
       }
   
       //----------------------------------------------------------------------
  
  
  
  1.1                  avalon-sandbox/repository/test/src/test/org/apache/avalon/repository/StandardTest.java
  
  Index: StandardTest.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.repository ;
  
  import java.io.File;
  import java.net.URL;
  import javax.naming.directory.Attributes;
  import javax.naming.directory.Attribute;
  
  import junit.framework.TestCase ;
  
  import org.apache.avalon.repository.Artifact;
  import org.apache.avalon.repository.ClassicArtifact ;
  import org.apache.avalon.repository.criteria.Criteria ;
  import org.apache.avalon.repository.criteria.Factory ;
  import org.apache.avalon.repository.meta.TargetMeta ;
  
  /**
   * 
   * 
   * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
   * @author $Author: mcconnell $
   * @version $Revision: 1.1 $
   */
  public class StandardTest extends TestCase
  {
      private Repository m_repository;
  
      /**
       * Constructor for InitialRepositoryFactoryTest.
       * @param name the name of the testcase
       */
      public StandardTest( String name )
      {
          super( name );
      }
  
      protected void setUp() throws Exception
      {
          String[] bootstrap = getBootstrapRepositorySet();
          Factory factory = new InitialRepositoryFactory( bootstrap );
          Criteria criteria = factory.createDefaultCriteria();
          String[] repositories = getWorkingRepositorySet();
          criteria.setValue( "avalon.repository.remote.url", repositories );
          m_repository = (Repository) factory.create( criteria.getMap() ) ;
      }
  
      //----------------------------------------------------------------------
      // tests
      //----------------------------------------------------------------------
  
      public void testEmbeddingScenario() throws Exception
      {
          Artifact spec = Artifact.createArtifact( "test", "repo" );
          Attributes attributes = m_repository.getArtifactAttributes( spec );
          TargetMeta target = new TargetMeta( attributes );
          Artifact implementation = target.getImplementation();
          String classname = target.getFactoryClassname();
  
          //
          // create a classloader using the artifact referenced by the target
          // using the context classloader as the parent
          //
  
          ClassLoader parent = Thread.currentThread().getContextClassLoader();
          ClassLoader loader = m_repository.getClassLoader( parent, implementation );
          Class c = loader.loadClass( classname );
          Factory factory = (Factory) c.newInstance();
          Criteria criteria = factory.createDefaultCriteria();
          assertNotNull( "criteria", criteria );
  
          //
          // populate the criteria with stuff
          //
  
          //criteria.setValue( 
          //  "urn:merlin:base.dir", 
          //  new File( getBaseDirectory(), "home" ) );
  
          //
          // instantiate the application
          //
  
          Repository repo = (Repository) factory.create( criteria.getMap() );
          System.out.println( "REPO: " + repo );
      }
  
      //----------------------------------------------------------------------
      // utilities
      //----------------------------------------------------------------------
  
      private static String[] getBootstrapRepositorySet()
      {
          return new String[]{ 
            "file:///" + System.getProperty( "basedir" ) + "/target/repository",
          };
      }
  
      private static String[] getWorkingRepositorySet()
      {
          return new String[]{ 
            "file:///" + System.getProperty( "basedir" ) + "/target/repository",
            "http://dpml.net/",
            "http://www.ibiblio.org/maven/"
          };
      }
  
      private File getBaseDirectory()
      {
          String work = System.getProperty( "user.dir" );
          String base = System.getProperty( "basedir", work );
          return new File( base );
      }
  }
  
  
  
  1.3       +16 -1     avalon-sandbox/repository/util/src/java/org/apache/avalon/repository/util/RepositoryUtils.java
  
  Index: RepositoryUtils.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/util/src/java/org/apache/avalon/repository/util/RepositoryUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RepositoryUtils.java	20 Nov 2003 22:46:29 -0000	1.2
  +++ RepositoryUtils.java	24 Nov 2003 05:19:54 -0000	1.3
  @@ -124,6 +124,21 @@
           
           return l_attrs ;
       }
  +
  +    /**
  +     * Gets the Attribues in a remote artifact.
  +     * 
  +     * @param repositories the reprositories to search against
  +     * @param artifact the artifact to oload meta data from
  +     * @return the meta data as attributes
  +     * @throws RepositoryException if there is execution failure
  +     */
  +    public static Attributes getAttributes( 
  +      String [] repositories, Artifact artifact ) 
  +      throws RepositoryException
  +    {
  +        return getAsAttributes( getProperties( repositories, artifact ) ) ;
  +    }
       
       /**
        * Gets the Properties in a remote properties file.
  
  
  

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


Mime
View raw message