You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ak...@apache.org on 2003/11/06 06:28:37 UTC
cvs commit: avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository InitialRepositoryFactory.java RepositoryFactory.java RepositoryConfig.java
akarasulu 2003/11/05 21:28:37
Modified: repository/spi/src/java/org/apache/avalon/repository
InitialRepositoryFactory.java
RepositoryFactory.java RepositoryConfig.java
Log:
Converted RepositoryConfig to an interface and
created a default implementation for it.
Revision Changes Path
1.2 +520 -520 avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/InitialRepositoryFactory.java
Index: InitialRepositoryFactory.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/InitialRepositoryFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InitialRepositoryFactory.java 6 Nov 2003 04:09:15 -0000 1.1
+++ InitialRepositoryFactory.java 6 Nov 2003 05:28:36 -0000 1.2
@@ -1,520 +1,520 @@
-/*
-
- ============================================================================
- 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.io.IOException ;
-import java.io.InputStream ;
-import java.io.FileOutputStream ;
-
-import java.util.ArrayList ;
-import java.util.Properties ;
-import java.util.Enumeration ;
-
-import java.net.URL ;
-import java.net.URLConnection ;
-import java.net.URLClassLoader ;
-import java.net.HttpURLConnection ;
-import java.net.MalformedURLException ;
-
-
-/**
- * Sets up the environment to create repositories by downloading the required
- * jars, preparing a ClassLoader and delegating calls to repository factory
- * methods using a newly configured ClassLoader.
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author$
- * @version $Revision$
- */
-public class InitialRepositoryFactory implements RepositoryFactory
-{
- /** 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" ;
- /** the properties file containing seed information */
- public static final String PROPS = "repository.properties" ;
-
- /** repository loader's bootstrap properties */
- private static Properties s_props = null ;
-
- /** the delegate repository factory instantiated */
- private RepositoryFactory m_delegate = null ;
-
-
- // ------------------------------------------------------------------------
- // C O N S T R U C T O R S
- // ------------------------------------------------------------------------
-
-
- /**
- * Creates a repository loader which loads a default repository factory
- * and delegates calls to it.
- *
- * @throws RepositoryException
- */
- public InitialRepositoryFactory() throws RepositoryException
- {
- /*
- * Create the temporary directory to pull down files into
- */
- String l_userHome = System.getProperty( "user.home" ) ;
- File l_tmpDir = new File( l_userHome, ".bootstrap" ) ;
- if ( ! l_tmpDir.exists() )
- {
- l_tmpDir.mkdirs() ;
- }
-
- JarBuildDescriptor l_myBuild = JarBuildDescriptor
- .getJarBuildDescriptor( InitialRepositoryFactory.class.getClassLoader() ) ;
-
- /*
- * Load default bootstrap (seed) properties
- */
- Properties l_props = new Properties() ;
- try
- {
- Class l_clazz = InitialRepositoryFactory.class ;
- l_props.load( l_clazz.getResourceAsStream( PROPS ) ) ;
- }
- catch( IOException e )
- {
- throw new RepositoryException( "Failed to read " + PROPS, e ) ;
- }
-
- /*
- * Pull down all jars required to bootstrap the repository
- */
- ArrayList l_urlsList = new ArrayList() ;
- Enumeration l_list = l_props.propertyNames() ;
- while ( l_list.hasMoreElements() )
- {
- String l_key = ( String ) l_list.nextElement() ;
-
- if ( ! l_key.startsWith( URLS_BASE ) )
- {
- continue ;
- }
-
- String l_url = l_props.getProperty( l_key ) ;
- int l_fileIdx = l_url.lastIndexOf( '/' ) ;
- String l_fileName = l_url.substring( l_fileIdx + 1 ) ;
- File l_localFile = new File( l_tmpDir, l_fileName ) ;
- boolean l_isSuccess = false ;
-
- try
- {
- l_isSuccess = getTempFile( l_url, l_localFile, true ) ;
- }
- catch ( Exception e )
- {
- throw new RepositoryException(
- "Failed to download bootstrap jar: " + l_url, e ) ;
- }
-
- try
- {
- l_urlsList.add( new URL( l_url ) ) ;
- }
- catch ( MalformedURLException e )
- {
- throw new RepositoryException( l_url + " not a valid URL", e ) ;
- }
- }
-
- /*
- * Check that we have the factory implementation for the delegate
- */
- if ( ! l_props.containsKey( FACTORY_KEY ) )
- {
- throw new RepositoryException( "Factory property " + FACTORY_KEY
- + " must be defined for a factory implementation." ) ;
- }
-
- /*
- * Create the factory class loaders and instantiate the delegate factory
- */
- String l_factory = l_props.getProperty( FACTORY_KEY ) ;
- ClassLoader l_loader = new URLClassLoader( ( URL [] )
- l_urlsList.toArray( new URL [0] ),
- Thread.currentThread().getContextClassLoader() ) ;
- try
- {
- Class l_clazz = l_loader.loadClass( l_factory ) ;
- m_delegate = ( RepositoryFactory ) l_clazz.newInstance() ;
- }
- catch( IllegalAccessException e )
- {
- throw new RepositoryException( "Could not default constructor on: "
- + l_factory, e ) ;
- }
- catch( InstantiationException e )
- {
- throw new RepositoryException(
- "Could not instantiate the factory class: " + l_factory, e ) ;
- }
- catch( ClassNotFoundException e )
- {
- throw new RepositoryException( "Could not find the factory class: "
- + l_factory, e ) ;
- }
- }
-
-
- // ------------------------------------------------------------------------
- // RepositoryFactory Implementations
- // ------------------------------------------------------------------------
-
-
- /**
- * Factory method that creates a repository by calling the delegate factory.
- *
- * @param a_config a repository configuration bean
- * @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.RepositoryConfig)
- */
- public Repository create( RepositoryConfig a_config )
- throws RepositoryException
- {
- return m_delegate.create( a_config ) ;
- }
-
-
- /**
- * Factory method that creates a default repository configuration bean
- * by calling the delegate factory.
- *
- * @see org.apache.avalon.repository.RepositoryFactory#getDefaultConfig()
- */
- public RepositoryConfig getDefaultConfig() throws RepositoryException
- {
- return m_delegate.getDefaultConfig() ;
- }
-
-
- // ------------------------------------------------------------------------
- // Utility Methods
- // ------------------------------------------------------------------------
-
-
- private static Properties getProperties()
- {
- if ( null == s_props )
- {
- s_props = new Properties() ;
-
- try
- {
- s_props.load( InitialRepositoryFactory.class
- .getResourceAsStream( PROPS ) ) ;
- }
- catch ( IOException e )
- {
- e.printStackTrace() ;
- }
- }
-
- return s_props ;
- }
-
-
- /**
- * Gets the urls of remote repositories used to bootstrap.
- *
- * @return the set of remote repo urls to bootstrap from
- */
- public static String [] getBootstrapRepositories()
- {
- Properties l_props = getProperties() ; // getBootstrapProperties(
- //RepositoryLoader.class.getClassLoader(),
- //RepositoryException.class, PROPS ) ;
-
- ArrayList l_values = new ArrayList() ;
- Enumeration l_list = l_props.propertyNames() ;
- while ( l_list.hasMoreElements() )
- {
- String l_key = ( String ) l_list.nextElement() ;
-
- if ( l_key.startsWith( URLS_BASE ) )
- {
- l_values.add( l_props.getProperty( l_key ) ) ;
- }
- }
-
- return ( String [] ) l_values.toArray( new String [0] ) ;
- }
-
-
- /**
- * 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
- {
- String [] l_srcs = getBootstrapRepositories() ;
- return cacheArtifact( a_artifact, l_srcs, a_destFile, a_useTimestamp ) ;
- }
-
-
- /**
- * 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_repos the remote repositories to try to download from
- * @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,
- String [] a_repos, File a_destFile, boolean a_useTimestamp )
- throws RepositoryException
- {
- boolean l_updated = false ;
- Exception l_cause = null ;
-
- /*
- * Don't fail fast - keep trying until we get something.
- */
- for ( int ii = 0; ii < a_repos.length; ii++ )
- {
- try
- {
- String l_url = a_artifact.getUrl( a_repos[ii] ) ;
- l_updated = getTempFile( l_url, a_destFile, a_useTimestamp ) ;
- return l_updated ;
- }
- catch ( Exception e )
- {
- l_cause = e ;
- }
- }
-
- if ( null == l_cause )
- {
- throw new RepositoryException( "Failed to download artifact to "
- + "local cache file " + a_destFile.getAbsolutePath() ) ;
- }
-
- // Should not really execute but it shuts up the compiler
- throw new RepositoryException( "Failed to download artifact to "
- + "local cache file " + a_destFile.getAbsolutePath(), l_cause ) ;
- }
-
-
- /**
- * Retrieve a remote file. Returns true if the file was successfully
- * retrieved or if it is up to date (when the useTimestamp flag is set).
- *
- * Moved here from HttpController.
- *
- * @param a_url the of the file to retrieve
- * @param a_destFile where to store it
- * @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 getTempFile( String a_url, File a_destFile,
- boolean a_useTimestamp ) throws Exception
- {
- URL l_source = null ;
- String l_username = null ;
- String l_password = null ;
-
- // We want to be able to deal with Basic Auth where the username
- // and password are part of the URL. An example of the URL string
- // we would like to be able to parse is like the following:
- //
- // http://username:password@repository.mycompany.com
-
- int l_atIdx = a_url.indexOf( "@" ) ;
- if ( l_atIdx > 0 )
- {
- String s = a_url.substring( 7, l_atIdx ) ;
- int l_colonIdx = s.indexOf( ":" ) ;
- l_username = s.substring( 0, l_colonIdx ) ;
- l_password = s.substring( l_colonIdx + 1 ) ;
- l_source = new URL( "http://" + a_url.substring( l_atIdx + 1 ) ) ;
- }
- else
- {
- l_source = new URL( a_url ) ;
- }
-
- //set the timestamp to the file date.
- long l_timestamp = 0 ;
- boolean l_hasTimestamp = false ;
- if ( a_useTimestamp && a_destFile.exists() )
- {
- l_timestamp = a_destFile.lastModified() ;
- l_hasTimestamp = true ;
- }
-
- //set up the URL connection
- URLConnection l_connection = l_source.openConnection() ;
-
- //modify the headers
- //NB: things like user authentication could go in here too.
- if ( a_useTimestamp && l_hasTimestamp )
- {
- l_connection.setIfModifiedSince( l_timestamp ) ;
- }
-
- //connect to the remote site (may take some time)
- l_connection.connect() ;
- //next test for a 304 result (HTTP only)
- if ( l_connection instanceof HttpURLConnection )
- {
- HttpURLConnection l_httpConnection =
- ( HttpURLConnection ) l_connection ;
-
- if ( l_httpConnection.getResponseCode() ==
- HttpURLConnection.HTTP_NOT_MODIFIED )
- {
- return false ;
- }
-
- // test for 401 result (HTTP only)
- if ( l_httpConnection.getResponseCode() ==
- HttpURLConnection.HTTP_UNAUTHORIZED )
- {
- throw new Exception( "Not authorized." ) ;
- }
- }
-
- // REVISIT: at this point even non HTTP connections may support the
- // if-modified-since behaviour - we just check the date of the
- // content and skip the write if it is not newer.
- // Some protocols (FTP) dont include dates, of course.
-
- InputStream l_in = null ;
- for ( int ii = 0; ii < 3; ii++ )
- {
- try
- {
- l_in = l_connection.getInputStream() ;
- break ;
- }
- catch ( IOException ex )
- {
- // do nothing
- }
- }
- if ( l_in == null )
- {
- final String error =
- "Connection returned a null input stream: " + a_url ;
- throw new IOException( error ) ;
- }
-
- File parent = a_destFile.getParentFile() ;
- parent.mkdirs() ;
-
- FileOutputStream l_out = new FileOutputStream( a_destFile ) ;
-
- byte[] buffer = new byte[100 * 1024] ;
- int length ;
-
- System.out.print( "Source: " + l_source + "\n") ;
- while ( ( length = l_in.read( buffer ) ) >= 0 )
- {
- l_out.write( buffer, 0, length ) ;
- System.out.print( "." ) ;
- }
-
- System.out.println( "" ) ;
- l_out.close() ;
- l_in.close() ;
-
- // if (and only if) the use file time option is set, then the
- // saved file now has its timestamp set to that of the downloaded
- // file
-
- if ( a_useTimestamp )
- {
- long l_remoteTimestamp = l_connection.getLastModified() ;
-
- if ( l_remoteTimestamp != 0 )
- {
- long l_modifiedTime ;
-
- if ( l_remoteTimestamp < 0 )
- {
- l_modifiedTime = System.currentTimeMillis() ;
- }
- else
- {
- l_modifiedTime = l_remoteTimestamp ;
- }
-
- a_destFile.setLastModified( l_modifiedTime ) ;
- return true ;
- }
- }
-
- return true ;
- }
-}
+/*
+
+ ============================================================================
+ 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.io.IOException ;
+import java.io.InputStream ;
+import java.io.FileOutputStream ;
+
+import java.util.ArrayList ;
+import java.util.Properties ;
+import java.util.Enumeration ;
+
+import java.net.URL ;
+import java.net.URLConnection ;
+import java.net.URLClassLoader ;
+import java.net.HttpURLConnection ;
+import java.net.MalformedURLException ;
+
+
+/**
+ * Sets up the environment to create repositories by downloading the required
+ * jars, preparing a ClassLoader and delegating calls to repository factory
+ * methods using a newly configured ClassLoader.
+ *
+ * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
+ * @author $Author$
+ * @version $Revision$
+ */
+public class InitialRepositoryFactory implements RepositoryFactory
+{
+ /** 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" ;
+ /** the properties file containing seed information */
+ public static final String PROPS = "repository.properties" ;
+
+ /** repository loader's bootstrap properties */
+ private static Properties s_props = null ;
+
+ /** the delegate repository factory instantiated */
+ private RepositoryFactory m_delegate = null ;
+
+
+ // ------------------------------------------------------------------------
+ // C O N S T R U C T O R S
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * Creates a repository loader which loads a default repository factory
+ * and delegates calls to it.
+ *
+ * @throws RepositoryException
+ */
+ public InitialRepositoryFactory() throws RepositoryException
+ {
+ /*
+ * Create the temporary directory to pull down files into
+ */
+ String l_userHome = System.getProperty( "user.home" ) ;
+ File l_tmpDir = new File( l_userHome, ".bootstrap" ) ;
+ if ( ! l_tmpDir.exists() )
+ {
+ l_tmpDir.mkdirs() ;
+ }
+
+ JarBuildDescriptor l_myBuild = JarBuildDescriptor
+ .getJarBuildDescriptor( InitialRepositoryFactory.class.getClassLoader() ) ;
+
+ /*
+ * Load default bootstrap (seed) properties
+ */
+ Properties l_props = new Properties() ;
+ try
+ {
+ Class l_clazz = InitialRepositoryFactory.class ;
+ l_props.load( l_clazz.getResourceAsStream( PROPS ) ) ;
+ }
+ catch( IOException e )
+ {
+ throw new RepositoryException( "Failed to read " + PROPS, e ) ;
+ }
+
+ /*
+ * Pull down all jars required to bootstrap the repository
+ */
+ ArrayList l_urlsList = new ArrayList() ;
+ Enumeration l_list = l_props.propertyNames() ;
+ while ( l_list.hasMoreElements() )
+ {
+ String l_key = ( String ) l_list.nextElement() ;
+
+ if ( ! l_key.startsWith( URLS_BASE ) )
+ {
+ continue ;
+ }
+
+ String l_url = l_props.getProperty( l_key ) ;
+ int l_fileIdx = l_url.lastIndexOf( '/' ) ;
+ String l_fileName = l_url.substring( l_fileIdx + 1 ) ;
+ File l_localFile = new File( l_tmpDir, l_fileName ) ;
+ boolean l_isSuccess = false ;
+
+ try
+ {
+ l_isSuccess = getTempFile( l_url, l_localFile, true ) ;
+ }
+ catch ( Exception e )
+ {
+ throw new RepositoryException(
+ "Failed to download bootstrap jar: " + l_url, e ) ;
+ }
+
+ try
+ {
+ l_urlsList.add( new URL( l_url ) ) ;
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new RepositoryException( l_url + " not a valid URL", e ) ;
+ }
+ }
+
+ /*
+ * Check that we have the factory implementation for the delegate
+ */
+ if ( ! l_props.containsKey( FACTORY_KEY ) )
+ {
+ throw new RepositoryException( "Factory property " + FACTORY_KEY
+ + " must be defined for a factory implementation." ) ;
+ }
+
+ /*
+ * Create the factory class loaders and instantiate the delegate factory
+ */
+ String l_factory = l_props.getProperty( FACTORY_KEY ) ;
+ ClassLoader l_loader = new URLClassLoader( ( URL [] )
+ l_urlsList.toArray( new URL [0] ),
+ Thread.currentThread().getContextClassLoader() ) ;
+ try
+ {
+ Class l_clazz = l_loader.loadClass( l_factory ) ;
+ m_delegate = ( RepositoryFactory ) l_clazz.newInstance() ;
+ }
+ catch( IllegalAccessException e )
+ {
+ throw new RepositoryException( "Could not default constructor on: "
+ + l_factory, e ) ;
+ }
+ catch( InstantiationException e )
+ {
+ throw new RepositoryException(
+ "Could not instantiate the factory class: " + l_factory, e ) ;
+ }
+ catch( ClassNotFoundException e )
+ {
+ throw new RepositoryException( "Could not find the factory class: "
+ + l_factory, e ) ;
+ }
+ }
+
+
+ // ------------------------------------------------------------------------
+ // RepositoryFactory Implementations
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * Factory method that creates a repository by calling the delegate factory.
+ *
+ * @param a_config a repository configuration bean
+ * @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.RepositoryConfig)
+ */
+ public Repository create( RepositoryConfig a_config )
+ throws RepositoryException
+ {
+ return m_delegate.create( a_config ) ;
+ }
+
+
+ /**
+ * Factory method that creates a default repository configuration bean
+ * by calling the delegate factory.
+ *
+ * @see org.apache.avalon.repository.RepositoryFactory#getDefaultConfig()
+ */
+ public RepositoryConfig getDefaultConfig() throws RepositoryException
+ {
+ return m_delegate.getDefaultConfig() ;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Utility Methods
+ // ------------------------------------------------------------------------
+
+
+ private static Properties getProperties()
+ {
+ if ( null == s_props )
+ {
+ s_props = new Properties() ;
+
+ try
+ {
+ s_props.load( InitialRepositoryFactory.class
+ .getResourceAsStream( PROPS ) ) ;
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace() ;
+ }
+ }
+
+ return s_props ;
+ }
+
+
+ /**
+ * Gets the urls of remote repositories used to bootstrap.
+ *
+ * @return the set of remote repo urls to bootstrap from
+ */
+ public static String [] getBootstrapRepositories()
+ {
+ Properties l_props = getProperties() ; // getBootstrapProperties(
+ //RepositoryLoader.class.getClassLoader(),
+ //RepositoryException.class, PROPS ) ;
+
+ ArrayList l_values = new ArrayList() ;
+ Enumeration l_list = l_props.propertyNames() ;
+ while ( l_list.hasMoreElements() )
+ {
+ String l_key = ( String ) l_list.nextElement() ;
+
+ if ( l_key.startsWith( URLS_BASE ) )
+ {
+ l_values.add( l_props.getProperty( l_key ) ) ;
+ }
+ }
+
+ return ( String [] ) l_values.toArray( new String [0] ) ;
+ }
+
+
+ /**
+ * 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
+ {
+ String [] l_srcs = getBootstrapRepositories() ;
+ return cacheArtifact( a_artifact, l_srcs, a_destFile, a_useTimestamp ) ;
+ }
+
+
+ /**
+ * 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_repos the remote repositories to try to download from
+ * @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,
+ String [] a_repos, File a_destFile, boolean a_useTimestamp )
+ throws RepositoryException
+ {
+ boolean l_updated = false ;
+ Exception l_cause = null ;
+
+ /*
+ * Don't fail fast - keep trying until we get something.
+ */
+ for ( int ii = 0; ii < a_repos.length; ii++ )
+ {
+ try
+ {
+ String l_url = a_artifact.getUrl( a_repos[ii] ) ;
+ l_updated = getTempFile( l_url, a_destFile, a_useTimestamp ) ;
+ return l_updated ;
+ }
+ catch ( Exception e )
+ {
+ l_cause = e ;
+ }
+ }
+
+ if ( null == l_cause )
+ {
+ throw new RepositoryException( "Failed to download artifact to "
+ + "local cache file " + a_destFile.getAbsolutePath() ) ;
+ }
+
+ // Should not really execute but it shuts up the compiler
+ throw new RepositoryException( "Failed to download artifact to "
+ + "local cache file " + a_destFile.getAbsolutePath(), l_cause ) ;
+ }
+
+
+ /**
+ * Retrieve a remote file. Returns true if the file was successfully
+ * retrieved or if it is up to date (when the useTimestamp flag is set).
+ *
+ * Moved here from HttpController.
+ *
+ * @param a_url the of the file to retrieve
+ * @param a_destFile where to store it
+ * @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 getTempFile( String a_url, File a_destFile,
+ boolean a_useTimestamp ) throws Exception
+ {
+ URL l_source = null ;
+ String l_username = null ;
+ String l_password = null ;
+
+ // We want to be able to deal with Basic Auth where the username
+ // and password are part of the URL. An example of the URL string
+ // we would like to be able to parse is like the following:
+ //
+ // http://username:password@repository.mycompany.com
+
+ int l_atIdx = a_url.indexOf( "@" ) ;
+ if ( l_atIdx > 0 )
+ {
+ String s = a_url.substring( 7, l_atIdx ) ;
+ int l_colonIdx = s.indexOf( ":" ) ;
+ l_username = s.substring( 0, l_colonIdx ) ;
+ l_password = s.substring( l_colonIdx + 1 ) ;
+ l_source = new URL( "http://" + a_url.substring( l_atIdx + 1 ) ) ;
+ }
+ else
+ {
+ l_source = new URL( a_url ) ;
+ }
+
+ //set the timestamp to the file date.
+ long l_timestamp = 0 ;
+ boolean l_hasTimestamp = false ;
+ if ( a_useTimestamp && a_destFile.exists() )
+ {
+ l_timestamp = a_destFile.lastModified() ;
+ l_hasTimestamp = true ;
+ }
+
+ //set up the URL connection
+ URLConnection l_connection = l_source.openConnection() ;
+
+ //modify the headers
+ //NB: things like user authentication could go in here too.
+ if ( a_useTimestamp && l_hasTimestamp )
+ {
+ l_connection.setIfModifiedSince( l_timestamp ) ;
+ }
+
+ //connect to the remote site (may take some time)
+ l_connection.connect() ;
+ //next test for a 304 result (HTTP only)
+ if ( l_connection instanceof HttpURLConnection )
+ {
+ HttpURLConnection l_httpConnection =
+ ( HttpURLConnection ) l_connection ;
+
+ if ( l_httpConnection.getResponseCode() ==
+ HttpURLConnection.HTTP_NOT_MODIFIED )
+ {
+ return false ;
+ }
+
+ // test for 401 result (HTTP only)
+ if ( l_httpConnection.getResponseCode() ==
+ HttpURLConnection.HTTP_UNAUTHORIZED )
+ {
+ throw new Exception( "Not authorized." ) ;
+ }
+ }
+
+ // REVISIT: at this point even non HTTP connections may support the
+ // if-modified-since behaviour - we just check the date of the
+ // content and skip the write if it is not newer.
+ // Some protocols (FTP) dont include dates, of course.
+
+ InputStream l_in = null ;
+ for ( int ii = 0; ii < 3; ii++ )
+ {
+ try
+ {
+ l_in = l_connection.getInputStream() ;
+ break ;
+ }
+ catch ( IOException ex )
+ {
+ // do nothing
+ }
+ }
+ if ( l_in == null )
+ {
+ final String error =
+ "Connection returned a null input stream: " + a_url ;
+ throw new IOException( error ) ;
+ }
+
+ File parent = a_destFile.getParentFile() ;
+ parent.mkdirs() ;
+
+ FileOutputStream l_out = new FileOutputStream( a_destFile ) ;
+
+ byte[] buffer = new byte[100 * 1024] ;
+ int length ;
+
+ System.out.print( "Source: " + l_source + "\n") ;
+ while ( ( length = l_in.read( buffer ) ) >= 0 )
+ {
+ l_out.write( buffer, 0, length ) ;
+ System.out.print( "." ) ;
+ }
+
+ System.out.println( "" ) ;
+ l_out.close() ;
+ l_in.close() ;
+
+ // if (and only if) the use file time option is set, then the
+ // saved file now has its timestamp set to that of the downloaded
+ // file
+
+ if ( a_useTimestamp )
+ {
+ long l_remoteTimestamp = l_connection.getLastModified() ;
+
+ if ( l_remoteTimestamp != 0 )
+ {
+ long l_modifiedTime ;
+
+ if ( l_remoteTimestamp < 0 )
+ {
+ l_modifiedTime = System.currentTimeMillis() ;
+ }
+ else
+ {
+ l_modifiedTime = l_remoteTimestamp ;
+ }
+
+ a_destFile.setLastModified( l_modifiedTime ) ;
+ return true ;
+ }
+ }
+
+ return true ;
+ }
+}
1.2 +79 -79 avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/RepositoryFactory.java
Index: RepositoryFactory.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/RepositoryFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RepositoryFactory.java 6 Nov 2003 04:09:15 -0000 1.1
+++ RepositoryFactory.java 6 Nov 2003 05:28:37 -0000 1.2
@@ -1,79 +1,79 @@
-/*
-
- ============================================================================
- 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 ;
-
-
-/**
- * Interface for Repository factories.
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author$
- * @version $Revision$
- */
-public interface RepositoryFactory
-{
- /**
- * Creates a new default configuration bean populated with default values.
- *
- * @return a default configuration bean used for Repository creation
- * @throws RepositoryException if there is a problem generating defaults
- */
- RepositoryConfig getDefaultConfig() throws RepositoryException ;
-
- /**
- * Creates a new Repository using a configuration bean.
- *
- * @param a_config the Repository configuration bean
- * @return the newly created Repository
- * @throws RepositoryException if there is a problem creating the Repository
- */
- Repository create( RepositoryConfig a_config ) throws RepositoryException ;
-}
+/*
+
+ ============================================================================
+ 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 ;
+
+
+/**
+ * Interface for Repository factories.
+ *
+ * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
+ * @author $Author$
+ * @version $Revision$
+ */
+public interface RepositoryFactory
+{
+ /**
+ * Creates a new default configuration bean populated with default values.
+ *
+ * @return a default configuration bean used for Repository creation
+ * @throws RepositoryException if there is a problem generating defaults
+ */
+ RepositoryConfig getDefaultConfig() throws RepositoryException ;
+
+ /**
+ * Creates a new Repository using a configuration bean.
+ *
+ * @param a_config the Repository configuration bean
+ * @return the newly created Repository
+ * @throws RepositoryException if there is a problem creating the Repository
+ */
+ Repository create( RepositoryConfig a_config ) throws RepositoryException ;
+}
1.2 +117 -162 avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/RepositoryConfig.java
Index: RepositoryConfig.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/RepositoryConfig.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RepositoryConfig.java 6 Nov 2003 04:09:15 -0000 1.1
+++ RepositoryConfig.java 6 Nov 2003 05:28:37 -0000 1.2
@@ -1,162 +1,117 @@
-/*
-
- ============================================================================
- 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.net.URL ;
-import java.net.MalformedURLException ;
-
-
-/**
- * Repository configuration parameters bean.
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author$
- * @version $Revision$
- */
-public class RepositoryConfig
-{
- /** the set of remote repositories to pull jars from */
- private URL [] m_remoteRepositories = null ;
-
- /** the path to the local repository that caches remote artifacts */
- private String m_cacheDir = null ;
-
- /** descriptor for proxy used to access remote repositories */
- private ProxyContext m_proxyCtx = null ;
-
-
- /**
- * Gets the ProxyContext used by the Kernel to access remote repositories.
- *
- * @return the proxy context used by the Kernel
- */
- public ProxyContext getProxyContext()
- {
- return m_proxyCtx ;
- }
-
-
- /**
- * Sets the ProxyContext for this KernelConfig.
- *
- * @param a_proxyCtx sets the proxy context
- */
- public void setProxyContext( ProxyContext a_proxyCtx )
- {
- m_proxyCtx = a_proxyCtx ;
- }
-
-
- /**
- * Gets the set of remote repositories used to download artifacts.
- *
- * @return the remote repositories to use
- */
- public URL[] getRemoteRepositories()
- {
- return m_remoteRepositories ;
- }
-
-
- /**
- * Gets the remote repository urls for downloading artifacts.
- *
- * @param a_remoteRepositories the remote Repositories to use.
- */
- public void setRemoteRepositoryUrls( URL[] a_remoteRepositories )
- {
- m_remoteRepositories = a_remoteRepositories ;
- }
-
-
- /**
- * Sets the remote repository urls for downloading artifacts.
- *
- * @param urls the remote Repositories to use.
- */
- public void setRemoteRepositoryUrls( String[] urls )
- throws MalformedURLException
- {
- URL [] a_urls = new URL [urls.length] ;
-
- for ( int ii = 0; ii < a_urls.length; ii++ )
- {
- a_urls[ii] = new URL( urls[ii] ) ;
- }
-
-
- m_remoteRepositories = a_urls ;
- }
-
-
- /**
- * Gets the directory where repository artifacts are stored after being
- * downloaded from the Repository.
- *
- * @return the place to cache repository artifacts
- */
- public String getCacheDir()
- {
- return m_cacheDir ;
- }
-
-
- /**
- * Sets the directory where we store downloaded artifacts.
- *
- * @param a_cacheDir the place to cache repository artifacts
- */
- public void setCacheDir( String a_cacheDir )
- {
- m_cacheDir = a_cacheDir ;
- }
-}
+/*
+
+ ============================================================================
+ 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.net.URL ;
+import java.net.MalformedURLException ;
+
+
+/**
+ * Repository configuration bean interface.
+ *
+ * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
+ * @author $Author$
+ * @version $Revision$
+ */
+public interface RepositoryConfig
+{
+ /**
+ * Gets the ProxyContext used by the Kernel to access remote repositories.
+ *
+ * @return the proxy context used by the Kernel
+ */
+ ProxyContext getProxyContext() ;
+
+ /**
+ * Sets the ProxyContext for this KernelConfig.
+ *
+ * @param a_proxyCtx sets the proxy context
+ */
+ void setProxyContext( ProxyContext a_proxyCtx ) ;
+
+ /**
+ * Gets the set of remote repositories used to download artifacts.
+ *
+ * @return the remote repositories to use
+ */
+ URL[] getRemoteRepositories() ;
+
+ /**
+ * Gets the remote repository urls for downloading artifacts.
+ *
+ * @param a_remoteRepositories the remote Repositories to use.
+ */
+ void setRemoteRepositoryUrls( URL[] a_remoteRepositories ) ;
+
+ /**
+ * Sets the remote repository urls for downloading artifacts.
+ *
+ * @param a_urls the remote Repositories to use.
+ */
+ void setRemoteRepositoryUrls( String[] a_urls )
+ throws MalformedURLException ;
+
+ /**
+ * Gets the directory where repository artifacts are stored after being
+ * downloaded from the Repository.
+ *
+ * @return the place to cache repository artifacts
+ */
+ public abstract String getCacheDir() ;
+
+ /**
+ * Sets the directory where we store downloaded artifacts.
+ *
+ * @param a_cacheDir the place to cache repository artifacts
+ */
+ void setCacheDir( String a_cacheDir ) ;
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org