maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r1126856 - in /maven/maven-3/branches/mirror-group-routing: maven-routem-api/src/main/java/org/apache/maven/artifact/router/ maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/ maven-routem-impl/src/main/java/org/apache/m...
Date Tue, 24 May 2011 03:33:46 GMT
Author: jdcasey
Date: Tue May 24 03:33:46 2011
New Revision: 1126856

URL: http://svn.apache.org/viewvc?rev=1126856&view=rev
Log:
started refactoring router loading/discovery to have discovery strategies hand back ArtifactRouter
instances, rather than having a DTO for it. Now, need to consolidate the HTTP access and somehow
align it with the Wagon APIs

Removed:
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/DiscoveryResult.java
Modified:
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/FileRouterConfigBuilder.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/ArtifactRouterDiscoveryStrategy.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/DNSDiscoveryStrategy.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java

Modified: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java?rev=1126856&r1=1126855&r2=1126856&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java
(original)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java
Tue May 24 03:33:46 2011
@@ -47,6 +47,24 @@ public final class ArtifactRouter
         selectedMirrors.clear();
         return this;
     }
+    
+    public synchronized ArtifactRouter merge( ArtifactRouter other )
+    {
+        addMirrors( other.mirrors );
+        addGroups( other.groups.values() );
+        
+        for ( Map.Entry<String, MirrorRoute> entry : other.selectedMirrors.entrySet()
)
+        {
+            String url = entry.getKey();
+            
+            if ( !selectedMirrors.containsKey( url ) )
+            {
+                selectedMirrors.put( url, entry.getValue() );
+            }
+        }
+        
+        return this;
+    }
 
     public synchronized ArtifactRouter addMirrors( final Collection<MirrorRoute> mirrors
)
     {

Modified: maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/FileRouterConfigBuilder.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/FileRouterConfigBuilder.java?rev=1126856&r1=1126855&r2=1126856&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/FileRouterConfigBuilder.java
(original)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/FileRouterConfigBuilder.java
Tue May 24 03:33:46 2011
@@ -22,8 +22,6 @@ package org.apache.maven.artifact.router
 import static org.codehaus.plexus.util.IOUtil.close;
 import static org.codehaus.plexus.util.StringUtils.isNotBlank;
 
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.Logger;
 
 import java.io.File;

Modified: maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/ArtifactRouterDiscoveryStrategy.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/ArtifactRouterDiscoveryStrategy.java?rev=1126856&r1=1126855&r2=1126856&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/ArtifactRouterDiscoveryStrategy.java
(original)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/ArtifactRouterDiscoveryStrategy.java
Tue May 24 03:33:46 2011
@@ -19,12 +19,13 @@ package org.apache.maven.artifact.router
  * under the License.
  */
 
+import org.apache.maven.artifact.router.ArtifactRouter;
 import org.apache.maven.artifact.router.ArtifactRouterException;
 
 public interface ArtifactRouterDiscoveryStrategy
 {
 
-    DiscoveryResult findRouter()
+    ArtifactRouter findRouter()
         throws ArtifactRouterException;
 
 }

Modified: maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/DNSDiscoveryStrategy.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/DNSDiscoveryStrategy.java?rev=1126856&r1=1126855&r2=1126856&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/DNSDiscoveryStrategy.java
(original)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/DNSDiscoveryStrategy.java
Tue May 24 03:33:46 2011
@@ -19,8 +19,13 @@ package org.apache.maven.artifact.router
  * under the License.
  */
 
+import org.apache.maven.artifact.router.ArtifactRouter;
 import org.apache.maven.artifact.router.ArtifactRouterException;
+import org.apache.maven.artifact.router.GroupRoute;
+import org.apache.maven.artifact.router.MirrorRoute;
 import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.Logger;
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
@@ -29,6 +34,7 @@ import javax.naming.directory.InitialDir
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
@@ -37,8 +43,11 @@ import java.util.Map;
 final class DNSDiscoveryStrategy
     implements ArtifactRouterDiscoveryStrategy
 {
+    
+    @Requirement
+    private Logger logger;
 
-    public DiscoveryResult findRouter()
+    public ArtifactRouter findRouter()
         throws ArtifactRouterException
     {
         final Map<String, String> env = new HashMap<String, String>();
@@ -104,9 +113,47 @@ final class DNSDiscoveryStrategy
         return null;
     }
 
-    private DiscoveryResult parse( String record )
+    private ArtifactRouter parse( String record )
     {
-        return null;
+        ArtifactRouter router = new ArtifactRouter();
+        
+        String[] sections = record.split(";");
+        for ( String section : sections )
+        {
+            String[] kv = section.split( "=" );
+            if ( kv.length < 2 )
+            {
+                if ( logger.isDebugEnabled() )
+                {
+                    logger.debug( "Skipping DNS TXT section: '" + section + "': it is not
a value key-value pair." );
+                }
+                
+                continue;
+            }
+            
+            if ( "mirrors".equalsIgnoreCase( kv[0] ) )
+            {
+                router.addMirrors( loadMirrorsFrom( kv[1] ) );
+            }
+            else if ( "groups".equalsIgnoreCase( kv[0] ) )
+            {
+                router.addGroups( loadGroupsFrom( kv[1] ) );
+            }
+        }
+        
+        return router;
+    }
+
+    private Collection<GroupRoute> loadGroupsFrom( String string )
+    {
+        // TODO Implement DNSDiscoveryStrategy.loadGroupsFrom
+        throw new UnsupportedOperationException( "Not Implemented." );
     }
 
+    private Collection<MirrorRoute> loadMirrorsFrom( String string )
+    {
+        // TODO Implement DNSDiscoveryStrategy.loadMirrorsFrom
+        throw new UnsupportedOperationException( "Not Implemented." );
+    }
+    
 }

Modified: maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java?rev=1126856&r1=1126855&r2=1126856&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java
(original)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java
Tue May 24 03:33:46 2011
@@ -40,7 +40,6 @@ import org.apache.maven.artifact.router.
 import org.apache.maven.artifact.router.MirrorRoute;
 import org.apache.maven.artifact.router.conf.ArtifactRouterConfiguration;
 import org.apache.maven.artifact.router.discovery.ArtifactRouterDiscoveryStrategy;
-import org.apache.maven.artifact.router.discovery.DiscoveryResult;
 import org.apache.maven.artifact.router.io.ArtifactRouteSerializer;
 import org.apache.maven.artifact.router.io.ArtifactRouterModelException;
 import org.codehaus.plexus.component.annotations.Component;
@@ -236,21 +235,12 @@ public class DefaultRouterLoader
                         }
                     }
 
-                    DiscoveryResult discoveryResult = null;
                     for ( final ArtifactRouterDiscoveryStrategy strategy : strats )
                     {
-                        discoveryResult = strategy.findRouter();
-                        if ( discoveryResult != null )
+                        ArtifactRouter result = strategy.findRouter();
+                        if ( result != null )
                         {
-                            if ( discoveryResult.getMirrorsUrl() != null )
-                            {
-                                routes.addMirrors( getMirrorMapping( discoveryResult.getMirrorsUrl(),
config, client ) );
-                            }
-                            
-                            if ( discoveryResult.getGroupsUrl() != null )
-                            {
-                                routes.addGroups( getGroupMapping( discoveryResult.getGroupsUrl(),
config, client ) );
-                            }
+                            routes.merge( result );
                         }
                     }
                 }



Mime
View raw message