avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 21392 - avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home
Date Fri, 18 Jun 2004 00:14:03 GMT
Author: mcconnell
Date: Thu Jun 17 17:14:02 2004
New Revision: 21392

Modified:
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home/Home.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home/Repository.java
Log:
add proxy support to the home and repository

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home/Home.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home/Home.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home/Home.java	Thu Jun 17 17:14:02
2004
@@ -102,7 +102,7 @@
             m_system = m_index.getParentFile();
             String path = getCachePath( project );
             String hostsPath = project.getProperty( "avalon.hosts" );
-            m_repository = new Repository( m_system, path, hostsPath, this );
+            m_repository = new Repository( project, m_system, path, hostsPath, this );
 
             Element root = ElementHelper.getRootElement( m_index );
             final Element resources = ElementHelper.getChild( root, "resources" );

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home/Repository.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home/Repository.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/home/Repository.java	Thu Jun
17 17:14:02 2004
@@ -38,6 +38,7 @@
 import org.apache.tools.ant.taskdefs.Sequential;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.FileList;
+import org.apache.tools.ant.taskdefs.optional.net.SetProxy;
 
 import org.apache.avalon.tools.project.Definition;
 import org.apache.avalon.tools.project.ResourceRef;
@@ -51,12 +52,18 @@
  */
 public class Repository 
 {
+    public final String PROJECT_PROXY_HOST_KEY = "project.proxy.host";
+    public final String PROJECT_PROXY_PORT_KEY = "project.proxy.port";
+    public final String PROJECT_PROXY_USERNAME_KEY = "project.proxy.username";
+    public final String PROJECT_PROXY_PASSWORD_KEY = "project.proxy.password";
+
     private final Home m_home;
     private final File m_root;
     private final File m_cache;
     private final String[] m_hosts;
 
-    public Repository( File system, String path, String hosts, Home home )
+    public Repository( 
+      Project project, File system, String path, String hosts, Home home )
     {
         if( null == system ) 
         {
@@ -74,6 +81,8 @@
         m_root = system;
         m_cache = getCanonicalFile( Context.getFile( system, path ) );
         m_hosts = getHostsSequence( hosts );
+
+        setupProxy( project );
     }
 
     public File getCacheDirectory()
@@ -114,4 +123,29 @@
         return (String[]) list.toArray( new String[0] );
     }
 
+    private void setupProxy( Project project )
+    {
+        String host = project.getProperty( PROJECT_PROXY_HOST_KEY );
+        if(( null == host ) || "".equals( host ) )
+        {
+            return;
+        }
+        else
+        {
+            int port = Integer.decode( 
+              project.getProperty( PROJECT_PROXY_PORT_KEY ) ).intValue();
+            String username = 
+              project.getProperty( PROJECT_PROXY_USERNAME_KEY );
+            String password = 
+              project.getProperty( PROJECT_PROXY_PASSWORD_KEY );
+            SetProxy proxy = 
+              (SetProxy) project.createTask( "setproxy" );
+            proxy.init();
+            proxy.setProxyHost( host );
+            proxy.setProxyPort( port );
+            proxy.setProxyUser( username );
+            proxy.setProxyPassword( password );
+            proxy.execute();
+        }
+    }
 }

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


Mime
View raw message