You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2011/05/24 05:31:42 UTC

svn commit: r1126851 [1/2] - in /maven/maven-3/branches/mirror-group-routing: ./ maven-compat/src/main/java/org/apache/maven/repository/ maven-core/ maven-core/src/main/java/org/apache/maven/ maven-core/src/main/java/org/apache/maven/execution/ maven-c...

Author: jdcasey
Date: Tue May 24 03:31:40 2011
New Revision: 1126851

URL: http://svn.apache.org/viewvc?rev=1126851&view=rev
Log:
Refactoring route-M implementation to separate module, then starting to add in notion of groupId-to-canonical-URL mapping to allow fragmentation of repos along groupId lines.

Added:
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouteSerializer.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouterModelException.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRoutingTables.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupPattern.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupRoute.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/MirrorRoute.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupPatternTest.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupRouteTest.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRouteTest.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRoutingTableTest.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/RouterMirrorSerializerTest.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/pom.xml   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/ArtifactRouterException.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/ArtifactRouterConfiguration.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/ArtifactRouterConfigurationException.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/DefaultRouterConfigBuilder.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/FileRouterConfigSource.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/RouterConfigBuilder.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/conf/RouterConfigSource.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/ArtifactRouterDiscoveryStrategy.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/discovery/DNSDiscoveryStrategy.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/ArtifactRouterLoader.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java   (with props)
Removed:
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/MirrorRouter.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/MirrorRouterException.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/DefaultMirrorRouterConfigBuilder.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/FileMirrorRouterConfigSource.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/MirrorRouterConfigBuilder.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/MirrorRouterConfigSource.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/MirrorRouterConfiguration.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/MirrorRouterConfigurationException.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/discovery/DNSDiscoveryStrategy.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/discovery/RouterDiscoveryStrategy.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/loader/DefaultMirrorRouterLoader.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/loader/MirrorRouterLoader.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/repository/automirror/MirrorRoute.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/repository/automirror/MirrorRouteSerializer.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/repository/automirror/MirrorRouterModelException.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/repository/automirror/MirrorRoutingTable.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/repository/automirror/MirrorRouteTest.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/repository/automirror/MirrorRoutingTableTest.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/repository/automirror/RouterMirrorSerializerTest.java
Modified:
    maven/maven-3/branches/mirror-group-routing/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java
    maven/maven-3/branches/mirror-group-routing/maven-core/pom.xml
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/RoutingMirrorSelector.java
    maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
    maven/maven-3/branches/mirror-group-routing/maven-routem-api/pom.xml
    maven/maven-3/branches/mirror-group-routing/pom.xml
    maven/maven-3/branches/mirror-group-routing/pom.xml.orig

Modified: maven/maven-3/branches/mirror-group-routing/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java Tue May 24 03:31:40 2011
@@ -25,9 +25,9 @@ import java.util.List;
 
 import org.apache.maven.RepositoryUtils;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.router.ArtifactRouter;
+import org.apache.maven.artifact.router.MirrorRoute;
 import org.apache.maven.plugin.LegacySupport;
-import org.apache.maven.repository.automirror.MirrorRoute;
-import org.apache.maven.repository.mirror.MirrorRouter;
 import org.apache.maven.settings.Mirror;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
@@ -75,7 +75,7 @@ public class DefaultMirrorSelector
         {
             final String repoUrl = repository.getUrl();
 
-            MirrorRouter routingTable = legacySupport.getSession().getMirrorRouter();
+            ArtifactRouter routingTable = legacySupport.getSession().getMirrorRouter();
             final MirrorRoute rMirror = routingTable.getMirror( repoUrl );
 
             if ( rMirror != null )

Modified: maven/maven-3/branches/mirror-group-routing/maven-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-core/pom.xml?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-core/pom.xml (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-core/pom.xml Tue May 24 03:31:40 2011
@@ -110,6 +110,10 @@
     	<groupId>org.apache.httpcomponents</groupId>
     	<artifactId>httpclient</artifactId>
     </dependency>
+    <dependency>
+    	<groupId>org.apache.maven</groupId>
+    	<artifactId>maven-routem-impl</artifactId>
+    </dependency>
   </dependencies>
 
   <build>

Modified: maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Tue May 24 03:31:40 2011
@@ -377,7 +377,7 @@ public class DefaultMaven
         }
 
         final RoutingMirrorSelector mirrorSelector =
-            new RoutingMirrorSelector( request.getMirrorRouter(), logger );
+            new RoutingMirrorSelector( request.getArtifactRouter(), logger );
         
         for ( Mirror mirror : request.getMirrors() )
         {

Modified: maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java Tue May 24 03:31:40 2011
@@ -26,11 +26,10 @@ import java.util.List;
 import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.router.ArtifactRouter;
 import org.apache.maven.model.Profile;
 import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.repository.mirror.MirrorRouter;
-import org.apache.maven.repository.mirror.configuration.MirrorRouterConfiguration;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Server;
@@ -187,7 +186,7 @@ public class DefaultMavenExecutionReques
         copy.setWorkspaceReader( original.getWorkspaceReader() );
         copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
         copy.setExecutionListener( original.getExecutionListener() );
-        copy.setMirrorRouter( original.getMirrorRouter() );
+        copy.setArtifactRouter( original.getArtifactRouter() );
         
         return copy;
     }
@@ -1080,21 +1079,21 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    private MirrorRouter mirrorRouter;
+    private ArtifactRouter artifactRouter;
 
-    public synchronized MirrorRouter getMirrorRouter()
+    public synchronized ArtifactRouter getArtifactRouter()
     {
-        if ( mirrorRouter == null )
+        if ( artifactRouter == null )
         {
-            mirrorRouter = new MirrorRouter();
+            artifactRouter = new ArtifactRouter();
         }
 
-        return mirrorRouter;
+        return artifactRouter;
     }
 
-    public MavenExecutionRequest setMirrorRouter( final MirrorRouter mirrorRouter )
+    public MavenExecutionRequest setArtifactRouter( final ArtifactRouter mirrorRouter )
     {
-        this.mirrorRouter = mirrorRouter;
+        this.artifactRouter = mirrorRouter;
         return this;
     }
 

Modified: maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java Tue May 24 03:31:40 2011
@@ -26,10 +26,9 @@ import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.router.ArtifactRouter;
 import org.apache.maven.model.Profile;
 import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.repository.mirror.MirrorRouter;
-import org.apache.maven.repository.mirror.configuration.MirrorRouterConfiguration;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Server;
@@ -285,8 +284,8 @@ public interface MavenExecutionRequest
 
     ProjectBuildingRequest getProjectBuildingRequest();
 
-    MirrorRouter getMirrorRouter();
+    ArtifactRouter getArtifactRouter();
 
-    MavenExecutionRequest setMirrorRouter( MirrorRouter router );
+    MavenExecutionRequest setArtifactRouter( ArtifactRouter router );
 
 }

