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 04:33:38 UTC

svn commit: r1126834 [1/3] - in /maven/maven-3/branches/mirror-group-routing: maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/ maven-auto-mirror-model/src/test/java/org/apache/maven/repository/automirror/ maven-core/src/mai...

Author: jdcasey
Date: Tue May 24 02:33:37 2011
New Revision: 1126834

URL: http://svn.apache.org/viewvc?rev=1126834&view=rev
Log:
message

Added:
    maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoute.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouteSerializer.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouterModelException.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoutingTable.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/MirrorRouterException.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/RoutingMirrorSelector.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/DefaultMirrorRouterConfigBuilder.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/FileMirrorRouterConfigSource.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/MirrorRouterConfigBuilder.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/MirrorRouterConfigSource.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/MirrorRouterConfiguration.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/configuration/MirrorRouterConfigurationException.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/discovery/
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/discovery/DNSDiscoveryStrategy.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/discovery/RouterDiscoveryStrategy.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/loader/
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/loader/DefaultMirrorRoutingTableLoader.java   (with props)
    maven/maven-3/branches/mirror-group-routing/maven-core/src/main/java/org/apache/maven/repository/mirror/loader/MirrorRoutingTableLoader.java   (with props)
Modified:
    maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/test/java/org/apache/maven/repository/automirror/RouterMirrorSerializerTest.java
    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/DefaultMirrorRouter.java
    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-embedder/src/main/java/org/apache/maven/cli/MavenCli.java

