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/main/src/java/org/apache/avalon/repository InitialRepositoryFactory.java
Date Tue, 18 Nov 2003 07:39:35 GMT
mcconnell    2003/11/17 23:39:35

  Modified:    repository/main/src/java/org/apache/avalon/repository
                        InitialRepositoryFactory.java
  Log:
  Remove constructors that imply a default repo.  This makes the class require an explicit
remote repository sequence as part of the constructor.
  
  Revision  Changes    Path
  1.4       +30 -89    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InitialRepositoryFactory.java	17 Nov 2003 16:51:53 -0000	1.3
  +++ InitialRepositoryFactory.java	18 Nov 2003 07:39:35 -0000	1.4
  @@ -83,8 +83,7 @@
   public class InitialRepositoryFactory implements RepositoryFactory
   {
       public static final String AVALON_ARTIFACT_DEPENDENCY = 
  -        //"avalon.artifact.dependency";
  -        "avalon.dependency"; // use cached version
  +        "avalon.artifact.dependency";
   
       public static final String REPOSITORY_GROUP_NAME = 
           "avalon-repository" ;
  @@ -100,9 +99,6 @@
       public static final ArtifactReference REFERENCE = 
           new ArtifactReference( REPOSITORY_GROUP_NAME, REPOSITORY_APPLICATION_NAME );
   
  -    private static final String[] DEFAULT_REPOSITORIES =
  -        new String[]{ "http://dpml.net/" };
  -
      /**
       * Build the properties that declare the default repository
       * implementation that was assigned at build time.
  @@ -155,25 +151,15 @@
       private static Properties s_props = null ;
       
       /** the delegate repository factory instantiated */
  -    private RepositoryFactory m_delegate = null ;
  +    private final RepositoryFactory m_delegate;
   
  +    /** the supplied remote repositories */
  +    private final String[] m_repositories;
       
       // ------------------------------------------------------------------------
       // C O N S T R U C T O R S
       // ------------------------------------------------------------------------
       
  -    
  -    /**
  -     * Creates a repository which in turn instantiates the default Repository 
  -     * factory implementation and delegates calls to it.
  -     * 
  -     * @throws RepositoryException
  -     */
  -    public InitialRepositoryFactory() 
  -        throws RepositoryException
  -    {
  -        this( REFERENCE ) ;
  -    }
   
       /**
        * Creates a repository which in turn instantiates a Repository 
  @@ -189,21 +175,6 @@
            this( REFERENCE, repositories );
       }
       
  -    
  -    /**
  -     * Creates a repository which in turn instantiates a Repository 
  -     * factory implementation specified by an artifact descriptor and the 
  -     * implementation factory's class name.  This factory delegates 
  -     * calls to the implementation factory once it is created.
  -     * 
  -     * @throws RepositoryException
  -     */
  -    public InitialRepositoryFactory( ArtifactReference reference ) 
  -        throws RepositoryException
  -    {
  -         this( reference, DEFAULT_REPOSITORIES );
  -    }
  -
       /**
        * Creates a repository which in turn instantiates a Repository 
        * factory implementation specified by an artifact descriptor and the 
  @@ -247,9 +218,9 @@
            */
   
           JarDescriptor implementation = app.getJarDescriptor();
  -        String[] repositories = app.getDefaultRepositories();
  +        m_repositories = app.getDefaultRepositories();
   
  -        Properties l_props = RepositoryUtils.getProperties( repositories, implementation
) ;
  +        Properties l_props = RepositoryUtils.getProperties( m_repositories, implementation
) ;
           Attributes l_attrs = RepositoryUtils.getAsAttributes( l_props ) ;
           
           /*
  @@ -266,8 +237,6 @@
               // If the key that is supplied here is does not have a value we get null 
               // back instead of an empty list
   
  -System.out.println("## LIST: " + l_attrs );
  -
               NamingEnumeration l_list = l_attrs.get( AVALON_ARTIFACT_DEPENDENCY ).getAll()
;
               while ( l_list.hasMore() )
               {
  @@ -286,7 +255,7 @@
                   l_targetFile = new File( l_target.toString() ) ;
   
                   cacheArtifact( 
  -                  l_dep, repositories,
  +                  l_dep, m_repositories,
                     l_targetFile, true ) ;
                   l_urlList.add( l_targetFile.toURL() ) ;
               }
  @@ -331,7 +300,7 @@
               if ( '/' != target.charAt( target.length() - 1 ) ) target.append( '/' ) ;
               target.append( implementation.getRootRelativePath() ) ;
               File file = new File( target.toString() ) ;
  -            cacheArtifact( implementation, repositories, file, true ) ;
  +            cacheArtifact( implementation, m_repositories, file, true ) ;
               l_urlList.add( file.toURL() ) ;
           }
           catch( Throwable e )
  @@ -376,28 +345,6 @@
           }
       }
   
  -    private void printClassLoader( ClassLoader loader )
  -    {
  -        if( loader == null ) return;
  -        if( loader instanceof URLClassLoader )
  -        {
  -            printURLClassLoader( (URLClassLoader) loader );
  -        }
  -    }
  -
  -    private void printURLClassLoader( URLClassLoader loader )
  -    {
  -        System.out.println( "  " );
  -        URL[] urls = loader.getURLs();
  -        for( int i=0; i<urls.length; i++ )
  -        {
  -            System.out.println( "  " + urls[i] );
  -        }
  -
  -        ClassLoader parent = loader.getParent();
  -        printClassLoader( parent );
  -    }
  -
       // ------------------------------------------------------------------------
       // RepositoryFactory Implementations
       // ------------------------------------------------------------------------
  @@ -429,30 +376,9 @@
           return m_delegate.getDefaultContext() ;
       }
       
  -    
       // ------------------------------------------------------------------------
       // Utility Methods
       // ------------------------------------------------------------------------
  -
  -    
  -    /**
  -     * Attempts to download and cache a remote artifact trying a set of remote
  -     * repositories.  The operation is not fail fast and so it keeps trying if
  -     * the first repository does not have the artifact in question.
  -     * 
  -     * @param a_artifact the artifact to retrieve and cache
  -     * @param a_destFile where to store it locally in the cache
  -     * @param a_useTimestamp whether to check the modified timestamp on the
  -     *      <code>destinationFile</code> against the remote <code>source</code>
  -     * @return TRUE if the file was updated else FALSE
  -     */
  -    public static boolean cacheArtifact( ArtifactDescriptor a_artifact, 
  -        File a_destFile, boolean a_useTimestamp ) 
  -        throws RepositoryException
  -    {
  -        return cacheArtifact( a_artifact, DEFAULT_REPOSITORIES, a_destFile, a_useTimestamp
) ;
  -    }
  -    
       
       /**
        * Attempts to download and cache a remote artifact trying a set of remote
  @@ -473,8 +399,6 @@
           boolean l_updated = false ;
           Exception l_cause = null ;
           
  -System.out.println( "## CACHING ARTIFACT");
  -
           /*
            * Don't fail fast - keep trying until we get something.
            */
  @@ -553,9 +477,6 @@
               l_hasTimestamp = true ;
           }
   
  -System.out.println( "USING TIMESTAMP: " + l_timestamp );
  -System.out.println( "HAS TIMESTAMP: " + l_hasTimestamp );
  -
           //set up the URL connection
           URLConnection l_connection = l_source.openConnection() ;
   
  @@ -563,7 +484,6 @@
           //NB: things like user authentication could go in here too.
           if ( a_useTimestamp && l_hasTimestamp )
           {
  -System.out.println( "SETTING IF MODIFIED"  );
               l_connection.setIfModifiedSince( l_timestamp ) ;
           }
   
  @@ -578,7 +498,6 @@
               if ( l_httpConnection.getResponseCode() == 
                       HttpURLConnection.HTTP_NOT_MODIFIED )
               {
  -System.out.println( "NOT MODIFIED RESPONCE"  );
                   return false ;
               }
               
  @@ -661,5 +580,27 @@
           }
           
           return true ;
  +    }
  +
  +    private void printClassLoader( ClassLoader loader )
  +    {
  +        if( loader == null ) return;
  +        if( loader instanceof URLClassLoader )
  +        {
  +            printURLClassLoader( (URLClassLoader) loader );
  +        }
  +    }
  +
  +    private void printURLClassLoader( URLClassLoader loader )
  +    {
  +        System.out.println( "  " );
  +        URL[] urls = loader.getURLs();
  +        for( int i=0; i<urls.length; i++ )
  +        {
  +            System.out.println( "  " + urls[i] );
  +        }
  +
  +        ClassLoader parent = loader.getParent();
  +        printClassLoader( parent );
       }
   }
  
  
  

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


Mime
View raw message