Modified: maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java Tue May 24 03:31:40 2011
@@ -29,11 +29,11 @@ import java.util.concurrent.ConcurrentHa
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.RepositoryCache;
+import org.apache.maven.artifact.router.ArtifactRouter;
 import org.apache.maven.monitor.event.EventDispatcher;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.repository.mirror.MirrorRouter;
 import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -394,9 +394,9 @@ public class MavenSession
         return repositorySession;
     }
 
-    public MirrorRouter getMirrorRouter()
+    public ArtifactRouter getMirrorRouter()
     {
-        return request.getMirrorRouter();
+        return request.getArtifactRouter();
     }
     
 }

Modified: maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/RoutingMirrorSelector.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/RoutingMirrorSelector.java?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/RoutingMirrorSelector.java (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/RoutingMirrorSelector.java Tue May 24 03:31:40 2011
@@ -19,7 +19,8 @@ package org.apache.maven.repository.mirr
  * under the License.
  */
 
-import org.apache.maven.repository.automirror.MirrorRoute;
+import org.apache.maven.artifact.router.MirrorRoute;
+import org.apache.maven.artifact.router.ArtifactRouter;
 import org.codehaus.plexus.logging.Logger;
 import org.sonatype.aether.repository.MirrorSelector;
 import org.sonatype.aether.repository.RemoteRepository;
@@ -31,13 +32,13 @@ public class RoutingMirrorSelector
     implements MirrorSelector
 {
 
-    private final MirrorRouter mirrorRouter;
+    private final ArtifactRouter mirrorRouter;
 
     private final DefaultMirrorSelector delegate = new DefaultMirrorSelector();
 
     private final Logger logger;
     
-    public RoutingMirrorSelector( final MirrorRouter mirrorRouter, final Logger logger )
+    public RoutingMirrorSelector( final ArtifactRouter mirrorRouter, final Logger logger )
     {
         this.mirrorRouter = mirrorRouter;
         this.logger = logger;

Modified: maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java Tue May 24 03:31:40 2011
@@ -36,6 +36,12 @@ import org.apache.commons.cli.Unrecogniz
 import org.apache.maven.BuildAbort;
 import org.apache.maven.InternalErrorException;
 import org.apache.maven.Maven;
+import org.apache.maven.artifact.router.ArtifactRouter;
+import org.apache.maven.artifact.router.ArtifactRouterException;
+import org.apache.maven.artifact.router.conf.FileRouterConfigSource;
+import org.apache.maven.artifact.router.conf.RouterConfigBuilder;
+import org.apache.maven.artifact.router.conf.ArtifactRouterConfiguration;
+import org.apache.maven.artifact.router.loader.ArtifactRouterLoader;
 import org.apache.maven.eventspy.internal.EventSpyDispatcher;
 import org.apache.maven.exception.DefaultExceptionHandler;
 import org.apache.maven.exception.ExceptionHandler;
@@ -50,12 +56,6 @@ import org.apache.maven.lifecycle.intern
 import org.apache.maven.model.building.ModelProcessor;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.properties.internal.EnvironmentUtils;
-import org.apache.maven.repository.mirror.MirrorRouter;
-import org.apache.maven.repository.mirror.MirrorRouterException;
-import org.apache.maven.repository.mirror.configuration.FileMirrorRouterConfigSource;
-import org.apache.maven.repository.mirror.configuration.MirrorRouterConfigBuilder;
-import org.apache.maven.repository.mirror.configuration.MirrorRouterConfiguration;
-import org.apache.maven.repository.mirror.loader.MirrorRouterLoader;
 import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
 import org.apache.maven.settings.building.SettingsBuilder;
 import org.apache.maven.settings.building.SettingsBuildingRequest;
@@ -122,13 +122,13 @@ public class MavenCli
 
     private SettingsBuilder settingsBuilder;
 
-    private MirrorRouterConfigBuilder routerConfBuilder;
+    private RouterConfigBuilder routerConfBuilder;
     
-    private MirrorRouterLoader routerLoader;
+    private ArtifactRouterLoader routerLoader;
 
     private DefaultSecDispatcher dispatcher;
 
-    private MirrorRouterConfiguration routerConfig;
+    private ArtifactRouterConfiguration routerConfig;
 
     public MavenCli()
     {
@@ -427,8 +427,8 @@ public class MavenCli
 
         settingsBuilder = container.lookup( SettingsBuilder.class );
 
-        routerConfBuilder = container.lookup( MirrorRouterConfigBuilder.class );
-        routerLoader = container.lookup( MirrorRouterLoader.class );
+        routerConfBuilder = container.lookup( RouterConfigBuilder.class );
+        routerLoader = container.lookup( ArtifactRouterLoader.class );
         
         dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven" );
     }
@@ -555,9 +555,9 @@ public class MavenCli
 
         try
         {
-            routerLoader.saveSelectedMirrors( cliRequest.request.getMirrorRouter(), routerConfig );
+            routerLoader.saveSelectedMirrors( cliRequest.request.getArtifactRouter(), routerConfig );
         }
-        catch ( MirrorRouterException e )
+        catch ( ArtifactRouterException e )
         {
             result.addException( e );
         }
@@ -941,9 +941,9 @@ public class MavenCli
         }
 
         routerConfig =
-            routerConfBuilder.build( new FileMirrorRouterConfigSource( DEFAULT_USER_EXT_CONF_DIR ) );
+            routerConfBuilder.build( new FileRouterConfigSource( DEFAULT_USER_EXT_CONF_DIR ) );
         
-        MirrorRouter mirrorRouter = routerLoader.load( routerConfig );
+        ArtifactRouter router = routerLoader.load( routerConfig );
         
         request.setBaseDirectory( baseDirectory ).setGoals( goals )
             .setSystemProperties( cliRequest.systemProperties )
@@ -959,7 +959,7 @@ public class MavenCli
             .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
             .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
             .setUserToolchainsFile( userToolchainsFile )
-            .setMirrorRouter( mirrorRouter );
+            .setArtifactRouter( router );
 
         if ( alternatePomFile != null )
         {

Modified: maven/maven-3/branches/mirror-group-routing/maven-routem-api/pom.xml
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-api/pom.xml?rev=1126851&r1=1126850&r2=1126851&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/pom.xml (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/pom.xml Tue May 24 03:31:40 2011
@@ -16,22 +16,22 @@
   <parent>
     <artifactId>maven</artifactId>
     <groupId>org.apache.maven</groupId>
-    <version>3.0.3-SNAPSHOT</version>
+    <version>3.0.4-SNAPSHOT</version>
   </parent>
   
   <artifactId>maven-routem-api</artifactId>
   
   <name>Maven Route-M API</name>
-  <description>Maven Route-M auto-mirroring data API</description>
+  <description>Maven Route-M artifact-routing API</description>
   
   <dependencies>
-  	<dependency>
-  		<groupId>com.google.code.gson</groupId>
-  		<artifactId>gson</artifactId>
-  	</dependency>
-  	<dependency>
-  		<groupId>org.codehaus.plexus</groupId>
-  		<artifactId>plexus-utils</artifactId>
-  	</dependency>
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+    </dependency>
   </dependencies>
 </project>

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouteSerializer.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/ArtifactRouteSerializer.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouteSerializer.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouteSerializer.java Tue May 24 03:31:40 2011
@@ -0,0 +1,197 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.InstanceCreator;
+import com.google.gson.JsonParseException;
+import com.google.gson.reflect.TypeToken;
+
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+public class ArtifactRouteSerializer
+{
+
+    // NOTE: Gson is supposed to be threadsafe, so all this static stuff should be fine.
+    private static Gson gson;
+
+    public static void serializeLoose( final Set<MirrorRoute> mirrors, final Writer writer )
+        throws ArtifactRouterModelException
+    {
+        try
+        {
+            getGson().toJson( mirrors, writer );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new ArtifactRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static String serializeLooseToString( final Set<MirrorRoute> mirrors )
+        throws ArtifactRouterModelException
+    {
+        try
+        {
+            return getGson().toJson( mirrors );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new ArtifactRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static Set<MirrorRoute> deserializeLoose( final Reader reader )
+        throws ArtifactRouterModelException
+    {
+        try
+        {
+            return getGson().fromJson( reader, RepositoryMirrorSetCreator.getType() );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new ArtifactRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static Set<MirrorRoute> deserializeLoose( final String source )
+        throws ArtifactRouterModelException
+    {
+        try
+        {
+            return getGson().fromJson( source, RepositoryMirrorSetCreator.getType() );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new ArtifactRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static void serialize( final ArtifactRoutingTables mirrors, final Writer writer )
+        throws ArtifactRouterModelException
+    {
+        try
+        {
+            getGson().toJson( mirrors, writer );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new ArtifactRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static String serializeToString( final ArtifactRoutingTables mirrors )
+        throws ArtifactRouterModelException
+    {
+        try
+        {
+            return getGson().toJson( mirrors );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new ArtifactRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static ArtifactRoutingTables deserialize( final Reader reader )
+        throws ArtifactRouterModelException
+    {
+        try
+        {
+            return getGson().fromJson( reader, ArtifactRoutingTables.class );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new ArtifactRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static ArtifactRoutingTables deserialize( final String source )
+        throws ArtifactRouterModelException
+    {
+        try
+        {
+            return getGson().fromJson( source, ArtifactRoutingTables.class );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new ArtifactRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    private static Gson getGson()
+    {
+        if ( gson == null )
+        {
+            final GsonBuilder builder = new GsonBuilder();
+            builder.disableHtmlEscaping().disableInnerClassSerialization().setPrettyPrinting();
+            builder.registerTypeAdapter( RepositoryMirrorSetCreator.getType(), new RepositoryMirrorSetCreator() );
+            builder.registerTypeAdapter( RepositoryMirrorListCreator.getType(), new RepositoryMirrorListCreator() );
+
+            gson = builder.create();
+        }
+
+        return gson;
+    }
+
+    public static final class RepositoryMirrorListCreator
+        implements InstanceCreator<List<MirrorRoute>>
+    {
+
+        public List<MirrorRoute> createInstance( final Type type )
+        {
+            return new ArrayList<MirrorRoute>();
+        }
+
+        public static Type getType()
+        {
+            return new TypeToken<List<MirrorRoute>>()
+            {
+            }.getType();
+        }
+
+    }
+
+    public static final class RepositoryMirrorSetCreator
+        implements InstanceCreator<Set<MirrorRoute>>
+    {
+
+        public Set<MirrorRoute> createInstance( final Type type )
+        {
+            return new LinkedHashSet<MirrorRoute>();
+        }
+
+        public static Type getType()
+        {
+            return new TypeToken<Set<MirrorRoute>>()
+            {
+            }.getType();
+        }
+
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouteSerializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouterModelException.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/ArtifactRouterModelException.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouterModelException.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouterModelException.java Tue May 24 03:31:40 2011
@@ -0,0 +1,38 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public class ArtifactRouterModelException
+    extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+    public ArtifactRouterModelException( final String message, final Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public ArtifactRouterModelException( final String message )
+    {
+        super( message );
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRouterModelException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRoutingTables.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/ArtifactRoutingTables.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRoutingTables.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRoutingTables.java Tue May 24 03:31:40 2011
@@ -0,0 +1,261 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+public final class ArtifactRoutingTables
+{
+
+    private List<MirrorRoute> mirrors = new ArrayList<MirrorRoute>();
+    
+    private Map<GroupPattern, GroupRoute> groups = new HashMap<GroupPattern, GroupRoute>();
+
+    private final transient Random random = new Random();
+
+    private transient Map<String, int[]> mirrorIndexGrabBags = new HashMap<String, int[]>();
+    
+    public ArtifactRoutingTables()
+    {
+        addGroup( GroupRoute.CENTRAL );
+    }
+    
+    public synchronized ArtifactRoutingTables addMirror( final MirrorRoute mirror )
+    {
+        if ( !mirrors.contains( mirror ) )
+        {
+            mirrors.add( mirror );
+            for ( String url : mirror.getMirrorOfUrls() )
+            {
+                mirrorIndexGrabBags.remove( url );
+            }
+        }
+
+        return this;
+    }
+
+    public synchronized MirrorRoute getMirror( final String canonicalUrl )
+    {
+        return getWeightedRandomMirror( canonicalUrl );
+    }
+    
+    public synchronized ArtifactRoutingTables addGroup( final GroupRoute group )
+    {
+        GroupRoute toInsert = group;
+        
+        List<GroupRoute> routes = new ArrayList<GroupRoute>( groups.values() );
+        int idx = routes.indexOf( group );
+        if ( idx > -1 )
+        {
+            GroupRoute existing = routes.get( idx );
+            for ( GroupPattern p : existing.getGroupPatterns() )
+            {
+                groups.remove( p );
+            }
+            
+            existing.merge( group.getGroupPatterns() );
+            toInsert = existing;
+        }
+        
+        for ( GroupPattern p : toInsert.getGroupPatterns() )
+        {
+            groups.put( p, toInsert );
+        }
+        
+        return this;
+    }
+    
+    public GroupRoute getGroup( String groupId )
+    {
+        List<GroupPattern> matches = new ArrayList<GroupPattern>();
+        for ( GroupPattern p : this.groups.keySet() )
+        {
+            if ( p.implies( groupId ) )
+            {
+                matches.add( p );
+            }
+        }
+        
+        Collections.sort( matches );
+        GroupPattern pattern = matches.get( 0 );
+        
+        return groups.get( pattern );
+    }
+    
+//    private MirrorRoute getHighestPriorityMirror( final String canonicalUrl )
+//    {
+//        if ( mirrors.isEmpty() )
+//        {
+//            return null;
+//        }
+//
+//        final List<MirrorRoute> available = new ArrayList<MirrorRoute>( mirrors );
+//
+//        // sort by weight.
+//        Collections.sort( available );
+//
+//        for ( final MirrorRoute mirror : available )
+//        {
+//            // return the highest-priority ENABLED mirror.
+//            if ( mirror.isEnabled() && canonicalUrl.equals( mirror.getUrl() ) )
+//            {
+//                return mirror;
+//            }
+//        }
+//
+//        return null;
+//    }
+
+    private MirrorRoute getWeightedRandomMirror( final String canonicalUrl )
+    {
+        if ( mirrors.isEmpty() )
+        {
+            return null;
+        }
+
+        int[] indexGrabBag = null;
+        synchronized ( canonicalUrl )
+        {
+            indexGrabBag = mirrorIndexGrabBags.get( canonicalUrl );
+            if ( indexGrabBag == null )
+            {
+                final List<Integer> gb = new ArrayList<Integer>();
+                for ( int idx = 0; idx < mirrors.size(); idx++ )
+                {
+                    final MirrorRoute mirror = mirrors.get( idx );
+                    if ( !mirror.isEnabled() || !mirror.isMirrorOf( canonicalUrl ) )
+                    {
+                        // only select from enabled mirrors that actually mirror the given canonical repository URL.
+                        continue;
+                    }
+
+                    if ( mirror.getWeight() < 1 )
+                    {
+                        // make sure this mirror has at least one chance of being picked.
+                        gb.add( idx );
+                    }
+                    else
+                    {
+                        // if weight == 9, give this mirror 9 chances of being picked randomly.
+                        for ( int i = 0; i < mirror.getWeight(); i++ )
+                        {
+                            gb.add( idx );
+                        }
+                    }
+                }
+
+                indexGrabBag = new int[gb.size()];
+                for ( int i = 0; i < indexGrabBag.length; i++ )
+                {
+                    indexGrabBag[i] = gb.get( i );
+                }
+
+                mirrorIndexGrabBags.put( canonicalUrl, indexGrabBag );
+            }
+        }
+
+        if ( indexGrabBag.length == 0 )
+        {
+            return null;
+        }
+        
+        // generate a random number that will correspond to an index stored in the index grab bag.
+        int idx = Math.abs( random.nextInt() ) % indexGrabBag.length;
+
+        // use that random number to select the index of the mirror in the mirrors list.
+        idx = indexGrabBag[idx];
+
+        // lookup the mirror instance associated with the index from the grab bag.
+        return mirrors.get( idx );
+    }
+
+    public boolean contains( final MirrorRoute o )
+    {
+        return mirrors.contains( o );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( mirrors == null ) ? 0 : mirrors.hashCode() );
+        return result;
+    }
+
+    @Override
+    public boolean equals( final Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null )
+        {
+            return false;
+        }
+        if ( getClass() != obj.getClass() )
+        {
+            return false;
+        }
+        final ArtifactRoutingTables other = (ArtifactRoutingTables) obj;
+        if ( mirrors == null )
+        {
+            if ( other.mirrors != null )
+            {
+                return false;
+            }
+        }
+        else if ( !mirrors.equals( other.mirrors ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+    public List<MirrorRoute> getMirrors()
+    {
+        return mirrors;
+    }
+
+    void setMirrors( final List<MirrorRoute> mirrors )
+    {
+        this.mirrors = mirrors;
+    }
+
+    public boolean containsMirrorOf( final String canonicalUrl )
+    {
+        for ( final MirrorRoute mirror : mirrors )
+        {
+            if ( mirror.isEnabled() && mirror.isMirrorOf( canonicalUrl ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/ArtifactRoutingTables.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupPattern.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/GroupPattern.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupPattern.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupPattern.java Tue May 24 03:31:40 2011
@@ -0,0 +1,197 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public final class GroupPattern
+    implements Comparable<GroupPattern>
+{
+    
+    private static final String GROUP_SEPARATOR = "[\\/.]";
+
+    public static final GroupPattern GLOBAL_WILDCARD = new GroupPattern( "*" );
+    
+    private final String pattern;
+    
+    private transient final String[] parts;
+    
+    private transient final boolean wildcard;
+
+    private transient final String basePattern;
+    
+    public GroupPattern( String pattern )
+    {
+        this.pattern = pattern;
+        
+        if ( pattern.endsWith("*") )
+        {
+            wildcard = true;
+            pattern = pattern.substring( 0, pattern.length() - 1 );
+            if ( pattern.endsWith(".") )
+            {
+                pattern = pattern.substring( 0, pattern.length() - 1 );
+            }
+        }
+        else
+        {
+            wildcard = false;
+        }
+        
+        this.basePattern = pattern;
+        parts = pattern.split( GROUP_SEPARATOR );
+        
+        if ( parts.length < 1 || parts[0] == "" )
+        {
+            throw new IllegalArgumentException( "Invalid groupId pattern: '" + this.pattern + "'." );
+        }
+    }
+    
+    public boolean implies( GroupPattern pattern )
+    {
+        return implies( pattern.parts ) && ( wildcard || !pattern.wildcard );
+    }
+    
+    public boolean implies( String pattern )
+    {
+        return implies( pattern.split( GROUP_SEPARATOR ) );
+    }
+    
+    private boolean implies( String[] patternParts )
+    {
+        if ( parts.length > patternParts.length )
+        {
+            return false;
+        }
+        
+        for ( int i = 0; i < parts.length; i++ )
+        {
+            if ( !parts[i].equals( patternParts[i]) )
+            {
+                return false;
+            }
+        }
+        
+        if ( wildcard || parts.length == patternParts.length )
+        {
+            return true;
+        }
+        
+        return false;
+    }
+    
+    public boolean moreGeneralThan( final GroupPattern other )
+    {
+        if ( this.implies( other ) && !other.implies( this ) )
+        {
+            return true;
+        }
+        
+        return false;
+    }
+
+    public boolean lessGeneralThan( final GroupPattern other )
+    {
+        if ( other.implies( this ) && !this.implies( other ) )
+        {
+            return true;
+        }
+        
+        return false;
+    }
+
+    public int compareTo( GroupPattern other )
+    {
+        if ( other.basePattern.equals( basePattern ) )
+        {
+            if ( wildcard == other.wildcard )
+            {
+                return 0;
+            }
+            else if ( wildcard )
+            {
+                return 1;
+            }
+            
+            return -1;
+        }
+        else if ( basePattern.startsWith( other.basePattern ) )
+        {
+            return -1;
+        }
+        else if ( other.basePattern.startsWith( basePattern ) )
+        {
+            return 1;
+        }
+        
+        return basePattern.compareTo( other.basePattern );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( basePattern == null ) ? 0 : basePattern.hashCode() );
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        GroupPattern other = (GroupPattern) obj;
+        if ( basePattern == null )
+        {
+            if ( other.basePattern != null )
+                return false;
+        }
+        else if ( !basePattern.equals( other.basePattern ) )
+            return false;
+        return true;
+    }
+    
+    public String getBasePattern()
+    {
+        return basePattern;
+    }
+    
+    public boolean isWildcard()
+    {
+        return wildcard;
+    }
+
+    public String getPattern()
+    {
+        return pattern;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder builder = new StringBuilder();
+        builder.append( "GroupPattern [" ).append( pattern ).append( "]" );
+        return builder.toString();
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupPattern.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupRoute.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/GroupRoute.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupRoute.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupRoute.java Tue May 24 03:31:40 2011
@@ -0,0 +1,148 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public final class GroupRoute
+{
+    
+    public static final GroupRoute CENTRAL = new GroupRoute( "http://repo1.maven.org/maven2", GroupPattern.GLOBAL_WILDCARD );
+
+    private final String canonicalUrl;
+    
+    private final List<GroupPattern> groupPatterns = new ArrayList<GroupPattern>();
+    
+    public GroupRoute( String canonicalUrl, Collection<GroupPattern> groupPatterns )
+    {
+        this.canonicalUrl = canonicalUrl;
+        merge( groupPatterns );
+    }
+    
+    public GroupRoute( String canonicalUrl, GroupPattern...groupPatterns )
+    {
+        this.canonicalUrl = canonicalUrl;
+        merge( groupPatterns );
+    }
+    
+    public boolean merge( GroupPattern...groupPatterns )
+    {
+        return merge( Arrays.asList( groupPatterns ) );
+    }
+    
+    public synchronized boolean merge( Collection<GroupPattern> groupPatterns )
+    {
+        boolean changed = false;
+        
+        if ( groupPatterns != null && !groupPatterns.isEmpty() )
+        {
+            List<GroupPattern> all = new ArrayList<GroupPattern>( this.groupPatterns );
+            all.addAll( groupPatterns );
+            Collections.sort( all );
+            Collections.reverse( all );
+            
+            this.groupPatterns.clear();
+            
+            GroupPattern last = all.remove( 0 );
+            for ( GroupPattern p : all )
+            {
+                if ( !last.implies( p ) )
+                {
+                    this.groupPatterns.add( last );
+                    last = p;
+                }
+            }
+            
+            this.groupPatterns.add( last );
+        }
+        
+        return changed;
+    }
+    
+    public boolean contains( GroupPattern pattern )
+    {
+        for ( GroupPattern p : groupPatterns )
+        {
+            if ( p.implies( pattern ) )
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    public boolean contains( String pattern )
+    {
+        for ( GroupPattern p : groupPatterns )
+        {
+            if ( p.implies( pattern ) )
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    public String getCanonicalUrl()
+    {
+        return canonicalUrl;
+    }
+    
+    public Collection<GroupPattern> getGroupPatterns()
+    {
+        return groupPatterns;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( canonicalUrl == null ) ? 0 : canonicalUrl.hashCode() );
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        GroupRoute other = (GroupRoute) obj;
+        if ( canonicalUrl == null )
+        {
+            if ( other.canonicalUrl != null )
+                return false;
+        }
+        else if ( !canonicalUrl.equals( other.canonicalUrl ) )
+            return false;
+        return true;
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/GroupRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/MirrorRoute.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/MirrorRoute.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/MirrorRoute.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/MirrorRoute.java Tue May 24 03:31:40 2011
@@ -0,0 +1,188 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.codehaus.plexus.util.StringUtils.join;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+public final class MirrorRoute
+    implements Comparable<MirrorRoute>
+{
+
+    private final String id;
+
+    private final String routeUrl;
+
+    private final int weight;
+
+    private final boolean enabled;
+
+    private final Set<String> mirrorOfUrls;
+
+    // NOTE: ONLY used during deserialization!
+    MirrorRoute()
+    {
+        id = null;
+        mirrorOfUrls = Collections.emptySet();
+        routeUrl = null;
+        weight = 0;
+        enabled = false;
+    }
+
+    public MirrorRoute( final String id, final String routeUrl, final int weight,
+                        final boolean enabled, final String... mirrorOfUrls )
+    {
+        if ( mirrorOfUrls.length < 1 )
+        {
+            throw new IllegalArgumentException( "Cannot construct a mirror route without at least one mirror-of URL." );
+        }
+        
+        this.id = id;
+        this.mirrorOfUrls = normalizeMirrorOfUrls( Arrays.asList( mirrorOfUrls ) );
+        this.routeUrl = routeUrl;
+        this.weight = weight;
+        this.enabled = enabled;
+    }
+
+    public MirrorRoute( final String id, final String routeUrl, final int weight,
+                        final boolean enabled, final Collection<String> mirrorOfUrls )
+    {
+        if ( mirrorOfUrls.size() < 1 )
+        {
+            throw new IllegalArgumentException( "Cannot construct a mirror route without at least one mirror-of URL." );
+        }
+        
+        this.id = id;
+        this.mirrorOfUrls = normalizeMirrorOfUrls( mirrorOfUrls );
+        this.routeUrl = routeUrl;
+        this.weight = weight;
+        this.enabled = enabled;
+    }
+
+    private Set<String> normalizeMirrorOfUrls( Collection<String> src )
+    {
+        Set<String> result = new HashSet<String>( src.size() );
+        for ( String srcItem : src )
+        {
+            String item = srcItem.toLowerCase();
+            if ( item.endsWith( "/" ) )
+            {
+                item = item.substring( 0, item.length() - 1 );
+            }
+            
+            result.add( item );
+        }
+        
+        return result;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public String getRouteUrl()
+    {
+        return routeUrl;
+    }
+
+    public int getWeight()
+    {
+        return weight;
+    }
+
+    public boolean isEnabled()
+    {
+        return enabled;
+    }
+
+    public int compareTo( final MirrorRoute o )
+    {
+        return o.weight - weight;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "mirror [id: " + id + ", weight: " + weight + ", mirror-of urls: " + join( mirrorOfUrls.iterator(), ", " ) + ", route-url: " + routeUrl
+                        + ", enabled: " + enabled + "]";
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( routeUrl == null ) ? 0 : routeUrl.hashCode() );
+        return result;
+    }
+
+    @Override
+    public boolean equals( final Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null )
+        {
+            return false;
+        }
+        if ( getClass() != obj.getClass() )
+        {
+            return false;
+        }
+        final MirrorRoute other = (MirrorRoute) obj;
+        if ( routeUrl == null )
+        {
+            if ( other.routeUrl != null )
+            {
+                return false;
+            }
+        }
+        else if ( !routeUrl.equals( other.routeUrl ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+    public Set<String> getMirrorOfUrls()
+    {
+        return mirrorOfUrls;
+    }
+
+    public boolean isMirrorOf( final String canonicalUrl )
+    {
+        String check = canonicalUrl.toLowerCase();
+        if ( check.endsWith( "/" ) )
+        {
+            check = check.substring( 0, check.length() - 1 );
+        }
+        
+        return mirrorOfUrls.contains( check );
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/main/java/org/apache/maven/artifact/router/MirrorRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupPatternTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupPatternTest.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupPatternTest.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupPatternTest.java Tue May 24 03:31:40 2011
@@ -0,0 +1,217 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static junit.framework.Assert.*;
+
+import org.apache.maven.artifact.router.GroupPattern;
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+public class GroupPatternTest
+{
+
+    @Test
+    public void orgApacheMaven_doesNotImply_orgApacheMavenArtifact()
+    {
+        assertFalse( new GroupPattern( "org.apache.maven" ).implies( new GroupPattern( "org.apache.maven.artifact" ) ) );
+    }
+
+    @Test
+    public void orgApacheMaven_wildcardImplies_orgApacheMavenArtifact()
+    {
+        assertTrue( new GroupPattern( "org.apache.maven.*" ).implies( new GroupPattern( "org.apache.maven.artifact" ) ) );
+    }
+
+    @Test
+    public void orgApacheMaven_wildcardImplies_orgApacheMaven()
+    {
+        assertTrue( new GroupPattern( "org.apache.maven.*" ).implies( new GroupPattern( "org.apache.maven" ) ) );
+    }
+
+    @Test
+    public void orgApacheMaven_impliesSelf()
+    {
+        GroupPattern pat = new GroupPattern( "org.apache.maven" );
+        assertTrue( pat.implies( pat ) );
+    }
+
+    @Test
+    public void orgApacheMaven_wildcardImpliesSelf()
+    {
+        GroupPattern pat = new GroupPattern( "org.apache.maven.*" );
+        assertTrue( pat.implies( pat ) );
+    }
+
+    @Test
+    public void s_orgApacheMaven_doesNotImply_orgApacheMavenArtifact()
+    {
+        assertFalse( new GroupPattern( "org.apache.maven" ).implies( "org.apache.maven.artifact" ) );
+    }
+
+    @Test
+    public void s_orgApacheMaven_wildcardImplies_orgApacheMavenArtifact()
+    {
+        assertTrue( new GroupPattern( "org.apache.maven.*" ).implies( "org.apache.maven.artifact" ) );
+    }
+
+    @Test
+    public void s_orgApacheMaven_wildcardImplies_orgApacheMaven()
+    {
+        assertTrue( new GroupPattern( "org.apache.maven.*" ).implies( "org.apache.maven" ) );
+    }
+
+    @Test
+    public void s_orgApacheMaven_impliesSelf()
+    {
+        GroupPattern pat = new GroupPattern( "org.apache.maven" );
+        assertTrue( pat.implies( pat.getPattern() ) );
+    }
+
+    @Test
+    public void s_orgApacheMaven_wildcardImpliesSelf()
+    {
+        GroupPattern pat = new GroupPattern( "org.apache.maven.*" );
+        assertTrue( pat.implies( pat.getPattern() ) );
+    }
+
+    @Test
+    public void wildcardSortsLastWhenBasePatternsAreEqual()
+    {
+        String base = "org.apache.maven";
+        String wc = base + ".*";
+
+        GroupPattern one = new GroupPattern( base );
+        GroupPattern two = new GroupPattern( wc );
+
+        Set<GroupPattern> set = new TreeSet<GroupPattern>();
+        set.add( one );
+        set.add( two );
+
+        Iterator<GroupPattern> it = set.iterator();
+        assertSame( one, it.next() );
+        assertSame( two, it.next() );
+    }
+
+    @Test
+    public void longestSortsFirstWhenBasesEqual()
+    {
+        String shorter = "org.apache.maven";
+        String longer = shorter + ".artifact";
+
+        GroupPattern one = new GroupPattern( shorter );
+        GroupPattern two = new GroupPattern( longer );
+
+        Set<GroupPattern> set = new TreeSet<GroupPattern>();
+        set.add( one );
+        set.add( two );
+
+        Iterator<GroupPattern> it = set.iterator();
+        assertSame( two, it.next() );
+        assertSame( one, it.next() );
+    }
+
+    @Test
+    public void longestSortsFirstWhenShortestHasWildcard()
+    {
+        String base = "org.apache.maven";
+        String wc = base + ".*";
+        String longer = base + ".artifact";
+
+        GroupPattern one = new GroupPattern( wc );
+        GroupPattern two = new GroupPattern( longer );
+
+        Set<GroupPattern> set = new TreeSet<GroupPattern>();
+        set.add( one );
+        set.add( two );
+
+        Iterator<GroupPattern> it = set.iterator();
+        assertSame( two, it.next() );
+        assertSame( one, it.next() );
+    }
+
+    @Test
+    public void unrelatedSortLexicographically()
+    {
+        String org = "org.apache.maven.*";
+        String com = "com.mycomp.fooba.*";
+
+        GroupPattern one = new GroupPattern( org );
+        GroupPattern two = new GroupPattern( com );
+
+        Set<GroupPattern> set = new TreeSet<GroupPattern>();
+        set.add( one );
+        set.add( two );
+
+        Iterator<GroupPattern> it = set.iterator();
+        assertSame( two, it.next() );
+        assertSame( one, it.next() );
+    }
+    
+    @Test
+    public void globalWildcardSortsLast()
+    {
+        String org = "org.apache.maven.*";
+        String com = "com.mycomp.fooba.*";
+        String wc = "*";
+
+        GroupPattern one = new GroupPattern( org );
+        GroupPattern two = new GroupPattern( com );
+        GroupPattern w = new GroupPattern( wc );
+
+        Set<GroupPattern> set = new TreeSet<GroupPattern>();
+        set.add( one );
+        set.add( two );
+        set.add( w );
+
+        Iterator<GroupPattern> it = set.iterator();
+        assertSame( two, it.next() );
+        assertSame( one, it.next() );
+        assertSame( w, it.next() );
+    }
+    
+    @Test( expected=IllegalArgumentException.class )
+    public void failWithInvalidGroupIdPattern()
+    {
+        new GroupPattern( "." );
+    }
+
+    @Test( expected=IllegalArgumentException.class )
+    public void failWithInvalidGroupIdPattern2()
+    {
+        new GroupPattern( ".." );
+    }
+
+    @Test( expected=IllegalArgumentException.class )
+    public void failWithInvalidGroupIdPattern3()
+    {
+        new GroupPattern( "/" );
+    }
+
+    @Test( expected=IllegalArgumentException.class )
+    public void failWithEmptyGroupIdPattern()
+    {
+        new GroupPattern( "" );
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupPatternTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupRouteTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupRouteTest.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupRouteTest.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupRouteTest.java Tue May 24 03:31:40 2011
@@ -0,0 +1,89 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static junit.framework.Assert.*;
+
+import org.apache.maven.artifact.router.GroupPattern;
+import org.apache.maven.artifact.router.GroupRoute;
+import org.junit.Test;
+
+public class GroupRouteTest
+{
+
+    @Test
+    public void containsWithExactMatch()
+    {
+        assertTrue( new GroupRoute( "http://maven.apache.org", new GroupPattern( "org.apache.maven" ) ).contains( new GroupPattern(
+                                                                                                                                    "org.apache.maven" ) ) );
+    }
+
+    @Test
+    public void s_containsWithExactMatch()
+    {
+        assertTrue( new GroupRoute( "http://maven.apache.org", new GroupPattern( "org.apache.maven" ) ).contains( "org.apache.maven" ) );
+    }
+
+    @Test
+    public void containsWithWildcardMatch()
+    {
+        assertTrue( new GroupRoute( "http://maven.apache.org", new GroupPattern( "org.apache.maven.*" ) ).contains( new GroupPattern(
+                                                                                                                                      "org.apache.maven.artifact" ) ) );
+    }
+
+    @Test
+    public void s_containsWithWildcardMatch()
+    {
+        assertTrue( new GroupRoute( "http://maven.apache.org", new GroupPattern( "org.apache.maven.*" ) ).contains( "org.apache.maven.artifact" ) );
+    }
+
+    @Test
+    public void containsWithMatchAmongTwoWildcards()
+    {
+        assertTrue( new GroupRoute( "http://maven.apache.org", new GroupPattern( "org.apache.maven.plugins.*" ),
+                                    new GroupPattern( "org.codehaus.mojo.*" ) ).contains( new GroupPattern(
+                                                                                                            "org.apache.maven.plugins" ) ) );
+    }
+    
+    @Test
+    public void mergeToIncludeBroaderMatch()
+    {
+        String m = "org.apache.maven";
+        String a = m + ".artifact";
+        
+        GroupRoute r = new GroupRoute( "http://maven.apache.org", new GroupPattern( "org.apache.maven" ) );
+        assertTrue( "Before merge, " + m + " NOT matched!", r.contains( m ) );
+        assertFalse( "Before merge, " + a + " matched!", r.contains( a ) );
+        
+        r.merge( new GroupPattern( "org.apache.maven.*" ) );
+        assertTrue( "After merge, " + m + " NO LONGER matched!", r.contains( m ) );
+        assertTrue( "After merge, " + a + " STILL not matched!", r.contains( a ) );
+    }
+
+    @Test
+    public void mergeReplacesObsoletePattern()
+    {
+        GroupRoute r = new GroupRoute( "http://maven.apache.org", new GroupPattern( "org.apache.maven" ) );
+        r.merge( new GroupPattern( "org.apache.maven.*" ) );
+        
+        assertEquals( "After merge, obsolete pattern NOT replaced!", 1, r.getGroupPatterns().size() );
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/GroupRouteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRouteTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRouteTest.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRouteTest.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRouteTest.java Tue May 24 03:31:40 2011
@@ -0,0 +1,52 @@
+/*
+ *  Copyright (C) 2011 John Casey.
+ *  
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.apache.maven.artifact.router;
+
+import org.apache.maven.artifact.router.MirrorRoute;
+
+import junit.framework.TestCase;
+
+public class MirrorRouteTest
+    extends TestCase
+{
+    
+    public void testMatchMirror()
+    {
+        String canonical = "http://repo1.maven.org/maven2";
+        MirrorRoute route = new MirrorRoute( "test", "http://localhost:8080/mirror", 10, true, canonical );
+        
+        assertTrue( route.isMirrorOf( canonical ) );
+    }
+
+    public void testMatchSecondMirrorOf()
+    {
+        String canonical = "http://repo1.maven.org/maven2";
+        MirrorRoute route = new MirrorRoute( "test", "http://localhost:8080/mirror", 10, true, "http://www.foo.bar.com/mirror", canonical );
+        
+        assertTrue( route.isMirrorOf( canonical ) );
+    }
+
+    public void testMatchMirrorWithTrailingSlashMismatched()
+    {
+        String canonical = "http://repo1.maven.org/maven2";
+        MirrorRoute route = new MirrorRoute( "test", "http://localhost:8080/mirror", 10, true, canonical + "/" );
+        
+        assertTrue( route.isMirrorOf( canonical ) );
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRouteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRoutingTableTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRoutingTableTest.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRoutingTableTest.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRoutingTableTest.java Tue May 24 03:31:40 2011
@@ -0,0 +1,55 @@
+/*
+ *  Copyright (C) 2011 John Casey.
+ *  
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.apache.maven.artifact.router;
+
+import org.apache.maven.artifact.router.MirrorRoute;
+import org.apache.maven.artifact.router.ArtifactRoutingTables;
+
+import junit.framework.TestCase;
+
+public class MirrorRoutingTableTest
+    extends TestCase
+{
+    
+    public void testFindMirrorMatch()
+    {
+        String canonical = "http://repo1.maven.org/maven2";
+        
+        ArtifactRoutingTables table = new ArtifactRoutingTables();
+        MirrorRoute route = new MirrorRoute( "test", "http://nowhere.com/mirror", 10, true, canonical );
+        table.addMirror( route );
+        
+        MirrorRoute result = table.getMirror( canonical );
+        
+        assertEquals( route, result );
+    }
+
+    public void testMirrorMatchNotFound()
+    {
+        String canonical = "http://repo1.maven.org/maven3";
+        
+        ArtifactRoutingTables table = new ArtifactRoutingTables();
+        MirrorRoute route = new MirrorRoute( "test", "http://nowhere.com/mirror", 10, true, "http://repo1.maven.org/maven2" );
+        table.addMirror( route );
+        
+        MirrorRoute result = table.getMirror( canonical );
+        
+        assertNull( result );
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/MirrorRoutingTableTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/RouterMirrorSerializerTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/RouterMirrorSerializerTest.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/RouterMirrorSerializerTest.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/RouterMirrorSerializerTest.java Tue May 24 03:31:40 2011
@@ -0,0 +1,71 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.router.MirrorRoute;
+import org.apache.maven.artifact.router.ArtifactRouteSerializer;
+import org.apache.maven.artifact.router.ArtifactRoutingTables;
+
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+public class RouterMirrorSerializerTest
+    extends TestCase
+{
+
+    public void testSerializeOneMirror()
+        throws Exception
+    {
+        final ArtifactRoutingTables mirrorMap =
+            new ArtifactRoutingTables().addMirror( new MirrorRoute( "central",
+                                                             "http://localhost:8081/nexus", 99, true, "http://repo1.maven.org/maven2" ) );
+
+        final StringWriter sw = new StringWriter();
+        ArtifactRouteSerializer.serialize( mirrorMap, sw );
+
+        System.out.println( sw );
+    }
+
+    public void testSerializeToStringOneMirror()
+        throws Exception
+    {
+        final ArtifactRoutingTables mirrorMap =
+            new ArtifactRoutingTables().addMirror( new MirrorRoute( "central",
+                                                             "http://localhost:8081/nexus", 99, true, "http://repo1.maven.org/maven2" ) );
+
+        System.out.println( ArtifactRouteSerializer.serializeToString( mirrorMap ) );
+    }
+
+    public void testRoundTripOneMirror()
+        throws Exception
+    {
+        final ArtifactRoutingTables mirrorMap =
+            new ArtifactRoutingTables().addMirror( new MirrorRoute( "central",
+                                                             "http://localhost:8081/nexus", 99, true, "http://repo1.maven.org/maven2" ) );
+
+        final String ser = ArtifactRouteSerializer.serializeToString( mirrorMap );
+        final ArtifactRoutingTables result = ArtifactRouteSerializer.deserialize( ser );
+
+        assertEquals( mirrorMap, result );
+        assertTrue( result.getMirror( "http://repo1.maven.org/maven2" ).isEnabled() );
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-api/src/test/java/org/apache/maven/artifact/router/RouterMirrorSerializerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-impl/pom.xml
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-impl/pom.xml?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-impl/pom.xml (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-impl/pom.xml Tue May 24 03:31:40 2011
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>maven</artifactId>
+    <groupId>org.apache.maven</groupId>
+    <version>3.0.4-SNAPSHOT</version>
+  </parent>
+  <artifactId>maven-routem-impl</artifactId>
+  <name>Maven Route-M Implementation</name>
+  <description>Maven Route-M artifact-router Implementation</description>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+    </dependency>
+    <dependency>
+    	<groupId>org.apache.maven</groupId>
+    	<artifactId>maven-routem-api</artifactId>
+    </dependency>
+    <dependency>
+    	<groupId>org.apache.httpcomponents</groupId>
+    	<artifactId>httpclient</artifactId>
+    </dependency>
+    <dependency>
+    	<groupId>org.codehaus.plexus</groupId>
+    	<artifactId>plexus-component-annotations</artifactId>
+    </dependency>
+    <dependency>
+    	<groupId>org.sonatype.sisu</groupId>
+    	<artifactId>sisu-inject-plexus</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-impl/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-routem-impl/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-impl/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java?rev=1126851&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java Tue May 24 03:31:40 2011
@@ -0,0 +1,67 @@
+package org.apache.maven.artifact.router;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.router.MirrorRoute;
+import org.apache.maven.artifact.router.ArtifactRoutingTables;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class ArtifactRouter
+{
+    
+    private ArtifactRoutingTables routingTable;
+    
+    private Map<String, MirrorRoute> selectedRoutes;
+    
+    public ArtifactRouter( ArtifactRoutingTables routingTable, Map<String, MirrorRoute> selectedRoutes )
+    {
+        this.routingTable = routingTable;
+        this.selectedRoutes = selectedRoutes;
+    }
+
+    public ArtifactRouter()
+    {
+        routingTable = new ArtifactRoutingTables();
+        selectedRoutes = Collections.emptyMap();
+    }
+
+    public synchronized MirrorRoute getMirror( String canonicalUrl )
+    {
+        MirrorRoute route = selectedRoutes.get( canonicalUrl );
+        if ( route == null )
+        {
+            route = routingTable.getMirror( canonicalUrl );
+            if ( route != null )
+            {
+                selectedRoutes.put( canonicalUrl, route );
+            }
+        }
+        
+        return route;
+    }
+    
+    public Map<String, MirrorRoute> getSelectedRoutes()
+    {
+        return selectedRoutes;
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/ArtifactRouter.java
------------------------------------------------------------------------------
    svn:eol-style = native