Added: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoute.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoute.java?rev=1126834&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoute.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoute.java Tue May 24 02:33:37 2011
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+package org.apache.maven.repository.automirror;
+
+public class MirrorRoute
+    implements Comparable<MirrorRoute>
+{
+
+    private final String id;
+
+    private final String mirrorUrl;
+
+    private final int weight;
+
+    private final boolean enabled;
+
+    private final String url;
+
+    MirrorRoute()
+    {
+        id = null;
+        url = null;
+        mirrorUrl = null;
+        weight = 0;
+        enabled = false;
+    }
+
+    public MirrorRoute( final String id, final String url, final String mirrorUrl, final int weight,
+                        final boolean enabled )
+    {
+        this.id = id;
+        this.url = url;
+        this.mirrorUrl = mirrorUrl;
+        this.weight = weight;
+        this.enabled = enabled;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public String getMirrorUrl()
+    {
+        return mirrorUrl;
+    }
+
+    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 + ", url: " + url + ", mirror-url: " + mirrorUrl
+                        + ", enabled: " + enabled + "]";
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( mirrorUrl == null ) ? 0 : mirrorUrl.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 ( mirrorUrl == null )
+        {
+            if ( other.mirrorUrl != null )
+            {
+                return false;
+            }
+        }
+        else if ( !mirrorUrl.equals( other.mirrorUrl ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+    public String getUrl()
+    {
+        return url;
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouteSerializer.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouteSerializer.java?rev=1126834&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouteSerializer.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouteSerializer.java Tue May 24 02:33:37 2011
@@ -0,0 +1,105 @@
+package org.apache.maven.repository.automirror;
+
+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.List;
+
+public class MirrorRouteSerializer
+{
+
+    // NOTE: Gson is supposed to be threadsafe, so all this static stuff should be fine.
+    private static Gson gson;
+
+    public static void serialize( final MirrorRoutingTable mirrors, final Writer writer )
+        throws MirrorRouterModelException
+    {
+        try
+        {
+            getGson().toJson( mirrors, writer );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new MirrorRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static String serializeToString( final MirrorRoutingTable mirrors )
+        throws MirrorRouterModelException
+    {
+        try
+        {
+            return getGson().toJson( mirrors );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new MirrorRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static MirrorRoutingTable deserialize( final Reader reader )
+        throws MirrorRouterModelException
+    {
+        try
+        {
+            return getGson().fromJson( reader, MirrorRoutingTable.class );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new MirrorRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    public static MirrorRoutingTable deserialize( final String source )
+        throws MirrorRouterModelException
+    {
+        try
+        {
+            return getGson().fromJson( source, MirrorRoutingTable.class );
+        }
+        catch ( final JsonParseException e )
+        {
+            throw new MirrorRouterModelException( "Cannot read router-mirrors.", e );
+        }
+    }
+
+    private static Gson getGson()
+    {
+        if ( gson == null )
+        {
+            final GsonBuilder builder = new GsonBuilder();
+            builder.disableHtmlEscaping().disableInnerClassSerialization().setPrettyPrinting();
+            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();
+        }
+
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouteSerializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouterModelException.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouterModelException.java?rev=1126834&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouterModelException.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouterModelException.java Tue May 24 02:33:37 2011
@@ -0,0 +1,36 @@
+/*
+ *  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.repository.automirror;
+
+public class MirrorRouterModelException
+    extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+    public MirrorRouterModelException( final String message, final Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public MirrorRouterModelException( final String message )
+    {
+        super( message );
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRouterModelException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoutingTable.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoutingTable.java?rev=1126834&view=auto
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoutingTable.java (added)
+++ maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoutingTable.java Tue May 24 02:33:37 2011
@@ -0,0 +1,210 @@
+/*
+ * 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.
+ */
+package org.apache.maven.repository.automirror;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+public class MirrorRoutingTable
+    implements Iterable<MirrorRoute>
+{
+
+    private List<MirrorRoute> mirrors = new ArrayList<MirrorRoute>();
+
+    private final transient Random random = new Random();
+
+    private transient Map<String, int[]> indexGrabBags = new HashMap<String, int[]>();
+
+    public synchronized MirrorRoutingTable addMirror( final MirrorRoute mirror )
+    {
+        if ( !mirrors.contains( mirror ) )
+        {
+            mirrors.add( mirror );
+            indexGrabBags.remove( mirror.getUrl() );
+        }
+
+        return this;
+    }
+
+    public 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;
+    }
+
+    public MirrorRoute getWeightedRandomSuggestion( final String canonicalUrl )
+    {
+        if ( mirrors.isEmpty() )
+        {
+            return null;
+        }
+
+        int[] indexGrabBag = null;
+        synchronized ( canonicalUrl )
+        {
+            indexGrabBag = indexGrabBags.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() )
+                    {
+                        // only select from enabled mirrors.
+                        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 );
+                        }
+                    }
+                }
+
+                final int[] grabBag = new int[gb.size()];
+                for ( int i = 0; i < grabBag.length; i++ )
+                {
+                    grabBag[i] = gb.get( i );
+                }
+
+                indexGrabBags.put( canonicalUrl, grabBag );
+            }
+        }
+
+        // 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 int size()
+    {
+        return mirrors.size();
+    }
+
+    public boolean isEmpty()
+    {
+        return mirrors.isEmpty();
+    }
+
+    public boolean contains( final MirrorRoute o )
+    {
+        return mirrors.contains( o );
+    }
+
+    public Iterator<MirrorRoute> iterator()
+    {
+        return mirrors.iterator();
+    }
+
+    @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 MirrorRoutingTable other = (MirrorRoutingTable) obj;
+        if ( mirrors == null )
+        {
+            if ( other.mirrors != null )
+            {
+                return false;
+            }
+        }
+        else if ( !mirrors.equals( other.mirrors ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+    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() && canonicalUrl.equals( mirror.getUrl() ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+}

Propchange: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/main/java/org/apache/maven/repository/automirror/MirrorRoutingTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/test/java/org/apache/maven/repository/automirror/RouterMirrorSerializerTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/test/java/org/apache/maven/repository/automirror/RouterMirrorSerializerTest.java?rev=1126834&r1=1126833&r2=1126834&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/test/java/org/apache/maven/repository/automirror/RouterMirrorSerializerTest.java (original)
+++ maven/maven-3/branches/mirror-group-routing/maven-auto-mirror-model/src/test/java/org/apache/maven/repository/automirror/RouterMirrorSerializerTest.java Tue May 24 02:33:37 2011
@@ -11,12 +11,12 @@ public class RouterMirrorSerializerTest
     public void testSerializeOneMirror()
         throws Exception
     {
-        final RouterMirrors mirrorMap =
-            new RouterMirrors().addMirror( new RouterMirror( "central", "http://repo1.maven.org/maven2",
+        final MirrorRoutingTable mirrorMap =
+            new MirrorRoutingTable().addMirror( new MirrorRoute( "central", "http://repo1.maven.org/maven2",
                                                              "http://localhost:8081/nexus", 99, true ) );
 
         final StringWriter sw = new StringWriter();
-        RouterMirrorSerializer.serialize( mirrorMap, sw );
+        MirrorRouteSerializer.serialize( mirrorMap, sw );
 
         System.out.println( sw );
     }
@@ -24,22 +24,22 @@ public class RouterMirrorSerializerTest
     public void testSerializeToStringOneMirror()
         throws Exception
     {
-        final RouterMirrors mirrorMap =
-            new RouterMirrors().addMirror( new RouterMirror( "central", "http://repo1.maven.org/maven2",
+        final MirrorRoutingTable mirrorMap =
+            new MirrorRoutingTable().addMirror( new MirrorRoute( "central", "http://repo1.maven.org/maven2",
                                                              "http://localhost:8081/nexus", 99, true ) );
 
-        System.out.println( RouterMirrorSerializer.serializeToString( mirrorMap ) );
+        System.out.println( MirrorRouteSerializer.serializeToString( mirrorMap ) );
     }
 
     public void testRoundTripOneMirror()
         throws Exception
     {
-        final RouterMirrors mirrorMap =
-            new RouterMirrors().addMirror( new RouterMirror( "central", "http://repo1.maven.org/maven2",
+        final MirrorRoutingTable mirrorMap =
+            new MirrorRoutingTable().addMirror( new MirrorRoute( "central", "http://repo1.maven.org/maven2",
                                                              "http://localhost:8081/nexus", 99, true ) );
 
-        final String ser = RouterMirrorSerializer.serializeToString( mirrorMap );
-        final RouterMirrors result = RouterMirrorSerializer.deserialize( ser );
+        final String ser = MirrorRouteSerializer.serializeToString( mirrorMap );
+        final MirrorRoutingTable result = MirrorRouteSerializer.deserialize( ser );
 
         assertEquals( mirrorMap, result );
         assertTrue( result.getHighestPriorityMirror( "http://repo1.maven.org/maven2" ).isEnabled() );

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=1126834&r1=1126833&r2=1126834&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 02:33:37 2011
@@ -15,22 +15,6 @@ package org.apache.maven;
  * the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.eventspy.internal.EventSpyDispatcher;
@@ -58,6 +42,7 @@ import org.apache.maven.project.ProjectB
 import org.apache.maven.project.ProjectSorter;
 import org.apache.maven.repository.DelegatingLocalArtifactRepository;
 import org.apache.maven.repository.LocalRepositoryNotAccessibleException;
+import org.apache.maven.repository.mirror.RoutingMirrorSelector;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Server;
@@ -93,20 +78,35 @@ import org.sonatype.aether.util.graph.se
 import org.sonatype.aether.util.graph.selector.OptionalDependencySelector;
 import org.sonatype.aether.util.graph.selector.ScopeDependencySelector;
 import org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
-import org.sonatype.aether.util.graph.transformer.NearestVersionConflictResolver;
 import org.sonatype.aether.util.graph.transformer.ConflictMarker;
 import org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner;
 import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator;
+import org.sonatype.aether.util.graph.transformer.NearestVersionConflictResolver;
 import org.sonatype.aether.util.graph.traverser.FatArtifactTraverser;
 import org.sonatype.aether.util.repository.ChainedWorkspaceReader;
 import org.sonatype.aether.util.repository.DefaultAuthenticationSelector;
-import org.sonatype.aether.util.repository.DefaultMirrorSelector;
 import org.sonatype.aether.util.repository.DefaultProxySelector;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 /**
  * @author Jason van Zyl
  */
-@Component(role = Maven.class)
+@Component( role = Maven.class )
 public class DefaultMaven
     implements Maven
 {
@@ -147,7 +147,7 @@ public class DefaultMaven
     @Requirement
     private EventSpyDispatcher eventSpyDispatcher;
 
-    public MavenExecutionResult execute( MavenExecutionRequest request )
+    public MavenExecutionResult execute( final MavenExecutionRequest request )
     {
         MavenExecutionResult result;
 
@@ -155,15 +155,15 @@ public class DefaultMaven
         {
             result = doExecute( populator.populateDefaults( request ) );
         }
-        catch ( OutOfMemoryError e )
+        catch ( final OutOfMemoryError e )
         {
             result = processResult( new DefaultMavenExecutionResult(), e );
         }
-        catch ( MavenExecutionRequestPopulationException e )
+        catch ( final MavenExecutionRequestPopulationException e )
         {
             result = processResult( new DefaultMavenExecutionResult(), e );
         }
-        catch ( RuntimeException e )
+        catch ( final RuntimeException e )
         {
             result =
                 processResult( new DefaultMavenExecutionResult(),
@@ -177,46 +177,48 @@ public class DefaultMaven
         return result;
     }
 
-    @SuppressWarnings({"ThrowableInstanceNeverThrown", "ThrowableResultOfMethodCallIgnored"})
-    private MavenExecutionResult doExecute( MavenExecutionRequest request )
+    @SuppressWarnings( { "ThrowableInstanceNeverThrown", "ThrowableResultOfMethodCallIgnored" } )
+    private MavenExecutionResult doExecute( final MavenExecutionRequest request )
     {
-        //TODO: Need a general way to inject standard properties
+        // TODO: Need a general way to inject standard properties
         if ( request.getStartTime() != null )
         {
-            request.getSystemProperties().put( "${build.timestamp}", new SimpleDateFormat( "yyyyMMdd-hhmm" ).format( request.getStartTime() ) );
-        }        
-        
+            request.getSystemProperties()
+                   .put( "${build.timestamp}", new SimpleDateFormat( "yyyyMMdd-hhmm" ).format( request.getStartTime() ) );
+        }
+
         request.setStartTime( new Date() );
-        
-        MavenExecutionResult result = new DefaultMavenExecutionResult();
+
+        final MavenExecutionResult result = new DefaultMavenExecutionResult();
 
         try
         {
             validateLocalRepository( request );
         }
-        catch ( LocalRepositoryNotAccessibleException e )
+        catch ( final LocalRepositoryNotAccessibleException e )
         {
             return processResult( result, e );
         }
 
-        DelegatingLocalArtifactRepository delegatingLocalArtifactRepository =
+        final DelegatingLocalArtifactRepository delegatingLocalArtifactRepository =
             new DelegatingLocalArtifactRepository( request.getLocalRepository() );
-        
-        request.setLocalRepository( delegatingLocalArtifactRepository );        
 
-        DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) newRepositorySession( request );
+        request.setLocalRepository( delegatingLocalArtifactRepository );
+
+        final DefaultRepositorySystemSession repoSession =
+            (DefaultRepositorySystemSession) newRepositorySession( request );
 
-        MavenSession session = new MavenSession( container, repoSession, request, result );
+        final MavenSession session = new MavenSession( container, repoSession, request, result );
         legacySupport.setSession( session );
 
         try
         {
-            for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.<MavenProject> emptyList() ) )
+            for ( final AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.<MavenProject> emptyList() ) )
             {
                 listener.afterSessionStart( session );
             }
         }
-        catch ( MavenExecutionException e )
+        catch ( final MavenExecutionException e )
         {
             return processResult( result, e );
         }
@@ -225,14 +227,14 @@ public class DefaultMaven
 
         request.getProjectBuildingRequest().setRepositorySession( session.getRepositorySession() );
 
-        //TODO: optimize for the single project or no project
-        
+        // TODO: optimize for the single project or no project
+
         List<MavenProject> projects;
         try
         {
-            projects = getProjectsForMavenReactor( request );                                                
+            projects = getProjectsForMavenReactor( request );
         }
-        catch ( ProjectBuildingException e )
+        catch ( final ProjectBuildingException e )
         {
             return processResult( result, e );
         }
@@ -240,40 +242,40 @@ public class DefaultMaven
         session.setProjects( projects );
 
         result.setTopologicallySortedProjects( session.getProjects() );
-        
+
         result.setProject( session.getTopLevelProject() );
 
         try
         {
             Map<String, MavenProject> projectMap;
             projectMap = getProjectMap( session.getProjects() );
-    
+
             // Desired order of precedence for local artifact repositories
             //
             // Reactor
             // Workspace
             // User Local Repository
-            ReactorReader reactorRepository = new ReactorReader( projectMap );
+            final ReactorReader reactorRepository = new ReactorReader( projectMap );
 
             repoSession.setWorkspaceReader( ChainedWorkspaceReader.newInstance( reactorRepository,
                                                                                 repoSession.getWorkspaceReader() ) );
         }
-        catch ( org.apache.maven.DuplicateProjectException e )
+        catch ( final org.apache.maven.DuplicateProjectException e )
         {
             return processResult( result, e );
         }
 
-        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+        final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         try
         {
-            for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( projects ) )
+            for ( final AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( projects ) )
             {
                 Thread.currentThread().setContextClassLoader( listener.getClass().getClassLoader() );
 
                 listener.afterProjectsRead( session );
             }
         }
-        catch ( MavenExecutionException e )
+        catch ( final MavenExecutionException e )
         {
             return processResult( result, e );
         }
@@ -284,27 +286,27 @@ public class DefaultMaven
 
         try
         {
-            ProjectSorter projectSorter = new ProjectSorter( session.getProjects() );
+            final ProjectSorter projectSorter = new ProjectSorter( session.getProjects() );
 
-            ProjectDependencyGraph projectDependencyGraph = createDependencyGraph( projectSorter, request );
+            final ProjectDependencyGraph projectDependencyGraph = createDependencyGraph( projectSorter, request );
 
             session.setProjects( projectDependencyGraph.getSortedProjects() );
 
             session.setProjectDependencyGraph( projectDependencyGraph );
         }
-        catch ( CycleDetectedException e )
-        {            
-            String message = "The projects in the reactor contain a cyclic reference: " + e.getMessage();
+        catch ( final CycleDetectedException e )
+        {
+            final String message = "The projects in the reactor contain a cyclic reference: " + e.getMessage();
 
-            ProjectCycleException error = new ProjectCycleException( message, e );
+            final ProjectCycleException error = new ProjectCycleException( message, e );
 
             return processResult( result, error );
         }
-        catch ( DuplicateProjectException e )
+        catch ( final DuplicateProjectException e )
         {
             return processResult( result, e );
         }
-        catch ( MavenExecutionException e )
+        catch ( final MavenExecutionException e )
         {
             return processResult( result, e );
         }
@@ -328,15 +330,15 @@ public class DefaultMaven
         return result;
     }
 
-    public RepositorySystemSession newRepositorySession( MavenExecutionRequest request )
+    public RepositorySystemSession newRepositorySession( final MavenExecutionRequest request )
     {
-        DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
+        final DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
 
         session.setCache( request.getRepositoryCache() );
 
         session.setIgnoreInvalidArtifactDescriptor( true ).setIgnoreMissingArtifactDescriptor( true );
 
-        Map<Object, Object> configProps = new LinkedHashMap<Object, Object>();
+        final Map<Object, Object> configProps = new LinkedHashMap<Object, Object>();
         configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() );
         configProps.put( ConfigurationProperties.INTERACTIVE, Boolean.valueOf( request.isInteractiveMode() ) );
         configProps.putAll( request.getSystemProperties() );
@@ -351,7 +353,7 @@ public class DefaultMaven
 
         session.setArtifactTypeRegistry( RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) );
 
-        LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() );
+        final LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() );
         session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) );
 
         if ( request.getWorkspaceReader() != null )
@@ -363,57 +365,61 @@ public class DefaultMaven
             session.setWorkspaceReader( workspaceRepository );
         }
 
-        DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest();
+        final DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest();
         decrypt.setProxies( request.getProxies() );
         decrypt.setServers( request.getServers() );
-        SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt );
+        final SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt );
 
         if ( logger.isDebugEnabled() )
         {
-            for ( SettingsProblem problem : decrypted.getProblems() )
+            for ( final SettingsProblem problem : decrypted.getProblems() )
             {
                 logger.debug( problem.getMessage(), problem.getException() );
             }
         }
 
-        DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
-        for ( Mirror mirror : request.getMirrors() )
+        final RoutingMirrorSelector mirrorSelector =
+            new RoutingMirrorSelector( request.getMirrorRoutingTable(), logger );
+        
+        for ( final Mirror mirror : request.getMirrors() )
         {
             mirrorSelector.add( mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
                                 mirror.getMirrorOfLayouts() );
         }
+        
         session.setMirrorSelector( mirrorSelector );
 
-        DefaultProxySelector proxySelector = new DefaultProxySelector();
-        for ( Proxy proxy : decrypted.getProxies() )
+        final DefaultProxySelector proxySelector = new DefaultProxySelector();
+        for ( final Proxy proxy : decrypted.getProxies() )
         {
-            Authentication proxyAuth = new Authentication( proxy.getUsername(), proxy.getPassword() );
-            proxySelector.add( new org.sonatype.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(),
-                                                                proxyAuth ), proxy.getNonProxyHosts() );
+            final Authentication proxyAuth = new Authentication( proxy.getUsername(), proxy.getPassword() );
+            proxySelector.add( new org.sonatype.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(),
+                                                                         proxy.getPort(), proxyAuth ),
+                               proxy.getNonProxyHosts() );
         }
         session.setProxySelector( proxySelector );
 
-        DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector();
-        for ( Server server : decrypted.getServers() )
+        final DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector();
+        for ( final Server server : decrypted.getServers() )
         {
-            Authentication auth =
+            final Authentication auth =
                 new Authentication( server.getUsername(), server.getPassword(), server.getPrivateKey(),
                                     server.getPassphrase() );
             authSelector.add( server.getId(), auth );
 
             if ( server.getConfiguration() != null )
             {
-                Xpp3Dom dom = (Xpp3Dom) server.getConfiguration();
+                final Xpp3Dom dom = (Xpp3Dom) server.getConfiguration();
                 for ( int i = dom.getChildCount() - 1; i >= 0; i-- )
                 {
-                    Xpp3Dom child = dom.getChild( i );
+                    final Xpp3Dom child = dom.getChild( i );
                     if ( "wagonProvider".equals( child.getName() ) )
                     {
                         dom.removeChild( i );
                     }
                 }
 
-                XmlPlexusConfiguration config = new XmlPlexusConfiguration( dom );
+                final XmlPlexusConfiguration config = new XmlPlexusConfiguration( dom );
                 configProps.put( "aether.connector.wagon.config." + server.getId(), config );
             }
 
@@ -422,18 +428,18 @@ public class DefaultMaven
         }
         session.setAuthenticationSelector( authSelector );
 
-        DependencyTraverser depTraverser = new FatArtifactTraverser();
+        final DependencyTraverser depTraverser = new FatArtifactTraverser();
         session.setDependencyTraverser( depTraverser );
 
-        DependencyManager depManager = new ClassicDependencyManager();
+        final DependencyManager depManager = new ClassicDependencyManager();
         session.setDependencyManager( depManager );
 
-        DependencySelector depFilter =
-            new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), new OptionalDependencySelector(),
-                                     new ExclusionDependencySelector() );
+        final DependencySelector depFilter =
+            new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ),
+                                       new OptionalDependencySelector(), new ExclusionDependencySelector() );
         session.setDependencySelector( depFilter );
 
-        DependencyGraphTransformer transformer =
+        final DependencyGraphTransformer transformer =
             new ChainedDependencyGraphTransformer( new ConflictMarker(), new JavaEffectiveScopeCalculator(),
                                                    new NearestVersionConflictResolver(),
                                                    new JavaDependencyContextRefiner() );
@@ -452,7 +458,7 @@ public class DefaultMaven
 
     private String getUserAgent()
     {
-        StringBuilder buffer = new StringBuilder( 128 );
+        final StringBuilder buffer = new StringBuilder( 128 );
 
         buffer.append( "Apache-Maven/" ).append( getMavenVersion() );
         buffer.append( " (" );
@@ -466,16 +472,17 @@ public class DefaultMaven
 
     private String getMavenVersion()
     {
-        Properties props = new Properties();
+        final Properties props = new Properties();
 
-        InputStream is = getClass().getResourceAsStream( "/META-INF/maven/org.apache.maven/maven-core/pom.properties" );
+        final InputStream is =
+            getClass().getResourceAsStream( "/META-INF/maven/org.apache.maven/maven-core/pom.properties" );
         if ( is != null )
         {
             try
             {
                 props.load( is );
             }
-            catch ( IOException e )
+            catch ( final IOException e )
             {
                 logger.debug( "Failed to read Maven version", e );
             }
@@ -485,11 +492,11 @@ public class DefaultMaven
         return props.getProperty( "version", "unknown-version" );
     }
 
-    @SuppressWarnings({"ResultOfMethodCallIgnored"})
-    private void validateLocalRepository( MavenExecutionRequest request )
+    @SuppressWarnings( { "ResultOfMethodCallIgnored" } )
+    private void validateLocalRepository( final MavenExecutionRequest request )
         throws LocalRepositoryNotAccessibleException
     {
-        File localRepoDir = request.getLocalRepositoryPath();
+        final File localRepoDir = request.getLocalRepositoryPath();
 
         logger.debug( "Using local repository at " + localRepoDir );
 
@@ -501,29 +508,29 @@ public class DefaultMaven
         }
     }
 
-    private Collection<AbstractMavenLifecycleParticipant> getLifecycleParticipants( Collection<MavenProject> projects )
+    private Collection<AbstractMavenLifecycleParticipant> getLifecycleParticipants( final Collection<MavenProject> projects )
     {
-        Collection<AbstractMavenLifecycleParticipant> lifecycleListeners =
+        final Collection<AbstractMavenLifecycleParticipant> lifecycleListeners =
             new LinkedHashSet<AbstractMavenLifecycleParticipant>();
 
-        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+        final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         try
         {
             try
             {
                 lifecycleListeners.addAll( container.lookupList( AbstractMavenLifecycleParticipant.class ) );
             }
-            catch ( ComponentLookupException e )
+            catch ( final ComponentLookupException e )
             {
                 // this is just silly, lookupList should return an empty list!
                 logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() );
             }
 
-            Collection<ClassLoader> scannedRealms = new HashSet<ClassLoader>();
+            final Collection<ClassLoader> scannedRealms = new HashSet<ClassLoader>();
 
-            for ( MavenProject project : projects )
+            for ( final MavenProject project : projects )
             {
-                ClassLoader projectRealm = project.getClassRealm();
+                final ClassLoader projectRealm = project.getClassRealm();
 
                 if ( projectRealm != null && scannedRealms.add( projectRealm ) )
                 {
@@ -533,7 +540,7 @@ public class DefaultMaven
                     {
                         lifecycleListeners.addAll( container.lookupList( AbstractMavenLifecycleParticipant.class ) );
                     }
-                    catch ( ComponentLookupException e )
+                    catch ( final ComponentLookupException e )
                     {
                         // this is just silly, lookupList should return an empty list!
                         logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() );
@@ -549,7 +556,7 @@ public class DefaultMaven
         return lifecycleListeners;
     }
 
-    private MavenExecutionResult processResult( MavenExecutionResult result, Throwable e )
+    private MavenExecutionResult processResult( final MavenExecutionResult result, final Throwable e )
     {
         if ( !result.getExceptions().contains( e ) )
         {
@@ -558,41 +565,43 @@ public class DefaultMaven
 
         return result;
     }
-    
-    private List<MavenProject> getProjectsForMavenReactor( MavenExecutionRequest request )
+
+    private List<MavenProject> getProjectsForMavenReactor( final MavenExecutionRequest request )
         throws ProjectBuildingException
     {
-        List<MavenProject> projects =  new ArrayList<MavenProject>();
+        final List<MavenProject> projects = new ArrayList<MavenProject>();
 
         // We have no POM file.
         //
         if ( request.getPom() == null )
         {
-            ModelSource modelSource = new UrlModelSource( DefaultMaven.class.getResource( "project/standalone.xml" ) );
-            MavenProject project =
+            final ModelSource modelSource =
+                new UrlModelSource( DefaultMaven.class.getResource( "project/standalone.xml" ) );
+            final MavenProject project =
                 projectBuilder.build( modelSource, request.getProjectBuildingRequest() ).getProject();
             project.setExecutionRoot( true );
             projects.add( project );
             request.setProjectPresent( false );
             return projects;
         }
-        
-        List<File> files = Arrays.asList( request.getPom().getAbsoluteFile() );        
+
+        final List<File> files = Arrays.asList( request.getPom().getAbsoluteFile() );
         collectProjects( projects, files, request );
         return projects;
     }
 
-    private Map<String, MavenProject> getProjectMap( List<MavenProject> projects )
+    private Map<String, MavenProject> getProjectMap( final List<MavenProject> projects )
         throws org.apache.maven.DuplicateProjectException
     {
-        Map<String, MavenProject> index = new LinkedHashMap<String, MavenProject>();
-        Map<String, List<File>> collisions = new LinkedHashMap<String, List<File>>();
+        final Map<String, MavenProject> index = new LinkedHashMap<String, MavenProject>();
+        final Map<String, List<File>> collisions = new LinkedHashMap<String, List<File>>();
 
-        for ( MavenProject project : projects )
+        for ( final MavenProject project : projects )
         {
-            String projectId = ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() );
+            final String projectId =
+                ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() );
 
-            MavenProject collision = index.get( projectId );
+            final MavenProject collision = index.get( projectId );
 
             if ( collision == null )
             {
@@ -617,23 +626,25 @@ public class DefaultMaven
         if ( !collisions.isEmpty() )
         {
             throw new org.apache.maven.DuplicateProjectException( "Two or more projects in the reactor"
-                + " have the same identifier, please make sure that <groupId>:<artifactId>:<version>"
-                + " is unique for each project: " + collisions, collisions );
+                            + " have the same identifier, please make sure that <groupId>:<artifactId>:<version>"
+                            + " is unique for each project: " + collisions, collisions );
         }
 
         return index;
     }
 
-    private void collectProjects( List<MavenProject> projects, List<File> files, MavenExecutionRequest request )
+    private void collectProjects( final List<MavenProject> projects, final List<File> files,
+                                  final MavenExecutionRequest request )
         throws ProjectBuildingException
     {
-        ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();
+        final ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();
 
-        List<ProjectBuildingResult> results = projectBuilder.build( files, request.isRecursive(), projectBuildingRequest );
+        final List<ProjectBuildingResult> results =
+            projectBuilder.build( files, request.isRecursive(), projectBuildingRequest );
 
         boolean problems = false;
 
-        for ( ProjectBuildingResult result : results )
+        for ( final ProjectBuildingResult result : results )
         {
             projects.add( result.getProject() );
 
@@ -641,11 +652,11 @@ public class DefaultMaven
             {
                 logger.warn( "" );
                 logger.warn( "Some problems were encountered while building the effective model for "
-                    + result.getProject().getId() );
+                                + result.getProject().getId() );
 
-                for ( ModelProblem problem : result.getProblems() )
+                for ( final ModelProblem problem : result.getProblems() )
                 {
-                    String location = ModelProblemUtils.formatLocation( problem, result.getProjectId() );
+                    final String location = ModelProblemUtils.formatLocation( problem, result.getProjectId() );
                     logger.warn( problem.getMessage() + ( StringUtils.isNotEmpty( location ) ? " @ " + location : "" ) );
                 }
 
@@ -657,30 +668,30 @@ public class DefaultMaven
         {
             logger.warn( "" );
             logger.warn( "It is highly recommended to fix these problems"
-                + " because they threaten the stability of your build." );
+                            + " because they threaten the stability of your build." );
             logger.warn( "" );
             logger.warn( "For this reason, future Maven versions might no"
-                + " longer support building such malformed projects." );
+                            + " longer support building such malformed projects." );
             logger.warn( "" );
         }
     }
 
-    private void validateActivatedProfiles( List<MavenProject> projects, List<String> activeProfileIds )
+    private void validateActivatedProfiles( final List<MavenProject> projects, final List<String> activeProfileIds )
     {
-        Collection<String> notActivatedProfileIds = new LinkedHashSet<String>( activeProfileIds );
+        final Collection<String> notActivatedProfileIds = new LinkedHashSet<String>( activeProfileIds );
 
-        for ( MavenProject project : projects )
+        for ( final MavenProject project : projects )
         {
-            for ( List<String> profileIds : project.getInjectedProfileIds().values() )
+            for ( final List<String> profileIds : project.getInjectedProfileIds().values() )
             {
                 notActivatedProfileIds.removeAll( profileIds );
             }
         }
 
-        for ( String notActivatedProfileId : notActivatedProfileIds )
+        for ( final String notActivatedProfileId : notActivatedProfileIds )
         {
             logger.warn( "The requested profile \"" + notActivatedProfileId
-                + "\" could not be activated because it does not exist." );
+                            + "\" could not be activated because it does not exist." );
         }
     }
 
@@ -689,7 +700,8 @@ public class DefaultMaven
         return logger;
     }
 
-    private ProjectDependencyGraph createDependencyGraph( ProjectSorter sorter, MavenExecutionRequest request )
+    private ProjectDependencyGraph createDependencyGraph( final ProjectSorter sorter,
+                                                          final MavenExecutionRequest request )
         throws MavenExecutionException
     {
         ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( sorter );
@@ -707,8 +719,9 @@ public class DefaultMaven
         return graph;
     }
 
-    private List<MavenProject> trimSelectedProjects( List<MavenProject> projects, ProjectDependencyGraph graph,
-                                                     MavenExecutionRequest request )
+    private List<MavenProject> trimSelectedProjects( final List<MavenProject> projects,
+                                                     final ProjectDependencyGraph graph,
+                                                     final MavenExecutionRequest request )
         throws MavenExecutionException
     {
         List<MavenProject> result = projects;
@@ -721,13 +734,13 @@ public class DefaultMaven
                 reactorDirectory = new File( request.getBaseDirectory() );
             }
 
-            Collection<MavenProject> selectedProjects = new LinkedHashSet<MavenProject>( projects.size() );
+            final Collection<MavenProject> selectedProjects = new LinkedHashSet<MavenProject>( projects.size() );
 
-            for ( String selector : request.getSelectedProjects() )
+            for ( final String selector : request.getSelectedProjects() )
             {
                 MavenProject selectedProject = null;
 
-                for ( MavenProject project : projects )
+                for ( final MavenProject project : projects )
                 {
                     if ( isMatchingProject( project, selector, reactorDirectory ) )
                     {
@@ -743,7 +756,7 @@ public class DefaultMaven
                 else
                 {
                     throw new MavenExecutionException( "Could not find the selected project in the reactor: "
-                        + selector, request.getPom() );
+                                    + selector, request.getPom() );
                 }
             }
 
@@ -771,7 +784,7 @@ public class DefaultMaven
 
             if ( makeUpstream || makeDownstream )
             {
-                for ( MavenProject selectedProject : new ArrayList<MavenProject>( selectedProjects ) )
+                for ( final MavenProject selectedProject : new ArrayList<MavenProject>( selectedProjects ) )
                 {
                     if ( makeUpstream )
                     {
@@ -786,7 +799,7 @@ public class DefaultMaven
 
             result = new ArrayList<MavenProject>( selectedProjects.size() );
 
-            for ( MavenProject project : projects )
+            for ( final MavenProject project : projects )
             {
                 if ( selectedProjects.contains( project ) )
                 {
@@ -798,7 +811,8 @@ public class DefaultMaven
         return result;
     }
 
-    private List<MavenProject> trimResumedProjects( List<MavenProject> projects, MavenExecutionRequest request )
+    private List<MavenProject> trimResumedProjects( final List<MavenProject> projects,
+                                                    final MavenExecutionRequest request )
         throws MavenExecutionException
     {
         List<MavenProject> result = projects;
@@ -811,13 +825,13 @@ public class DefaultMaven
                 reactorDirectory = new File( request.getBaseDirectory() );
             }
 
-            String selector = request.getResumeFrom();
+            final String selector = request.getResumeFrom();
 
             result = new ArrayList<MavenProject>( projects.size() );
 
             boolean resumed = false;
 
-            for ( MavenProject project : projects )
+            for ( final MavenProject project : projects )
             {
                 if ( !resumed && isMatchingProject( project, selector, reactorDirectory ) )
                 {
@@ -833,14 +847,14 @@ public class DefaultMaven
             if ( !resumed )
             {
                 throw new MavenExecutionException( "Could not find project to resume reactor build from: " + selector
-                    + " vs " + projects, request.getPom() );
+                                + " vs " + projects, request.getPom() );
             }
         }
 
         return result;
     }
 
-    private boolean isMatchingProject( MavenProject project, String selector, File reactorDirectory )
+    private boolean isMatchingProject( final MavenProject project, final String selector, final File reactorDirectory )
     {
         // [groupId]:artifactId
         if ( selector.indexOf( ':' ) >= 0 )
@@ -863,7 +877,7 @@ public class DefaultMaven
         // relative path, e.g. "sub", "../sub" or "."
         else if ( reactorDirectory != null )
         {
-            File selectedProject = new File( new File( reactorDirectory, selector ).toURI().normalize() );
+            final File selectedProject = new File( new File( reactorDirectory, selector ).toURI().normalize() );
 
             if ( selectedProject.isFile() )
             {

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=1126834&r1=1126833&r2=1126834&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 02:33:37 2011
@@ -19,16 +19,11 @@ package org.apache.maven.execution;
  * under the License.
  */
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Profile;
 import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.automirror.MirrorRoutingTable;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Server;
@@ -37,6 +32,12 @@ import org.sonatype.aether.repository.Wo
 import org.sonatype.aether.transfer.TransferListener;
 import org.sonatype.aether.util.DefaultRepositoryCache;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
 /**
  * @author Jason van Zyl
  */
@@ -138,7 +139,7 @@ public class DefaultMavenExecutionReques
 
     /**
      * Suppress SNAPSHOT updates.
-     *
+     * 
      * @issue MNG-2681
      */
     private boolean noSnapshotUpdates;
@@ -147,9 +148,9 @@ public class DefaultMavenExecutionReques
     {
     }
 
-    public static MavenExecutionRequest copy( MavenExecutionRequest original )
+    public static MavenExecutionRequest copy( final MavenExecutionRequest original )
     {
-        DefaultMavenExecutionRequest copy = new DefaultMavenExecutionRequest();
+        final DefaultMavenExecutionRequest copy = new DefaultMavenExecutionRequest();
         copy.setLocalRepository( original.getLocalRepository() );
         copy.setLocalRepositoryPath( original.getLocalRepositoryPath() );
         copy.setOffline( original.isOffline() );
@@ -165,8 +166,7 @@ public class DefaultMavenExecutionReques
         copy.setUserSettingsFile( original.getUserSettingsFile() );
         copy.setGlobalSettingsFile( original.getGlobalSettingsFile() );
         copy.setUserToolchainsFile( original.getUserToolchainsFile() );
-        copy.setBaseDirectory( ( original.getBaseDirectory() != null )
-                               ? new File( original.getBaseDirectory() ) : null );
+        copy.setBaseDirectory( ( original.getBaseDirectory() != null ) ? new File( original.getBaseDirectory() ) : null );
         copy.setGoals( original.getGoals() );
         copy.setRecursive( original.isRecursive() );
         copy.setPom( original.getPom() );
@@ -185,6 +185,7 @@ public class DefaultMavenExecutionReques
         copy.setWorkspaceReader( original.getWorkspaceReader() );
         copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
         copy.setExecutionListener( original.getExecutionListener() );
+        copy.setMirrorRoutingTable( original.getMirrorRoutingTable() );
         return copy;
     }
 
@@ -282,7 +283,7 @@ public class DefaultMavenExecutionReques
         return interactiveMode;
     }
 
-    public MavenExecutionRequest setActiveProfiles( List<String> activeProfiles )
+    public MavenExecutionRequest setActiveProfiles( final List<String> activeProfiles )
     {
         if ( activeProfiles != null )
         {
@@ -296,7 +297,7 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setInactiveProfiles( List<String> inactiveProfiles )
+    public MavenExecutionRequest setInactiveProfiles( final List<String> inactiveProfiles )
     {
         if ( inactiveProfiles != null )
         {
@@ -310,7 +311,7 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
+    public MavenExecutionRequest setRemoteRepositories( final List<ArtifactRepository> remoteRepositories )
     {
         if ( remoteRepositories != null )
         {
@@ -324,7 +325,7 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setPluginArtifactRepositories( List<ArtifactRepository> pluginArtifactRepositories )
+    public MavenExecutionRequest setPluginArtifactRepositories( final List<ArtifactRepository> pluginArtifactRepositories )
     {
         if ( pluginArtifactRepositories != null )
         {
@@ -338,9 +339,9 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public void setProjectBuildingConfiguration( ProjectBuildingRequest projectBuildingConfiguration )
+    public void setProjectBuildingConfiguration( final ProjectBuildingRequest projectBuildingConfiguration )
     {
-        this.projectBuildingRequest = projectBuildingConfiguration;
+        projectBuildingRequest = projectBuildingConfiguration;
     }
 
     public List<String> getActiveProfiles()
@@ -400,28 +401,28 @@ public class DefaultMavenExecutionReques
     //
     // ----------------------------------------------------------------------
 
-    public MavenExecutionRequest setBaseDirectory( File basedir )
+    public MavenExecutionRequest setBaseDirectory( final File basedir )
     {
         this.basedir = basedir;
 
         return this;
     }
 
-    public MavenExecutionRequest setStartTime( Date startTime )
+    public MavenExecutionRequest setStartTime( final Date startTime )
     {
         this.startTime = startTime;
 
         return this;
     }
 
-    public MavenExecutionRequest setShowErrors( boolean showErrors )
+    public MavenExecutionRequest setShowErrors( final boolean showErrors )
     {
         this.showErrors = showErrors;
 
         return this;
     }
 
-    public MavenExecutionRequest setGoals( List<String> goals )
+    public MavenExecutionRequest setGoals( final List<String> goals )
     {
         if ( goals != null )
         {
@@ -435,7 +436,7 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setLocalRepository( ArtifactRepository localRepository )
+    public MavenExecutionRequest setLocalRepository( final ArtifactRepository localRepository )
     {
         this.localRepository = localRepository;
 
@@ -447,36 +448,36 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setLocalRepositoryPath( File localRepository )
+    public MavenExecutionRequest setLocalRepositoryPath( final File localRepository )
     {
         localRepositoryPath = localRepository;
 
         return this;
     }
 
-    public MavenExecutionRequest setLocalRepositoryPath( String localRepository )
+    public MavenExecutionRequest setLocalRepositoryPath( final String localRepository )
     {
         localRepositoryPath = ( localRepository != null ) ? new File( localRepository ) : null;
 
         return this;
     }
 
-    public MavenExecutionRequest setSystemProperties( Properties properties )
+    public MavenExecutionRequest setSystemProperties( final Properties properties )
     {
         if ( properties != null )
         {
-            this.systemProperties = new Properties();
-            this.systemProperties.putAll( properties );
+            systemProperties = new Properties();
+            systemProperties.putAll( properties );
         }
         else
         {
-            this.systemProperties = null;
+            systemProperties = null;
         }
 
         return this;
     }
 
-    public MavenExecutionRequest setUserProperties( Properties userProperties )
+    public MavenExecutionRequest setUserProperties( final Properties userProperties )
     {
         if ( userProperties != null )
         {
@@ -491,14 +492,14 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setReactorFailureBehavior( String failureBehavior )
+    public MavenExecutionRequest setReactorFailureBehavior( final String failureBehavior )
     {
         reactorFailureBehavior = failureBehavior;
 
         return this;
     }
 
-    public MavenExecutionRequest setSelectedProjects( List<String> selectedProjects )
+    public MavenExecutionRequest setSelectedProjects( final List<String> selectedProjects )
     {
         if ( selectedProjects != null )
         {
@@ -512,21 +513,21 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setResumeFrom( String project )
+    public MavenExecutionRequest setResumeFrom( final String project )
     {
-        this.resumeFrom = project;
+        resumeFrom = project;
 
         return this;
     }
 
-    public MavenExecutionRequest setMakeBehavior( String makeBehavior )
+    public MavenExecutionRequest setMakeBehavior( final String makeBehavior )
     {
         this.makeBehavior = makeBehavior;
 
         return this;
     }
 
-    public MavenExecutionRequest addActiveProfile( String profile )
+    public MavenExecutionRequest addActiveProfile( final String profile )
     {
         if ( !getActiveProfiles().contains( profile ) )
         {
@@ -536,7 +537,7 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest addInactiveProfile( String profile )
+    public MavenExecutionRequest addInactiveProfile( final String profile )
     {
         if ( !getInactiveProfiles().contains( profile ) )
         {
@@ -546,9 +547,9 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest addActiveProfiles( List<String> profiles )
+    public MavenExecutionRequest addActiveProfiles( final List<String> profiles )
     {
-        for ( String profile : profiles )
+        for ( final String profile : profiles )
         {
             addActiveProfile( profile );
         }
@@ -556,9 +557,9 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest addInactiveProfiles( List<String> profiles )
+    public MavenExecutionRequest addInactiveProfiles( final List<String> profiles )
     {
-        for ( String profile : profiles )
+        for ( final String profile : profiles )
         {
             addInactiveProfile( profile );
         }
@@ -566,7 +567,7 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setUseReactor( boolean reactorActive )
+    public MavenExecutionRequest setUseReactor( final boolean reactorActive )
     {
         useReactor = reactorActive;
 
@@ -579,7 +580,8 @@ public class DefaultMavenExecutionReques
     }
 
     /** @deprecated use {@link #setPom(File)} */
-    public MavenExecutionRequest setPomFile( String pomFilename )
+    @Deprecated
+    public MavenExecutionRequest setPomFile( final String pomFilename )
     {
         if ( pomFilename != null )
         {
@@ -589,56 +591,56 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setPom( File pom )
+    public MavenExecutionRequest setPom( final File pom )
     {
         this.pom = pom;
 
         return this;
     }
 
-    public MavenExecutionRequest setInteractiveMode( boolean interactive )
+    public MavenExecutionRequest setInteractiveMode( final boolean interactive )
     {
         interactiveMode = interactive;
 
         return this;
     }
 
-    public MavenExecutionRequest setTransferListener( TransferListener transferListener )
+    public MavenExecutionRequest setTransferListener( final TransferListener transferListener )
     {
         this.transferListener = transferListener;
 
         return this;
     }
 
-    public MavenExecutionRequest setLoggingLevel( int loggingLevel )
+    public MavenExecutionRequest setLoggingLevel( final int loggingLevel )
     {
         this.loggingLevel = loggingLevel;
 
         return this;
     }
 
-    public MavenExecutionRequest setOffline( boolean offline )
+    public MavenExecutionRequest setOffline( final boolean offline )
     {
         this.offline = offline;
 
         return this;
     }
 
-    public MavenExecutionRequest setUpdateSnapshots( boolean updateSnapshots )
+    public MavenExecutionRequest setUpdateSnapshots( final boolean updateSnapshots )
     {
         this.updateSnapshots = updateSnapshots;
 
         return this;
     }
 
-    public MavenExecutionRequest setNoSnapshotUpdates( boolean noSnapshotUpdates )
+    public MavenExecutionRequest setNoSnapshotUpdates( final boolean noSnapshotUpdates )
     {
         this.noSnapshotUpdates = noSnapshotUpdates;
 
         return this;
     }
 
-    public MavenExecutionRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
+    public MavenExecutionRequest setGlobalChecksumPolicy( final String globalChecksumPolicy )
     {
         this.globalChecksumPolicy = globalChecksumPolicy;
 
@@ -658,7 +660,7 @@ public class DefaultMavenExecutionReques
         return proxies;
     }
 
-    public MavenExecutionRequest setProxies( List<Proxy> proxies )
+    public MavenExecutionRequest setProxies( final List<Proxy> proxies )
     {
         if ( proxies != null )
         {
@@ -672,14 +674,14 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest addProxy( Proxy proxy )
+    public MavenExecutionRequest addProxy( final Proxy proxy )
     {
         if ( proxy == null )
         {
             throw new IllegalArgumentException( "proxy missing" );
         }
 
-        for ( Proxy p : getProxies() )
+        for ( final Proxy p : getProxies() )
         {
             if ( p.getId() != null && p.getId().equals( proxy.getId() ) )
             {
@@ -701,7 +703,7 @@ public class DefaultMavenExecutionReques
         return servers;
     }
 
-    public MavenExecutionRequest setServers( List<Server> servers )
+    public MavenExecutionRequest setServers( final List<Server> servers )
     {
         if ( servers != null )
         {
@@ -715,14 +717,14 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest addServer( Server server )
+    public MavenExecutionRequest addServer( final Server server )
     {
         if ( server == null )
         {
             throw new IllegalArgumentException( "server missing" );
         }
 
-        for ( Server p : getServers() )
+        for ( final Server p : getServers() )
         {
             if ( p.getId() != null && p.getId().equals( server.getId() ) )
             {
@@ -744,7 +746,7 @@ public class DefaultMavenExecutionReques
         return mirrors;
     }
 
-    public MavenExecutionRequest setMirrors( List<Mirror> mirrors )
+    public MavenExecutionRequest setMirrors( final List<Mirror> mirrors )
     {
         if ( mirrors != null )
         {
@@ -758,14 +760,14 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest addMirror( Mirror mirror )
+    public MavenExecutionRequest addMirror( final Mirror mirror )
     {
         if ( mirror == null )
         {
             throw new IllegalArgumentException( "mirror missing" );
         }
 
-        for ( Mirror p : getMirrors() )
+        for ( final Mirror p : getMirrors() )
         {
             if ( p.getId() != null && p.getId().equals( mirror.getId() ) )
             {
@@ -787,7 +789,7 @@ public class DefaultMavenExecutionReques
         return profiles;
     }
 
-    public MavenExecutionRequest setProfiles( List<Profile> profiles )
+    public MavenExecutionRequest setProfiles( final List<Profile> profiles )
     {
         if ( profiles != null )
         {
@@ -811,7 +813,7 @@ public class DefaultMavenExecutionReques
         return pluginGroups;
     }
 
-    public MavenExecutionRequest setPluginGroups( List<String> pluginGroups )
+    public MavenExecutionRequest setPluginGroups( final List<String> pluginGroups )
     {
         if ( pluginGroups != null )
         {
@@ -825,7 +827,7 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest addPluginGroup( String pluginGroup )
+    public MavenExecutionRequest addPluginGroup( final String pluginGroup )
     {
         if ( !getPluginGroups().contains( pluginGroup ) )
         {
@@ -835,9 +837,9 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest addPluginGroups( List<String> pluginGroups )
+    public MavenExecutionRequest addPluginGroups( final List<String> pluginGroups )
     {
-        for ( String pluginGroup : pluginGroups )
+        for ( final String pluginGroup : pluginGroups )
         {
             addPluginGroup( pluginGroup );
         }
@@ -845,7 +847,7 @@ public class DefaultMavenExecutionReques
         return this;
     }
 
-    public MavenExecutionRequest setRecursive( boolean recursive )
+    public MavenExecutionRequest setRecursive( final boolean recursive )
     {
         this.recursive = recursive;
 
@@ -855,14 +857,12 @@ public class DefaultMavenExecutionReques
     // calculated from request attributes.
     private ProjectBuildingRequest projectBuildingRequest;
 
-    private File extensionConfDir;
-
     public boolean isProjectPresent()
     {
         return isProjectPresent;
     }
 
-    public MavenExecutionRequest setProjectPresent( boolean projectPresent )
+    public MavenExecutionRequest setProjectPresent( final boolean projectPresent )
     {
         isProjectPresent = projectPresent;
 
@@ -876,7 +876,7 @@ public class DefaultMavenExecutionReques
         return userSettingsFile;
     }
 
-    public MavenExecutionRequest setUserSettingsFile( File userSettingsFile )
+    public MavenExecutionRequest setUserSettingsFile( final File userSettingsFile )
     {
         this.userSettingsFile = userSettingsFile;
 
@@ -888,7 +888,7 @@ public class DefaultMavenExecutionReques
         return globalSettingsFile;
     }
 
-    public MavenExecutionRequest setGlobalSettingsFile( File globalSettingsFile )
+    public MavenExecutionRequest setGlobalSettingsFile( final File globalSettingsFile )
     {
         this.globalSettingsFile = globalSettingsFile;
 
@@ -900,16 +900,16 @@ public class DefaultMavenExecutionReques
         return userToolchainsFile;
     }
 
-    public MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile )
+    public MavenExecutionRequest setUserToolchainsFile( final File userToolchainsFile )
     {
         this.userToolchainsFile = userToolchainsFile;
 
         return this;
     }
 
-    public MavenExecutionRequest addRemoteRepository( ArtifactRepository repository )
+    public MavenExecutionRequest addRemoteRepository( final ArtifactRepository repository )
     {
-        for ( ArtifactRepository repo : getRemoteRepositories() )
+        for ( final ArtifactRepository repo : getRemoteRepositories() )
         {
             if ( repo.getId() != null && repo.getId().equals( repository.getId() ) )
             {
@@ -931,9 +931,9 @@ public class DefaultMavenExecutionReques
         return remoteRepositories;
     }
 
-    public MavenExecutionRequest addPluginArtifactRepository( ArtifactRepository repository )
+    public MavenExecutionRequest addPluginArtifactRepository( final ArtifactRepository repository )
     {
-        for ( ArtifactRepository repo : getPluginArtifactRepositories() )
+        for ( final ArtifactRepository repo : getPluginArtifactRepositories() )
         {
             if ( repo.getId() != null && repo.getId().equals( repository.getId() ) )
             {
@@ -955,7 +955,7 @@ public class DefaultMavenExecutionReques
         return pluginArtifactRepositories;
     }
 
-    //TODO: this does not belong here.
+    // TODO: this does not belong here.
     public ProjectBuildingRequest getProjectBuildingRequest()
     {
         if ( projectBuildingRequest == null )
@@ -976,14 +976,14 @@ public class DefaultMavenExecutionReques
         return projectBuildingRequest;
     }
 
-    public MavenExecutionRequest addProfile( Profile profile )
+    public MavenExecutionRequest addProfile( final Profile profile )
     {
         if ( profile == null )
         {
             throw new IllegalArgumentException( "profile missing" );
         }
 
-        for ( Profile p : getProfiles() )
+        for ( final Profile p : getProfiles() )
         {
             if ( p.getId() != null && p.getId().equals( profile.getId() ) )
             {
@@ -1001,7 +1001,7 @@ public class DefaultMavenExecutionReques
         return repositoryCache;
     }
 
-    public MavenExecutionRequest setRepositoryCache( RepositoryCache repositoryCache )
+    public MavenExecutionRequest setRepositoryCache( final RepositoryCache repositoryCache )
     {
         this.repositoryCache = repositoryCache;
 
@@ -1013,7 +1013,7 @@ public class DefaultMavenExecutionReques
         return executionListener;
     }
 
-    public MavenExecutionRequest setExecutionListener( ExecutionListener executionListener )
+    public MavenExecutionRequest setExecutionListener( final ExecutionListener executionListener )
     {
         this.executionListener = executionListener;
 
@@ -1025,7 +1025,7 @@ public class DefaultMavenExecutionReques
         return threadCount;
     }
 
-    public void setThreadCount( String threadCount )
+    public void setThreadCount( final String threadCount )
     {
         this.threadCount = threadCount;
     }
@@ -1040,7 +1040,7 @@ public class DefaultMavenExecutionReques
         return perCoreThreadCount;
     }
 
-    public void setPerCoreThreadCount( boolean perCoreThreadCount )
+    public void setPerCoreThreadCount( final boolean perCoreThreadCount )
     {
         this.perCoreThreadCount = perCoreThreadCount;
     }
@@ -1050,7 +1050,7 @@ public class DefaultMavenExecutionReques
         return workspaceReader;
     }
 
-    public MavenExecutionRequest setWorkspaceReader( WorkspaceReader workspaceReader )
+    public MavenExecutionRequest setWorkspaceReader( final WorkspaceReader workspaceReader )
     {
         this.workspaceReader = workspaceReader;
         return this;
@@ -1061,7 +1061,7 @@ public class DefaultMavenExecutionReques
         return cacheTransferError;
     }
 
-    public MavenExecutionRequest setCacheTransferError( boolean cacheTransferError )
+    public MavenExecutionRequest setCacheTransferError( final boolean cacheTransferError )
     {
         this.cacheTransferError = cacheTransferError;
         return this;
@@ -1072,20 +1072,27 @@ public class DefaultMavenExecutionReques
         return cacheNotFound;
     }
 
-    public MavenExecutionRequest setCacheNotFound( boolean cacheNotFound )
+    public MavenExecutionRequest setCacheNotFound( final boolean cacheNotFound )
     {
         this.cacheNotFound = cacheNotFound;
         return this;
     }
 
-    public File getUserExtensionConfDir()
+    private MirrorRoutingTable mirrorRoutingTable;
+
+    public synchronized MirrorRoutingTable getMirrorRoutingTable()
     {
-        return extensionConfDir;
+        if ( mirrorRoutingTable == null )
+        {
+            mirrorRoutingTable = new MirrorRoutingTable();
+        }
+
+        return mirrorRoutingTable;
     }
 
-    public MavenExecutionRequest setUserExtensionConfDir( File extensionConfDir )
+    public MavenExecutionRequest setMirrorRoutingTable( final MirrorRoutingTable mirrorRoutingTable )
     {
-        this.extensionConfDir = extensionConfDir;
+        this.mirrorRoutingTable = mirrorRoutingTable;
         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=1126834&r1=1126833&r2=1126834&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 02:33:37 2011
@@ -23,6 +23,7 @@ import org.apache.maven.artifact.reposit
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
 import org.apache.maven.model.Profile;
 import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.automirror.MirrorRoutingTable;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Server;
@@ -341,8 +342,21 @@ public interface MavenExecutionRequest
 
     ProjectBuildingRequest getProjectBuildingRequest();
 
-    File getUserExtensionConfDir();
+    /**
+     * List of mirrors, URLs they mirror, weight for each mirror, whether it's disabled, etc. This is used to select a
+     * mirror for a particular repository URL.
+     * 
+     * @return The routing table instance for use in this build. Never {@code null}.
+     */
+    MirrorRoutingTable getMirrorRoutingTable();
 
-    MavenExecutionRequest setUserExtensionConfDir( File extensionConfDir );
+    /**
+     * Set the list of mirrors, urls they mirror, weight for each mirror, whether it's disabled, etc.
+     * 
+     * @param routingTable
+     *            The {@link MirrorRoutingTable} to use for the current build.
+     * @return This request, never {@code null}.
+     */
+    MavenExecutionRequest setMirrorRoutingTable( MirrorRoutingTable routingTable );
 
 }