You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/02/19 08:30:28 UTC

cvs commit: avalon/repository/test/src/test/org/apache/avalon/repository/main DefaultInitialContextTest.java

mcconnell    2004/02/18 23:30:27

  Modified:    repository Tag: REPO_2_0 project.xml
               repository/cli/src/java/org/apache/avalon/repository/cli
                        Tag: REPO_2_0 Main.java
               repository/impl Tag: REPO_2_0 project.xml
               repository/impl/src/java/org/apache/avalon/repository/impl
                        Tag: REPO_2_0 DefaultFactory.java
                        DefaultRepository.java
                        DefaultRepositoryCriteria.java avalon.properties
               repository/main/src/java/org/apache/avalon/repository/main
                        Tag: REPO_2_0 DefaultBuilder.java
                        DefaultInitialContext.java
                        DefaultInitialContextFactory.java
               repository/spi/src/java/org/apache/avalon/repository/provider
                        Tag: REPO_2_0 InitialContext.java
                        InitialContextFactory.java
               repository/test/src/test/org/apache/avalon/repository/main
                        Tag: REPO_2_0 DefaultInitialContextTest.java
  Added:       repository/cli/src/java/org/apache/avalon/repository/cli
                        Tag: REPO_2_0 RepositoryVerifier.java
               repository/main/src/java/org/apache/avalon/repository/main
                        Tag: REPO_2_0 DefaultAuthenticator.java
               repository/spi/src/java/org/apache/avalon/repository/provider
                        Tag: REPO_2_0 RepositoryCriteria.java
  Removed:     repository/api/src/java/org/apache/avalon/repository Tag:
                        REPO_2_0 TODO.TXT
               repository/impl/src/java/org/apache/avalon/repository/impl
                        Tag: REPO_2_0 DefaultAuthenticator.java
                        DefaultBlockManifest.java DefaultCacheManager.java
                        DefaultCacheManagerMBean.java ProxyContext.java
               repository/spi/src/java/org/apache/avalon/repository/provider
                        Tag: REPO_2_0 BlockManifest.java CacheManager.java
               repository/test/conf Tag: REPO_2_0 repo.meta test.meta
  Log:
  Refactor the proxy handling so that it is handled exclusively by the intial context.  Repository implementations now can focus just on repo management.  This enables simplification of the SPI model (elimination of the CacheManager) and direct creation of a Repository by the factory.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.13.2.1  +1 -1      avalon/repository/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon/repository/project.xml,v
  retrieving revision 1.13
  retrieving revision 1.13.2.1
  diff -u -r1.13 -r1.13.2.1
  --- project.xml	17 Feb 2004 11:06:17 -0000	1.13
  +++ project.xml	19 Feb 2004 07:30:26 -0000	1.13.2.1
  @@ -6,7 +6,7 @@
     <groupId>avalon</groupId>
     <id>avalon-repository</id>
     <name>Avalon Repository</name>
  -  <currentVersion>1.3</currentVersion>
  +  <currentVersion>1.3-SNAPSHOT</currentVersion>
   
     <organization>
       <name>Apache Software Foundation</name>
  
  
  
  No                   revision
  No                   revision
  1.3.2.1   +8 -5      avalon/repository/cli/src/java/org/apache/avalon/repository/cli/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/cli/src/java/org/apache/avalon/repository/cli/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- Main.java	17 Feb 2004 11:06:16 -0000	1.3
  +++ Main.java	19 Feb 2004 07:30:26 -0000	1.3.2.1
  @@ -42,7 +42,7 @@
   import org.apache.avalon.repository.provider.InitialContext;
   import org.apache.avalon.repository.provider.Factory;
   import org.apache.avalon.repository.RepositoryException;
  -import org.apache.avalon.repository.main.DefaultInitialContext;
  +import org.apache.avalon.repository.main.DefaultInitialContextFactory;
   import org.apache.avalon.repository.main.DefaultBuilder;
   import org.apache.avalon.repository.meta.ArtifactDescriptor;
   import org.apache.avalon.repository.util.RepositoryUtils;
  @@ -191,9 +191,12 @@
                   ClassLoader parent = Main.class.getClassLoader();
                   String[] hosts = getHostsPath( line );
                   
  -                InitialContext context = 
  -                   new DefaultInitialContext( 
  -                     dir, parent, artifact, cache, hosts );
  +                DefaultInitialContextFactory factory = 
  +                  new DefaultInitialContextFactory( "avalon", dir );
  +                factory.setCacheDirectory( cache );
  +                factory.setHosts( hosts );
  +                
  +                InitialContext context = factory.createInitialContext();
   
                   //
                   // process the commandline and do the real work
  
  
  
  No                   revision
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/cli/src/java/org/apache/avalon/repository/cli/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- Main.java	17 Feb 2004 11:06:16 -0000	1.3
  +++ Main.java	19 Feb 2004 07:30:26 -0000	1.3.2.1
  @@ -42,7 +42,7 @@
   import org.apache.avalon.repository.provider.InitialContext;
   import org.apache.avalon.repository.provider.Factory;
   import org.apache.avalon.repository.RepositoryException;
  -import org.apache.avalon.repository.main.DefaultInitialContext;
  +import org.apache.avalon.repository.main.DefaultInitialContextFactory;
   import org.apache.avalon.repository.main.DefaultBuilder;
   import org.apache.avalon.repository.meta.ArtifactDescriptor;
   import org.apache.avalon.repository.util.RepositoryUtils;
  @@ -191,9 +191,12 @@
                   ClassLoader parent = Main.class.getClassLoader();
                   String[] hosts = getHostsPath( line );
                   
  -                InitialContext context = 
  -                   new DefaultInitialContext( 
  -                     dir, parent, artifact, cache, hosts );
  +                DefaultInitialContextFactory factory = 
  +                  new DefaultInitialContextFactory( "avalon", dir );
  +                factory.setCacheDirectory( cache );
  +                factory.setHosts( hosts );
  +                
  +                InitialContext context = factory.createInitialContext();
   
                   //
                   // process the commandline and do the real work
  
  
  
  No                   revision
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/cli/src/java/org/apache/avalon/repository/cli/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- Main.java	17 Feb 2004 11:06:16 -0000	1.3
  +++ Main.java	19 Feb 2004 07:30:26 -0000	1.3.2.1
  @@ -42,7 +42,7 @@
   import org.apache.avalon.repository.provider.InitialContext;
   import org.apache.avalon.repository.provider.Factory;
   import org.apache.avalon.repository.RepositoryException;
  -import org.apache.avalon.repository.main.DefaultInitialContext;
  +import org.apache.avalon.repository.main.DefaultInitialContextFactory;
   import org.apache.avalon.repository.main.DefaultBuilder;
   import org.apache.avalon.repository.meta.ArtifactDescriptor;
   import org.apache.avalon.repository.util.RepositoryUtils;
  @@ -191,9 +191,12 @@
                   ClassLoader parent = Main.class.getClassLoader();
                   String[] hosts = getHostsPath( line );
                   
  -                InitialContext context = 
  -                   new DefaultInitialContext( 
  -                     dir, parent, artifact, cache, hosts );
  +                DefaultInitialContextFactory factory = 
  +                  new DefaultInitialContextFactory( "avalon", dir );
  +                factory.setCacheDirectory( cache );
  +                factory.setHosts( hosts );
  +                
  +                InitialContext context = factory.createInitialContext();
   
                   //
                   // process the commandline and do the real work
  
  
  
  1.1.2.1   +0 -0      avalon/repository/cli/src/java/org/apache/avalon/repository/cli/RepositoryVerifier.java
  
  Index: RepositoryVerifier.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/cli/src/java/org/apache/avalon/repository/cli/RepositoryVerifier.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  
  
  
  No                   revision
  No                   revision
  1.5.2.1   +1 -1      avalon/repository/impl/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon/repository/impl/project.xml,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- project.xml	24 Jan 2004 23:20:04 -0000	1.5
  +++ project.xml	19 Feb 2004 07:30:26 -0000	1.5.2.1
  @@ -8,7 +8,7 @@
     <id>avalon-repository-impl</id>
     <name>Avalon Repository Implementation</name>
     <package>org.apache.avalon.repository</package>
  -  <currentVersion>1.3-SNAPSHOT</currentVersion>
  +  <currentVersion>2.0-SNAPSHOT</currentVersion>
   
     <inceptionYear>2002</inceptionYear>
     <shortDescription>Jar file repository implementation.</shortDescription>
  
  
  
  No                   revision
  No                   revision
  1.4.2.1   +5 -41     avalon/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java
  
  Index: DefaultFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -r1.4 -r1.4.2.1
  --- DefaultFactory.java	24 Jan 2004 23:20:05 -0000	1.4
  +++ DefaultFactory.java	19 Feb 2004 07:30:27 -0000	1.4.2.1
  @@ -38,7 +38,6 @@
   import org.apache.avalon.repository.RepositoryException ;
   import org.apache.avalon.repository.RepositoryRuntimeException;
   import org.apache.avalon.repository.provider.InitialContext ;
  -import org.apache.avalon.repository.provider.CacheManager ;
   import org.apache.avalon.repository.provider.Factory ;
   import org.apache.avalon.repository.util.RepositoryUtils ;
   
  @@ -128,12 +127,13 @@
       public Object create( Map map ) throws Exception
       {
           if( null == map )
  -          throw new NullPointerException( "map" );
  +        {
  +            throw new NullPointerException( "map" );
  +        }
   
           File root = getCache( map );
           String[] hosts = getHosts( map );
  -        ProxyContext proxy = createProxyContext( map );
  -        return new DefaultCacheManager( root, proxy, hosts );
  +        return new DefaultRepository( root, hosts );
       }
   
       private File getCache( Map map )
  @@ -146,41 +146,5 @@
       {
           return (String[]) map.get( 
               DefaultRepositoryCriteria.REPOSITORY_REMOTE_HOSTS );
  -    }
  -
  -    private ProxyContext createProxyContext( Map map )
  -    {
  -        final String proxyHostName = 
  -          (String) map.get( 
  -            DefaultRepositoryCriteria.REPOSITORY_PROXY_HOST );
  -
  -        if( null == proxyHostName )
  -        {
  -            return null;
  -        }
  -        else
  -        {    
  -            final String proxyUsername = 
  -              (String) map.get( 
  -                DefaultRepositoryCriteria.REPOSITORY_PROXY_USERNAME );
  -
  -            final String proxyPassword = 
  -              (String) map.get( 
  -                DefaultRepositoryCriteria.REPOSITORY_PROXY_PASSWORD );
  -
  -            Authenticator authenticator = 
  -              new DefaultAuthenticator( proxyUsername, proxyPassword );
  -
  -            Integer proxyPort = 
  -              (Integer) map.get( 
  -                DefaultRepositoryCriteria.REPOSITORY_PROXY_PORT );
  -            if( null == proxyPort ) proxyPort = new Integer( 0 );
  -
  -            return new ProxyContext( 
  -                proxyHostName, 
  -                proxyPort.intValue(), 
  -                authenticator );
  -        }
  -
       }
   }
  
  
  
  1.6.2.1   +9 -7      avalon/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepository.java
  
  Index: DefaultRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepository.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- DefaultRepository.java	24 Jan 2004 23:20:05 -0000	1.6
  +++ DefaultRepository.java	19 Feb 2004 07:30:27 -0000	1.6.2.1
  @@ -41,7 +41,6 @@
   import org.apache.avalon.repository.RepositoryRuntimeException;
   import org.apache.avalon.repository.meta.FactoryDescriptor;
   import org.apache.avalon.repository.meta.MetaException;
  -import org.apache.avalon.repository.provider.CacheManager;
   import org.apache.avalon.repository.util.LoaderUtils;
   import org.apache.avalon.repository.util.RepositoryUtils;
   
  @@ -59,6 +58,11 @@
       //------------------------------------------------------------------
   
      /**
  +    * The cache directory.
  +    */
  +    private File m_cache;
  +
  +   /**
       * Sequence of remote hosts.
       */
       private final URL[] m_hosts;
  @@ -67,8 +71,6 @@
       * Sequence of remote hosts.
       */
       private final String[] m_roots;
  -
  -    private final CacheManager m_cache;
       
       //------------------------------------------------------------------
       // constructor 
  @@ -81,7 +83,7 @@
       * @exception NullPointerException if the cache or hosts argument
       * is null
       */
  -    public DefaultRepository( CacheManager cache, String[] hosts )
  +    public DefaultRepository( File cache, String[] hosts )
       {
           if( cache == null ) throw new NullPointerException( "cache" );
           if( hosts == null ) throw new NullPointerException( "hosts" );
  @@ -135,7 +137,7 @@
           throws RepositoryException
       {
           return LoaderUtils.getResource( 
  -          artifact, m_roots, m_cache.getCacheDirectory(), true );
  +          artifact, m_roots, m_cache, true );
       }
   
       /**
  @@ -149,7 +151,7 @@
           throws RepositoryException
       {
           return LoaderUtils.getResource( 
  -          artifact, mime, m_roots, m_cache.getCacheDirectory(), true );
  +          artifact, mime, m_roots, m_cache, true );
       }
           
       /**
  
  
  
  1.3.2.1   +74 -67    avalon/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepositoryCriteria.java
  
  Index: DefaultRepositoryCriteria.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepositoryCriteria.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- DefaultRepositoryCriteria.java	18 Feb 2004 13:34:14 -0000	1.3
  +++ DefaultRepositoryCriteria.java	19 Feb 2004 07:30:27 -0000	1.3.2.1
  @@ -28,6 +28,7 @@
   
   import org.apache.avalon.repository.RepositoryException;
   import org.apache.avalon.repository.provider.InitialContext;
  +import org.apache.avalon.repository.provider.RepositoryCriteria;
   
   import org.apache.avalon.util.criteria.Criteria;
   import org.apache.avalon.util.criteria.Parameter;
  @@ -46,7 +47,7 @@
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$
    */
  -public class DefaultRepositoryCriteria extends Criteria
  +public class DefaultRepositoryCriteria extends Criteria implements RepositoryCriteria
   {
       //--------------------------------------------------------------
       // static
  @@ -63,66 +64,62 @@
           null );
   
      /**
  -    * Repository proxy host parameter descriptor.
  +    * Repository proxy password parameter descriptor.
       */
  -    public static final String REPOSITORY_PROXY_HOST = "avalon.repository.proxy.host";
  -    private static final Parameter REPOSITORY_PROXY_HOST_PARAM = 
  -      new Parameter( 
  -        REPOSITORY_PROXY_HOST,
  -        String.class,
  +    public static final String REPOSITORY_REMOTE_HOSTS = InitialContext.HOSTS_KEY;
  +    public static final Parameter REPOSITORY_REMOTE_HOSTS_PARAM = 
  +      new PackedParameter( 
  +        REPOSITORY_REMOTE_HOSTS,
  +        ",",
           null );
   
  +
      /**
  -    * Repository proxy port parameter descriptor.
  +    * Repository proxy host parameter descriptor.
       */
  -    public static final String REPOSITORY_PROXY_PORT = "avalon.repository.proxy.port";
  -    private static final Parameter REPOSITORY_PROXY_PORT_PARAM = 
  -      new Parameter( 
  -        REPOSITORY_PROXY_PORT,
  -        Integer.class,
  -        null );
  +    //public static final String REPOSITORY_PROXY_HOST = "avalon.repository.proxy.host";
  +    //private static final Parameter REPOSITORY_PROXY_HOST_PARAM = 
  +    //  new Parameter( 
  +    //    REPOSITORY_PROXY_HOST,
  +    //    String.class,
  +    //    null );
   
      /**
  -    * Repository proxy username parameter descriptor.
  +    * Repository proxy port parameter descriptor.
       */
  -    public static final String REPOSITORY_PROXY_USERNAME = "avalon.repository.proxy.username";
  -    private static final Parameter REPOSITORY_PROXY_USERNAME_PARAM = 
  -      new Parameter( 
  -        REPOSITORY_PROXY_USERNAME,
  -        String.class,
  -        null );
  +    //public static final String REPOSITORY_PROXY_PORT = "avalon.repository.proxy.port";
  +    //private static final Parameter REPOSITORY_PROXY_PORT_PARAM = 
  +    //  new Parameter( 
  +    //    REPOSITORY_PROXY_PORT,
  +    //    Integer.class,
  +    //    null );
   
      /**
  -    * Repository proxy password parameter descriptor.
  +    * Repository proxy username parameter descriptor.
       */
  -    public static final String REPOSITORY_PROXY_PASSWORD = "avalon.repository.proxy.password";
  -    private static final Parameter REPOSITORY_PROXY_PASSWORD_PARAM = 
  -      new Parameter( 
  -        REPOSITORY_PROXY_PASSWORD,
  -        String.class,
  -        null );
  +    //public static final String REPOSITORY_PROXY_USERNAME = "avalon.repository.proxy.username";
  +    //private static final Parameter REPOSITORY_PROXY_USERNAME_PARAM = 
  +    //  new Parameter( 
  +    //    REPOSITORY_PROXY_USERNAME,
  +    //    String.class,
  +    //    null );
   
      /**
       * Repository proxy password parameter descriptor.
       */
  -    public static final String REPOSITORY_REMOTE_HOSTS = InitialContext.HOSTS_KEY;
  -    public static final Parameter REPOSITORY_REMOTE_HOSTS_PARAM = 
  -      new PackedParameter( 
  -        REPOSITORY_REMOTE_HOSTS,
  -        ",",
  -        null );
  +    //public static final String REPOSITORY_PROXY_PASSWORD = "avalon.repository.proxy.password";
  +    //private static final Parameter REPOSITORY_PROXY_PASSWORD_PARAM = 
  +    //  new Parameter( 
  +    //    REPOSITORY_PROXY_PASSWORD,
  +    //    String.class,
  +    //    null );
   
      /**
       * The factory parameters template.
       */
       public static final Parameter[] PARAMS = new Parameter[]{
              REPOSITORY_CACHE_DIR_PARAM,
  -           REPOSITORY_REMOTE_HOSTS_PARAM,
  -           REPOSITORY_PROXY_HOST_PARAM,
  -           REPOSITORY_PROXY_PORT_PARAM,
  -           REPOSITORY_PROXY_USERNAME_PARAM,
  -           REPOSITORY_PROXY_PASSWORD_PARAM };
  -
  +           REPOSITORY_REMOTE_HOSTS_PARAM };
   
      /** 
       * The name of the static defaults property resource.
  @@ -220,33 +217,33 @@
                   throw new RepositoryException( error, e );
               }
   
  -            if( properties.containsKey( REPOSITORY_PROXY_HOST ) )
  -            {    
  -                put(
  -                  REPOSITORY_PROXY_HOST, 
  -                  new Integer( properties.getProperty( REPOSITORY_PROXY_HOST ) ) );
  +            //if( properties.containsKey( REPOSITORY_PROXY_HOST ) )
  +            //{    
  +            //    put(
  +            //      REPOSITORY_PROXY_HOST, 
  +            //      new Integer( properties.getProperty( REPOSITORY_PROXY_HOST ) ) );
       
  -                if( properties.containsKey( REPOSITORY_PROXY_PORT ) )
  -                {
  -                    put(
  -                      REPOSITORY_PROXY_PORT, 
  -                      new Integer( properties.getProperty( REPOSITORY_PROXY_PORT ) ) );
  -                }
  +            //    if( properties.containsKey( REPOSITORY_PROXY_PORT ) )
  +            //    {
  +            //        put(
  +            //          REPOSITORY_PROXY_PORT, 
  +            //          new Integer( properties.getProperty( REPOSITORY_PROXY_PORT ) ) );
  +            //    }
       
  -                if( properties.containsKey( REPOSITORY_PROXY_USERNAME ) )
  -                {
  -                    put(
  -                      REPOSITORY_PROXY_USERNAME, 
  -                      properties.getProperty( REPOSITORY_PROXY_USERNAME ) );
  -                }
  -
  -                if( properties.containsKey( REPOSITORY_PROXY_PASSWORD ) )
  -                {
  -                    put(
  -                      REPOSITORY_PROXY_PASSWORD, 
  -                      properties.getProperty( REPOSITORY_PROXY_PASSWORD ) );
  -                }
  -            }
  +            //    if( properties.containsKey( REPOSITORY_PROXY_USERNAME ) )
  +            //    {
  +            //        put(
  +            //          REPOSITORY_PROXY_USERNAME, 
  +            //          properties.getProperty( REPOSITORY_PROXY_USERNAME ) );
  +            //    }
  +
  +            //    if( properties.containsKey( REPOSITORY_PROXY_PASSWORD ) )
  +            //    {
  +            //        put(
  +            //          REPOSITORY_PROXY_PASSWORD, 
  +            //          properties.getProperty( REPOSITORY_PROXY_PASSWORD ) );
  +            //    }
  +            //}
           }
           catch( IOException ioe )
           {
  @@ -257,8 +254,18 @@
       }
   
       //--------------------------------------------------------------
  -    // Criteria
  +    // RepositoryCriteria
       //--------------------------------------------------------------
  +
  +    public void setCacheDirectory( File cache )
  +    {
  +        put( REPOSITORY_CACHE_DIR, cache );
  +    }
  +
  +    public void setHosts( String[] hosts )
  +    {
  +        put( REPOSITORY_REMOTE_HOSTS, hosts );
  +    }
   
       public String toString()
       {
  
  
  
  1.1.4.1   +0 -3      avalon/repository/impl/src/java/org/apache/avalon/repository/impl/avalon.properties
  
  Index: avalon.properties
  ===================================================================
  RCS file: /home/cvs/avalon/repository/impl/src/java/org/apache/avalon/repository/impl/avalon.properties,v
  retrieving revision 1.1
  retrieving revision 1.1.4.1
  diff -u -r1.1 -r1.1.4.1
  --- avalon.properties	6 Dec 2003 23:51:08 -0000	1.1
  +++ avalon.properties	19 Feb 2004 07:30:27 -0000	1.1.4.1
  @@ -1,6 +1,3 @@
   # 
   # static implementation defaults
   # 
  -# Alternative root cache directory.
  -# Normally supplied by initial context.
  -#avalon.home = 
  
  
  
  No                   revision
  No                   revision
  1.13.2.1  +2 -14     avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultBuilder.java
  
  Index: DefaultBuilder.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultBuilder.java,v
  retrieving revision 1.13
  retrieving revision 1.13.2.1
  diff -u -r1.13 -r1.13.2.1
  --- DefaultBuilder.java	17 Feb 2004 11:06:16 -0000	1.13
  +++ DefaultBuilder.java	19 Feb 2004 07:30:27 -0000	1.13.2.1
  @@ -42,7 +42,6 @@
   import org.apache.avalon.repository.meta.FactoryDescriptor;
   import org.apache.avalon.repository.provider.Builder;
   import org.apache.avalon.repository.provider.InitialContext;
  -import org.apache.avalon.repository.provider.CacheManager;
   import org.apache.avalon.repository.provider.Factory;
   import org.apache.avalon.util.env.Env;
   import org.apache.avalon.util.exception.ExceptionHelper;
  @@ -243,18 +242,7 @@
   
           ClassLoader parent = getClassLoader( classloader );
   
  -        try
  -        {
  -            Factory factory = m_context.getInitialFactory();
  -            CacheManager manager = (CacheManager)factory.create();
  -            m_repository = manager.createRepository();
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Internal error while attempt to construct initial repository.";
  -            throw new RepositoryException( error, e );           
  -        }
  +        m_repository = m_context.getRepository();
   
           Attributes attributes = m_repository.getAttributes( artifact );
           FactoryDescriptor descriptor = new FactoryDescriptor( attributes );
  
  
  
  1.20.2.1  +44 -378   avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContext.java
  
  Index: DefaultInitialContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContext.java,v
  retrieving revision 1.20
  retrieving revision 1.20.2.1
  diff -u -r1.20 -r1.20.2.1
  --- DefaultInitialContext.java	18 Feb 2004 02:23:57 -0000	1.20
  +++ DefaultInitialContext.java	19 Feb 2004 07:30:27 -0000	1.20.2.1
  @@ -40,6 +40,7 @@
   import java.util.jar.Manifest;
   import java.util.jar.JarFile;
   import java.util.zip.ZipEntry;
  +import java.net.Authenticator;
   
   import javax.naming.NamingException;
   import javax.naming.NamingEnumeration;
  @@ -52,6 +53,7 @@
   import org.apache.avalon.repository.meta.FactoryDescriptor;
   import org.apache.avalon.repository.provider.Factory;
   import org.apache.avalon.repository.provider.InitialContext;
  +import org.apache.avalon.repository.provider.RepositoryCriteria;
   import org.apache.avalon.repository.provider.Builder;
   import org.apache.avalon.repository.util.LoaderUtils;
   import org.apache.avalon.repository.util.RepositoryUtils;
  @@ -81,64 +83,6 @@
       */
       public static final String BLOCK_GROUP_KEY = "Block-Group";
   
  -   /**
  -    * The name of the properties file to be searched for confiuration
  -    * properties.  Seaches will be conducted on the current directory and 
  -    * the user's home directory.
  -    */
  -    public static final String AVALON_PROPERTIES = "avalon.properties";
  -
  -   /**
  -    * Return the Avalon system common directory.  This directory is 
  -    * is used as the default root directory against which the 
  -    * default application repository is established.  
  -    * 
  -    * @return the avalon system home directory.
  -    */
  -    public static File getAvalonHome()
  -    {
  -        try
  -        {
  -            String path = 
  -              System.getProperty( "avalon.home", Env.getEnvVariable( "AVALON_HOME" ) );
  -
  -            if( null != path )
  -            {
  -                return new File( path ).getCanonicalFile();
  -            }
  -            else
  -            {
  -                return new File(
  -                  System.getProperty( "user.home" ) 
  -                  + File.separator 
  -                  + ".avalon" ).getCanonicalFile();
  -            }
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Internal error while attempting to access symbol AVALON_HOME.";
  -            final String message = 
  -              ExceptionHelper.packException( error, e, true );
  -            throw new RuntimeException( message );
  -        }
  -    }
  -
  -    //------------------------------------------------------------------
  -    // private static 
  -    //------------------------------------------------------------------
  -
  -    private static final String AVALON_IMPL_PROPERTIES = 
  -       "avalon.properties";
  -
  -    private static final File USER_HOME = 
  -      new File( System.getProperty( "user.home" ) );
  -
  -    private static final String[] DEFAULT_INITIAL_HOSTS = 
  -      new String[]{
  -        "http://dpml.net/", 
  -        "http://ibiblio.org/maven" };
  -
       //------------------------------------------------------------------
       // immutable state 
       //------------------------------------------------------------------
  @@ -149,7 +93,7 @@
       private final String m_key;
           
      /** 
  -    * The instantiated delegate repository factory.
  +    * The instantiated delegate cache manager factory.
       */
       private final Factory m_factory;
   
  @@ -168,176 +112,14 @@
       */
       private final File m_base;
   
  +    private final Repository m_repository;
  +
       // ------------------------------------------------------------------------
       // constructors
       // ------------------------------------------------------------------------
   
       /**
        * Creates an initial repository context.
  -     * 
  -     * @deprecated use {@link DefaultInitialContextFactory}
  -     * @throws RepositoryException if an error occurs during establishment
  -     */
  -    public DefaultInitialContext( ) 
  -        throws RepositoryException
  -    {
  -         this( (File) null );
  -    }
  -
  -    /**
  -     * Creates an initial repository context.
  -     * 
  -     * @deprecated use {@link DefaultInitialContextFactory}
  -     * @param cache the cache directory
  -     * @throws RepositoryException if an error occurs during establishment
  -     */
  -    public DefaultInitialContext( File cache ) 
  -        throws RepositoryException
  -    {
  -         this( cache, null );
  -    }
  -
  -    /**
  -     * Creates an initial repository context.
  -     * 
  -     * @deprecated use {@link DefaultInitialContextFactory}
  -     * @param hosts a set of initial remote repository addresses 
  -     * @throws RepositoryException if an error occurs during establishment
  -     */
  -    public DefaultInitialContext( String[] hosts ) 
  -        throws RepositoryException
  -    {
  -         this( (File) null, hosts );
  -    }
  -
  -    /**
  -     * Creates an initial repository context.
  -     * 
  -     * @deprecated use {@link DefaultInitialContextFactory}
  -     * @param hosts a set of initial remote repository addresses 
  -     * @param cache the cache directory
  -     * @throws RepositoryException if an error occurs during establishment
  -     */
  -    public DefaultInitialContext( File cache, String[] hosts ) 
  -        throws RepositoryException
  -    {
  -         this( (Artifact) null, cache, hosts );
  -    }
  -    
  -    /**
  -     * Creates an initial repository context.
  -     *
  -     * @deprecated use {@link DefaultInitialContextFactory}
  -     * @param artifact an artifact referencing the default implementation
  -     * @param cache the cache directory
  -     * @param hosts a set of initial remote repository addresses 
  -     * @throws RepositoryException if an error occurs during establishment
  -     */
  -    public DefaultInitialContext( 
  -      Artifact artifact, File cache, String[] hosts ) 
  -      throws RepositoryException
  -    {
  -        this( 
  -          null, null, artifact, cache, hosts );
  -    }
  -
  -    /**
  -     * Creates an initial repository context.
  -     *
  -     * @deprecated use {@link DefaultInitialContextFactory}
  -     * @param base the base working directory
  -     * @param loader the parent classloader
  -     * @param artifact an artifact referencing the default implementation
  -     * @param cache the cache directory
  -     * @param hosts a set of initial remote repository addresses 
  -     * @throws RepositoryException if an error occurs during establishment
  -     */
  -    public DefaultInitialContext( 
  -      File base, ClassLoader loader, Artifact artifact, File cache, String[] hosts ) 
  -      throws RepositoryException
  -    {
  -        m_key = "avalon";
  -
  -        m_base = setupBaseDirectory( base );
  -        m_cache = setupCache( cache, base );
  -        m_hosts = setupHosts( hosts, base );
  -
  -        Artifact implementation = setupImplementation( artifact );
  -        ClassLoader parent = setupClassLoader( loader );
  -
  -        //
  -        // Create the temporary directory to pull down files into
  -        //
  -
  -        if ( ! m_cache.exists() ) m_cache.mkdirs();
  -
  -        //
  -        // Build the url to access the properties of the implementation artifact
  -        // which is default mechanism dependent.
  -        //
  -
  -        Attributes attributes = loadAttributes( m_cache, m_hosts, implementation );
  -        FactoryDescriptor descriptor = new FactoryDescriptor( attributes );
  -        String factory = descriptor.getFactory();
  -        if( null == factory ) 
  -        {
  -            final String error = 
  -              "Required property 'avalon.artifact.factory' not present in artifact: "
  -              + implementation + " under the active cache: [" + m_cache + "] using the "
  -              + "attribute sequence: " + attributes;
  -            throw new IllegalArgumentException( error );
  -        }
  -
  -        //
  -        // Grab all of the dependents in one hit because this is 
  -        // the implementation so we can ignore api/spi spread.
  -        //
  -
  -        Artifact[] dependencies = descriptor.getDependencies();
  -
  -        int n = dependencies.length;
  -        URL[] urls = new URL[ n + 1];
  -        for( int i=0; i<n; i++ )
  -        {
  -            urls[i] = LoaderUtils.getResource( 
  -              dependencies[i], m_hosts, m_cache, true );
  -        }
  -
  -        urls[ n ] = LoaderUtils.getResource( 
  -            implementation, m_hosts, m_cache, true );
  -
  -        //
  -        // create the classloader
  -        //
  -        
  -        ClassLoader classloader = new URLClassLoader( urls, parent );
  -        Class clazz = loadFactoryClass( classloader, factory );
  -
  -        //
  -        // load the actual repository implementation 
  -        //
  -
  -        try
  -        {
  -            m_factory = createDelegate( classloader, clazz, this );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Unable to establish a factory for the supplied artifact:";
  -            StringBuffer buffer = new StringBuffer( error );
  -            buffer.append( "\n artifact: " + implementation );
  -            buffer.append( "\n build: " + descriptor.getBuild() );
  -            buffer.append( "\n factory: " + descriptor.getFactory() );
  -            buffer.append( "\n source: " 
  -              + clazz.getProtectionDomain().getCodeSource().getLocation() );
  -            buffer.append( "\n cache: " + m_cache );
  -            throw new RepositoryException( buffer.toString(), e );
  -        }
  -    }
  -
  -    /**
  -     * Creates an initial repository context.
        *
        * @param parent the parent classloader
        * @param artifact an artifact referencing the default implementation
  @@ -347,7 +129,9 @@
        * @throws RepositoryException if an error occurs during establishment
        */
       DefaultInitialContext( 
  -      String key, ClassLoader parent, Artifact artifact, File base, File cache, String[] hosts ) 
  +      String key, ClassLoader parent, Artifact artifact, File base, File cache, 
  +      String proxyHost, int proxyPort, String proxyUsername, String proxyPassword, 
  +      String[] hosts ) 
         throws RepositoryException
       {
           if( null == key ) throw new NullPointerException( "key" ); 
  @@ -362,6 +146,8 @@
           m_cache = cache;
           m_hosts = hosts;
   
  +        setupProxy( proxyHost, proxyPort, proxyUsername, proxyPassword );
  +
           Attributes attributes = loadAttributes( m_cache, m_hosts, artifact );
           FactoryDescriptor descriptor = new FactoryDescriptor( attributes );
           String factory = descriptor.getFactory();
  @@ -400,12 +186,17 @@
           Class clazz = loadFactoryClass( classloader, factory );
   
           //
  -        // load the actual repository implementation 
  +        // load the cache manager factory implementation 
           //
   
           try
           {
               m_factory = createDelegate( classloader, clazz, this );
  +            RepositoryCriteria criteria = 
  +              (RepositoryCriteria) m_factory.createDefaultCriteria();
  +            criteria.setCacheDirectory( m_cache );
  +            criteria.setHosts( m_hosts );
  +            m_repository = (Repository) m_factory.create( criteria );
           }
           catch( Throwable e )
           {
  @@ -421,11 +212,37 @@
               throw new RepositoryException( buffer.toString(), e );
           }
       }
  -  
  +
  +    private void setupProxy( 
  +      final String host, final int port, final String username, final String password )
  +    {
  +        if( null == host ) return;
  +        Properties system = System.getProperties();
  +        system.put( "proxySet", "true" );
  +        system.put( "proxyHost", host );
  +        system.put( "proxyPort", String.valueOf( port ) );
  +        if( null != username )
  +        {
  +            Authenticator authenticator = 
  +              new DefaultAuthenticator( username, password );
  +            Authenticator.setDefault( authenticator );
  +        }
  +    }
  +
       // ------------------------------------------------------------------------
       // InitialContext
       // ------------------------------------------------------------------------
   
  +    public String getProperty( final String key )
  +    {
  +        return null;
  +    }
  +
  +    public Repository getRepository()
  +    {
  +        return m_repository;
  +    }
  +
       /**
        * Return the application key.  The value of the key may be used 
        * to resolve property files by using the convention 
  @@ -666,156 +483,5 @@
           {
                return RepositoryUtils.getAttributes( hosts, artifact );
           }
  -    }
  -
  -    private ClassLoader setupClassLoader( ClassLoader classloader )
  -    {
  -        if( null != classloader ) return classloader;
  -        return DefaultInitialContext.class.getClassLoader();
  -    }
  -
  -    private File setupCache( File cache, File base )
  -    {
  -        if( null != cache ) return cache;
  -        return setupDefaultCache( base );
  -    }
  -
  -    private String[] setupHosts( String[] hosts, File base )
  -    {
  -        if( null != hosts ) return RepositoryUtils.getCleanPaths( hosts );
  -        return setupDefaultHosts( base );
  -    }
  -
  -    private Artifact setupImplementation( Artifact artifact )
  -    {
  -        if( null != artifact ) return artifact;
  -        return getDefaultImplementation( );
  -    }
  -
  -   /**
  -    * Build the properties that declare the default repository
  -    * implementation that was assigned at build time.
  -    */
  -    private static Properties createDefaultProperties()
  -    {
  -        final String path = AVALON_IMPL_PROPERTIES;
  -        try
  -        {
  -            Properties properties = new Properties();
  -            ClassLoader classloader = DefaultInitialContext.class.getClassLoader();
  -            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 implementation directive.";
  -            RepositoryException re = new RepositoryException( error, e );
  -            re.printStackTrace( System.err );
  -            return null;
  -        }
  -    }
  -
  -    private static Artifact getDefaultImplementation()
  -    {
  -        Properties properties = createDefaultProperties();
  -        String spec = properties.getProperty( 
  -          InitialContext.IMPLEMENTATION_KEY );
  -        if( null == spec )
  -        {
  -            final String error =
  -              "Missing avalon.properties resource.";
  -            throw new IllegalStateException( error );
  -        }
  -        return Artifact.createArtifact( spec );
  -    }
  -
  -    private File setupBaseDirectory( File base )
  -    {
  -        if( null != base ) return base;
  -        return getBaseDirectory();
  -    }
  -
  -    private String[] setupDefaultHosts( File base )
  -    {
  -        String homeValue = getUserProperties().getProperty( HOSTS_KEY );
  -        String workValue = getWorkProperties( base ).getProperty( HOSTS_KEY, homeValue );
  -        String value = System.getProperty( HOSTS_KEY , workValue );
  -        if( null == value ) return DEFAULT_INITIAL_HOSTS;
  -        return expandHosts( value );
  -    }
  -
  -    private static File setupDefaultCache( File base )
  -    {
  -        String homeValue = getUserProperties().getProperty( CACHE_KEY );
  -        String workValue = getWorkProperties( base ).getProperty( CACHE_KEY, homeValue );
  -        String value = System.getProperty( CACHE_KEY , workValue );
  -        if( null != value ) return new File( value  );
  -        return getDefaultCache();
  -    }
  -
  -    private static File getDefaultCache()
  -    {
  -        return new File( getAvalonHome(), "repository" );
  -    }
  -
  -    private static File getBaseDirectory()
  -    {
  -        String base = System.getProperty( "basedir" );
  -        if( null != base )
  -        {
  -            return new File( base );
  -        }
  -        return new File( System.getProperty( "user.dir" ) );
  -    }
  -
  -    private static Properties getLocalProperties( 
  -      File dir, String filename ) 
  -    {
  -        Properties properties = new Properties();
  -        if( null == dir ) return properties;
  -        File file = new File( dir, filename );
  -        if( !file.exists() ) return properties;
  -        try
  -        {
  -            properties.load( new FileInputStream( file ) );
  -            return properties;
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Unexpected exception while attempting to read properties from: " 
  -              + file;
  -            throw new RepositoryRuntimeException( error, e );
  -        }
  -    }
  -
  -    private static String[] expandHosts( String arg )
  -    {
  -        ArrayList list = new ArrayList();
  -        StringTokenizer tokenizer = new StringTokenizer( arg, "," );
  -        while( tokenizer.hasMoreTokens() )
  -        {
  -            list.add( tokenizer.nextToken() );
  -        }
  -        return (String[]) list.toArray( new String[0] );
  -    }
  -
  -    private static Properties getUserProperties()
  -    {
  -        return getLocalProperties( USER_HOME, AVALON_PROPERTIES );
  -    }
  -
  -    private static Properties getWorkProperties( File base )
  -    {
  -        return getLocalProperties( base, AVALON_PROPERTIES );
       }
   }
  
  
  
  1.3.2.1   +100 -1    avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContextFactory.java
  
  Index: DefaultInitialContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContextFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- DefaultInitialContextFactory.java	18 Feb 2004 02:23:57 -0000	1.3
  +++ DefaultInitialContextFactory.java	19 Feb 2004 07:30:27 -0000	1.3.2.1
  @@ -118,6 +118,14 @@
   
       private String[] m_hosts;
   
  +    private String m_proxyHost;
  +
  +    private int m_proxyPort;
  +
  +    private String m_proxyUsername;
  +
  +    private String m_proxyPassword;
  +
       // ------------------------------------------------------------------------
       // constructor
       // ------------------------------------------------------------------------
  @@ -245,6 +253,47 @@
       }
   
      /**
  +    * Set the proxy host name.  If not supplied proxy usage will be 
  +    * disabled.
  +    *
  +    * @param host the proxy host name
  +    */
  +    public void setProxyHost( String host )
  +    {
  +        m_proxyHost = host;
  +    }
  +
  +   /**
  +    * Set the proxy host port.
  +    *
  +    * @param port the proxy port
  +    */
  +    public void setProxyPort( int port )
  +    {
  +        m_proxyPort = port;
  +    }
  +
  +   /**
  +    * Set the proxy username.
  +    *
  +    * @param username the proxy username
  +    */
  +    public void setProxyUsername( String username )
  +    {
  +        m_proxyUsername = username;
  +    }
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @param password the proxy password
  +    */
  +    public void setProxyPassword( String password )
  +    {
  +        m_proxyPassword = password;
  +    }
  +
  +   /**
       * Creation of an inital context based on the system and working 
       * directory, parent classloader, repository cache manager implementation
       * artifact, cache directory, and remote hosts sequence supplied to the 
  @@ -262,6 +311,10 @@
                 getImplementation(),
                 getWorkingDirectory(),
                 getCacheDirectory(),
  +              getProxyHost(),
  +              getProxyPort(),
  +              getProxyUsername(),
  +              getProxyPassword(),
                 getHosts() );
           }
           catch( Throwable e )
  @@ -346,6 +399,52 @@
           String value = m_properties.getProperty( InitialContext.HOSTS_KEY );
           if( null == value ) return new String[0];
           return expandHosts( value );
  +    }
  +
  +   /**
  +    * Get the proxy host name.
  +    *
  +    * @return the proxy host name
  +    */
  +    public String getProxyHost()
  +    {
  +        if( null != m_proxyHost ) return m_proxyHost;
  +        return m_properties.getProperty( InitialContext.PROXY_HOST_KEY );
  +    }
  +
  +   /**
  +    * Get the proxy host port.
  +    *
  +    * @return the proxy port
  +    */
  +    public int getProxyPort()
  +    {
  +        if( m_proxyPort > -1 ) return m_proxyPort;
  +        String value = m_properties.getProperty( InitialContext.PROXY_PORT_KEY );
  +        if( value != null ) return Integer.parseInt( value );
  +        return -1;
  +    }
  +
  +   /**
  +    * Get the proxy username.
  +    *
  +    * @return the proxy username
  +    */
  +    public String getProxyUsername()
  +    {
  +        if( null != m_proxyUsername ) return m_proxyUsername;
  +        return m_properties.getProperty( InitialContext.PROXY_USERNAME_KEY );
  +    }
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @return the proxy password
  +    */
  +    public String getProxyPassword()
  +    {
  +        if( null != m_proxyPassword ) return m_proxyPassword;
  +        return m_properties.getProperty( InitialContext.PROXY_PASSWORD_KEY );
       }
   
       // ------------------------------------------------------------------------
  
  
  
  No                   revision
  
  Index: DefaultInitialContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContextFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- DefaultInitialContextFactory.java	18 Feb 2004 02:23:57 -0000	1.3
  +++ DefaultInitialContextFactory.java	19 Feb 2004 07:30:27 -0000	1.3.2.1
  @@ -118,6 +118,14 @@
   
       private String[] m_hosts;
   
  +    private String m_proxyHost;
  +
  +    private int m_proxyPort;
  +
  +    private String m_proxyUsername;
  +
  +    private String m_proxyPassword;
  +
       // ------------------------------------------------------------------------
       // constructor
       // ------------------------------------------------------------------------
  @@ -245,6 +253,47 @@
       }
   
      /**
  +    * Set the proxy host name.  If not supplied proxy usage will be 
  +    * disabled.
  +    *
  +    * @param host the proxy host name
  +    */
  +    public void setProxyHost( String host )
  +    {
  +        m_proxyHost = host;
  +    }
  +
  +   /**
  +    * Set the proxy host port.
  +    *
  +    * @param port the proxy port
  +    */
  +    public void setProxyPort( int port )
  +    {
  +        m_proxyPort = port;
  +    }
  +
  +   /**
  +    * Set the proxy username.
  +    *
  +    * @param username the proxy username
  +    */
  +    public void setProxyUsername( String username )
  +    {
  +        m_proxyUsername = username;
  +    }
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @param password the proxy password
  +    */
  +    public void setProxyPassword( String password )
  +    {
  +        m_proxyPassword = password;
  +    }
  +
  +   /**
       * Creation of an inital context based on the system and working 
       * directory, parent classloader, repository cache manager implementation
       * artifact, cache directory, and remote hosts sequence supplied to the 
  @@ -262,6 +311,10 @@
                 getImplementation(),
                 getWorkingDirectory(),
                 getCacheDirectory(),
  +              getProxyHost(),
  +              getProxyPort(),
  +              getProxyUsername(),
  +              getProxyPassword(),
                 getHosts() );
           }
           catch( Throwable e )
  @@ -346,6 +399,52 @@
           String value = m_properties.getProperty( InitialContext.HOSTS_KEY );
           if( null == value ) return new String[0];
           return expandHosts( value );
  +    }
  +
  +   /**
  +    * Get the proxy host name.
  +    *
  +    * @return the proxy host name
  +    */
  +    public String getProxyHost()
  +    {
  +        if( null != m_proxyHost ) return m_proxyHost;
  +        return m_properties.getProperty( InitialContext.PROXY_HOST_KEY );
  +    }
  +
  +   /**
  +    * Get the proxy host port.
  +    *
  +    * @return the proxy port
  +    */
  +    public int getProxyPort()
  +    {
  +        if( m_proxyPort > -1 ) return m_proxyPort;
  +        String value = m_properties.getProperty( InitialContext.PROXY_PORT_KEY );
  +        if( value != null ) return Integer.parseInt( value );
  +        return -1;
  +    }
  +
  +   /**
  +    * Get the proxy username.
  +    *
  +    * @return the proxy username
  +    */
  +    public String getProxyUsername()
  +    {
  +        if( null != m_proxyUsername ) return m_proxyUsername;
  +        return m_properties.getProperty( InitialContext.PROXY_USERNAME_KEY );
  +    }
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @return the proxy password
  +    */
  +    public String getProxyPassword()
  +    {
  +        if( null != m_proxyPassword ) return m_proxyPassword;
  +        return m_properties.getProperty( InitialContext.PROXY_PASSWORD_KEY );
       }
   
       // ------------------------------------------------------------------------
  
  
  
  No                   revision
  
  Index: DefaultInitialContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/main/src/java/org/apache/avalon/repository/main/DefaultInitialContextFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- DefaultInitialContextFactory.java	18 Feb 2004 02:23:57 -0000	1.3
  +++ DefaultInitialContextFactory.java	19 Feb 2004 07:30:27 -0000	1.3.2.1
  @@ -118,6 +118,14 @@
   
       private String[] m_hosts;
   
  +    private String m_proxyHost;
  +
  +    private int m_proxyPort;
  +
  +    private String m_proxyUsername;
  +
  +    private String m_proxyPassword;
  +
       // ------------------------------------------------------------------------
       // constructor
       // ------------------------------------------------------------------------
  @@ -245,6 +253,47 @@
       }
   
      /**
  +    * Set the proxy host name.  If not supplied proxy usage will be 
  +    * disabled.
  +    *
  +    * @param host the proxy host name
  +    */
  +    public void setProxyHost( String host )
  +    {
  +        m_proxyHost = host;
  +    }
  +
  +   /**
  +    * Set the proxy host port.
  +    *
  +    * @param port the proxy port
  +    */
  +    public void setProxyPort( int port )
  +    {
  +        m_proxyPort = port;
  +    }
  +
  +   /**
  +    * Set the proxy username.
  +    *
  +    * @param username the proxy username
  +    */
  +    public void setProxyUsername( String username )
  +    {
  +        m_proxyUsername = username;
  +    }
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @param password the proxy password
  +    */
  +    public void setProxyPassword( String password )
  +    {
  +        m_proxyPassword = password;
  +    }
  +
  +   /**
       * Creation of an inital context based on the system and working 
       * directory, parent classloader, repository cache manager implementation
       * artifact, cache directory, and remote hosts sequence supplied to the 
  @@ -262,6 +311,10 @@
                 getImplementation(),
                 getWorkingDirectory(),
                 getCacheDirectory(),
  +              getProxyHost(),
  +              getProxyPort(),
  +              getProxyUsername(),
  +              getProxyPassword(),
                 getHosts() );
           }
           catch( Throwable e )
  @@ -346,6 +399,52 @@
           String value = m_properties.getProperty( InitialContext.HOSTS_KEY );
           if( null == value ) return new String[0];
           return expandHosts( value );
  +    }
  +
  +   /**
  +    * Get the proxy host name.
  +    *
  +    * @return the proxy host name
  +    */
  +    public String getProxyHost()
  +    {
  +        if( null != m_proxyHost ) return m_proxyHost;
  +        return m_properties.getProperty( InitialContext.PROXY_HOST_KEY );
  +    }
  +
  +   /**
  +    * Get the proxy host port.
  +    *
  +    * @return the proxy port
  +    */
  +    public int getProxyPort()
  +    {
  +        if( m_proxyPort > -1 ) return m_proxyPort;
  +        String value = m_properties.getProperty( InitialContext.PROXY_PORT_KEY );
  +        if( value != null ) return Integer.parseInt( value );
  +        return -1;
  +    }
  +
  +   /**
  +    * Get the proxy username.
  +    *
  +    * @return the proxy username
  +    */
  +    public String getProxyUsername()
  +    {
  +        if( null != m_proxyUsername ) return m_proxyUsername;
  +        return m_properties.getProperty( InitialContext.PROXY_USERNAME_KEY );
  +    }
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @return the proxy password
  +    */
  +    public String getProxyPassword()
  +    {
  +        if( null != m_proxyPassword ) return m_proxyPassword;
  +        return m_properties.getProperty( InitialContext.PROXY_PASSWORD_KEY );
       }
   
       // ------------------------------------------------------------------------
  
  
  
  1.1.2.1   +64 -0     avalon/repository/main/src/java/org/apache/avalon/repository/main/Attic/DefaultAuthenticator.java
  
  
  
  
  No                   revision
  No                   revision
  1.9.2.1   +42 -14    avalon/repository/spi/src/java/org/apache/avalon/repository/provider/InitialContext.java
  
  Index: InitialContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/spi/src/java/org/apache/avalon/repository/provider/InitialContext.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- InitialContext.java	18 Feb 2004 02:23:58 -0000	1.9
  +++ InitialContext.java	19 Feb 2004 07:30:27 -0000	1.9.2.1
  @@ -22,6 +22,7 @@
   import java.util.jar.Manifest;
   
   import org.apache.avalon.repository.Artifact;
  +import org.apache.avalon.repository.Repository;
   import org.apache.avalon.repository.RepositoryException;
   
   
  @@ -31,7 +32,7 @@
    * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
  -public interface InitialContext
  +public interface InitialContext 
   {        
      /**
       * The property key used when resolving the default implementation
  @@ -50,17 +51,45 @@
       */
       String HOSTS_KEY = "avalon.repository.hosts";
   
  +    String PROXY_HOST_KEY = "avalon.repository.proxy.host";
  +    String PROXY_PORT_KEY = "avalon.repository.proxy.port";
  +    String PROXY_USERNAME_KEY = "avalon.repository.proxy.username";
  +    String PROXY_PASSWORD_KEY = "avalon.repository.proxy.password";
  +
       String LINE = 
         "\n-----------------------------------------------------------";
   
  +   /**
  +    * Return the application key.  The value of the key may be used 
  +    * to resolve property files by using the convention 
  +    * [key].properties.
  +    * 
  +    * @return the application key.
  +    */
  +    String getApplicationKey();
  +
  +   /**
  +    * <p>Get the value of a property. If the property value does not 
  +    * exists a null value will be returned.  Property value resolution
  +    * shall take into account the following ordered property sources
  +    * (resolved relative to the application key):</p>
  +    * <ul>
  +    * <li>system properties</li>
  +    * <li>working directory properties</li>
  +    * <li>user properties</li>
  +    * <li>application properties</li>
  +    * </ul>
  +    *
  +    * @return the property value
  +    */
  +    String getProperty( String key );
  +
       /**
  -     * Return the application key.  The value of the key may be used 
  -     * to resolve property files by using the convention 
  -     * [key].properties.
  +     * Return cache root directory.
        * 
  -     * @return the application key.
  +     * @return the cache directory
        */
  -    String getApplicationKey();
  +    File getInitialCacheDirectory();
   
       /**
        * Return the base working directory.
  @@ -70,13 +99,6 @@
       File getInitialWorkingDirectory();
   
       /**
  -     * Return cache root directory.
  -     * 
  -     * @return the cache directory
  -     */
  -    File getInitialCacheDirectory();
  -    
  -    /**
        * Return the initial set of host names.
        * @return the host names sequence
        */
  @@ -87,6 +109,12 @@
       * @return the initial repository factory
       */
       Factory getInitialFactory();
  +
  +   /**
  +    * Return the repository.
  +    * @return the repository
  +    */
  +    Repository getRepository();
   
      /**
       * Create a factory builder using a supplied artifact.
  
  
  
  1.1.2.1   +30 -1     avalon/repository/spi/src/java/org/apache/avalon/repository/provider/InitialContextFactory.java
  
  Index: InitialContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/spi/src/java/org/apache/avalon/repository/provider/InitialContextFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- InitialContextFactory.java	17 Feb 2004 11:06:17 -0000	1.1
  +++ InitialContextFactory.java	19 Feb 2004 07:30:27 -0000	1.1.2.1
  @@ -75,6 +75,35 @@
       void setCacheDirectory( File cache );
   
      /**
  +    * Set the proxy host name.  If not supplied proxy usage will be 
  +    * disabled.
  +    *
  +    * @param host the proxy host name
  +    */
  +    void setProxyHost( String host );
  +
  +   /**
  +    * Set the proxy host port.
  +    *
  +    * @param port the proxy port
  +    */
  +    void setProxyPort( int port );
  +
  +   /**
  +    * Set the proxy username.
  +    *
  +    * @param username the proxy username
  +    */
  +    void setProxyUsername( String username );
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @param password the proxy password
  +    */
  +    void setProxyPassword( String password );
  +
  +   /**
       * Set the initial hosts to be used by a repository cache manager 
       * implementation and the initial context implementation when 
       * resolving dependent resources.  If is resource is not present
  
  
  
  No                   revision
  
  Index: InitialContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/spi/src/java/org/apache/avalon/repository/provider/InitialContextFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- InitialContextFactory.java	17 Feb 2004 11:06:17 -0000	1.1
  +++ InitialContextFactory.java	19 Feb 2004 07:30:27 -0000	1.1.2.1
  @@ -75,6 +75,35 @@
       void setCacheDirectory( File cache );
   
      /**
  +    * Set the proxy host name.  If not supplied proxy usage will be 
  +    * disabled.
  +    *
  +    * @param host the proxy host name
  +    */
  +    void setProxyHost( String host );
  +
  +   /**
  +    * Set the proxy host port.
  +    *
  +    * @param port the proxy port
  +    */
  +    void setProxyPort( int port );
  +
  +   /**
  +    * Set the proxy username.
  +    *
  +    * @param username the proxy username
  +    */
  +    void setProxyUsername( String username );
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @param password the proxy password
  +    */
  +    void setProxyPassword( String password );
  +
  +   /**
       * Set the initial hosts to be used by a repository cache manager 
       * implementation and the initial context implementation when 
       * resolving dependent resources.  If is resource is not present
  
  
  
  No                   revision
  
  Index: InitialContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/spi/src/java/org/apache/avalon/repository/provider/InitialContextFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- InitialContextFactory.java	17 Feb 2004 11:06:17 -0000	1.1
  +++ InitialContextFactory.java	19 Feb 2004 07:30:27 -0000	1.1.2.1
  @@ -75,6 +75,35 @@
       void setCacheDirectory( File cache );
   
      /**
  +    * Set the proxy host name.  If not supplied proxy usage will be 
  +    * disabled.
  +    *
  +    * @param host the proxy host name
  +    */
  +    void setProxyHost( String host );
  +
  +   /**
  +    * Set the proxy host port.
  +    *
  +    * @param port the proxy port
  +    */
  +    void setProxyPort( int port );
  +
  +   /**
  +    * Set the proxy username.
  +    *
  +    * @param username the proxy username
  +    */
  +    void setProxyUsername( String username );
  +
  +   /**
  +    * Set the proxy account password.
  +    *
  +    * @param password the proxy password
  +    */
  +    void setProxyPassword( String password );
  +
  +   /**
       * Set the initial hosts to be used by a repository cache manager 
       * implementation and the initial context implementation when 
       * resolving dependent resources.  If is resource is not present
  
  
  
  1.1.2.1   +62 -0     avalon/repository/spi/src/java/org/apache/avalon/repository/provider/Attic/RepositoryCriteria.java
  
  
  
  
  No                   revision
  No                   revision
  1.6.2.1   +21 -22    avalon/repository/test/src/test/org/apache/avalon/repository/main/DefaultInitialContextTest.java
  
  Index: DefaultInitialContextTest.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/test/src/test/org/apache/avalon/repository/main/DefaultInitialContextTest.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- DefaultInitialContextTest.java	24 Jan 2004 23:20:06 -0000	1.6
  +++ DefaultInitialContextTest.java	19 Feb 2004 07:30:27 -0000	1.6.2.1
  @@ -23,12 +23,13 @@
   
   import junit.framework.TestCase ;
   
  -import org.apache.avalon.repository.Artifact ;
  -import org.apache.avalon.repository.Repository ;
  -import org.apache.avalon.repository.RepositoryException ;
  -import org.apache.avalon.repository.provider.CacheManager ;
  -import org.apache.avalon.repository.provider.Factory ;
  -import org.apache.avalon.repository.provider.InitialContext ;
  +import org.apache.avalon.repository.Artifact;
  +import org.apache.avalon.repository.Repository;
  +import org.apache.avalon.repository.RepositoryException;
  +import org.apache.avalon.repository.provider.Factory;
  +import org.apache.avalon.repository.provider.InitialContext;
  +import org.apache.avalon.repository.provider.InitialContextFactory;
  +import org.apache.avalon.repository.main.DefaultInitialContextFactory;
   
   import org.apache.avalon.util.env.Env;
   import org.apache.avalon.util.exception.ExceptionHelper;
  @@ -42,11 +43,10 @@
    */
   public class DefaultInitialContextTest extends TestCase
   {
  +    private static final String KEY = "test";
   
  -    public static void main(String[] args)
  -    {
  -        junit.textui.TestRunner.run(DefaultInitialContextTest.class);
  -    }
  +    private static final File BASEDIR = 
  +      new File( System.getProperty( "basedir" ) );
   
       /**
        * Constructor for DefaultInitialContextTest.
  @@ -59,10 +59,12 @@
   
       public void testRepositoryBootstrap() throws Exception
       {
  -        InitialContext context = 
  -          new DefaultInitialContext( 
  -            getMavenRepositoryDirectory(),
  -            getDefaultHosts() );
  +        DefaultInitialContextFactory factory = 
  +          new DefaultInitialContextFactory( KEY, BASEDIR );
  +        factory.setCacheDirectory( getMavenRepositoryDirectory() );
  +        factory.setHosts( getDefaultHosts() );
  +
  +        InitialContext context = factory.createInitialContext();
   
           assertEquals( 
             "cache", 
  @@ -80,15 +82,12 @@
                 "host", defaults[i], hosts[i] );
           }
   
  -        Factory factory = context.getInitialFactory();
  -        assertNotNull( factory );
  +        Factory initialFactory = context.getInitialFactory();
  +        assertNotNull( initialFactory );
   
  -        CacheManager manager = (CacheManager) factory.create() ;
  -        assertNotNull( manager ) ;
  -   
  -        Repository repository = manager.createRepository() ;
  +        Repository repository = (Repository) context.getRepository() ;
           assertNotNull( repository ) ;
  -        
  +   
           Artifact artifact = Artifact.createArtifact( 
             "avalon-framework", "avalon-framework-api", "4.1.5" );
           URL url = repository.getResource( artifact );
  
  
  

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