Modified: 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java?rev=1130392&r1=1130391&r2=1130392&view=diff
==============================================================================
--- 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java
 (original)
+++ 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/DefaultRouterLoader.java
 Thu Jun  2 03:13:03 2011
@@ -1,3 +1,22 @@
+/*
+ * 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.artifact.router.loader;
 
 /*
@@ -21,42 +40,25 @@ package org.apache.maven.artifact.router
 
 import static org.codehaus.plexus.util.IOUtil.close;
 
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.maven.artifact.router.ArtifactRouter;
 import org.apache.maven.artifact.router.ArtifactRouterException;
-import org.apache.maven.artifact.router.GroupRoute;
-import org.apache.maven.artifact.router.MirrorRoute;
 import org.apache.maven.artifact.router.conf.ArtifactRouterConfiguration;
-import 
org.apache.maven.artifact.router.discovery.ArtifactRouterDiscoveryStrategy;
+import org.apache.maven.artifact.router.conf.RouterSource;
 import org.apache.maven.artifact.router.io.ArtifactRouteSerializer;
 import org.apache.maven.artifact.router.io.ArtifactRouterModelException;
+import 
org.apache.maven.artifact.router.loader.discovery.ArtifactRouterDiscoveryStrategy;
+import org.apache.maven.artifact.router.session.ArtifactRouterSession;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.util.IOUtil;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 @Component( role = ArtifactRouterLoader.class )
 public class DefaultRouterLoader
@@ -68,27 +70,30 @@ public class DefaultRouterLoader
 
     @Requirement
     private Logger logger;
+    
+    @Requirement
+    private ArtifactRouterReader routerReader;
 
-    public ArtifactRouter load( final ArtifactRouterConfiguration config )
+    public ArtifactRouter load( final ArtifactRouterSession session )
         throws ArtifactRouterException
     {
-        if ( config == null || config.isDisabled() )
+        if ( session == null || session.isDisabled() )
         {
             return new ArtifactRouter();
         }
         
-        return loadRoutes( config );
+        return loadRoutes( session );
     }
 
-    public void save( final ArtifactRouter router, final 
ArtifactRouterConfiguration config )
+    public void save( final ArtifactRouter router, final ArtifactRouterSession 
session )
         throws ArtifactRouterException
     {
-        if ( config == null )
+        if ( session == null )
         {
             return;
         }
         
-        File routingTablesFile = config.getRoutesFile();
+        File routingTablesFile = session.getRoutesFile();
         if ( routingTablesFile != null )
         {
             FileWriter writer = null;
@@ -118,10 +123,10 @@ public class DefaultRouterLoader
         }
     }
 
-    protected ArtifactRouter loadSaved( ArtifactRouterConfiguration config )
+    protected ArtifactRouter loadSaved( ArtifactRouterSession session )
         throws ArtifactRouterException
     {
-        File routesFile = config.getRoutesFile();
+        File routesFile = session.getRoutesFile();
         if ( routesFile != null && routesFile.exists() && routesFile.canRead() 
)
         {
             FileReader reader = null;
@@ -147,58 +152,35 @@ public class DefaultRouterLoader
         return new ArtifactRouter();
     }
 
-    protected ArtifactRouter loadRoutes( final ArtifactRouterConfiguration 
config )
+    protected ArtifactRouter loadRoutes( final ArtifactRouterSession session )
         throws ArtifactRouterException
     {
         ArtifactRouter routes = null;
         
-        if ( config.isClear() )
+        if ( session.isClear() )
         {
             routes = new ArtifactRouter();
-            save( routes, config );
+            save( routes, session );
         }
         else
         {
-            routes = loadSaved( config );
+            routes = loadSaved( session );
         }
 
-        if ( config.isUpdate() && !config.isOffline() )
+        if ( session.isUpdate() && !session.isOffline() )
         {
-            // FIXME: What about proxies?! Should be using settings.xml proxy 
defs.
-            final DefaultHttpClient client = new DefaultHttpClient();
-            if ( config.getRouterCredentials() != null )
+            try
             {
-                client.setCredentialsProvider( new CredentialsProvider()
+                for ( RouterSource src : session.getSources() )
                 {
-                    public void setCredentials( final AuthScope authscope, 
final Credentials credentials )
+                    ArtifactRouter r = routerReader.loadRouter( src, session );
+                    if ( r != null )
                     {
+                        routes.merge( r );
                     }
-
-                    public synchronized Credentials getCredentials( final 
AuthScope authscope )
-                    {
-                        final UsernamePasswordCredentials creds = 
config.getRouterCredentials();
-                        return creds;
-                    }
-
-                    public void clear()
-                    {
-                    }
-                } );
-            }
-
-            try
-            {
-                if ( config.getRouterMirrorsUrl() != null )
-                {
-                    routes.addMirrors( getMirrorMapping( 
config.getRouterMirrorsUrl(), config, client ) );
                 }
                 
-                if ( config.getRouterGroupsUrl() != null )
-                {
-                    routes.addGroups( getGroupMapping( 
config.getRouterGroupsUrl(), config, client ) );
-                }
-                
-                final String[] discoStrategies = 
config.getDiscoveryStrategies();
+                final String[] discoStrategies = 
session.getDiscoveryStrategies();
                 if ( discoStrategies != null && discoStrategies.length > 0
                     && !"none".equalsIgnoreCase( 
discoStrategies[0].toLowerCase() ) )
                 {
@@ -237,25 +219,13 @@ public class DefaultRouterLoader
 
                     for ( final ArtifactRouterDiscoveryStrategy strategy : 
strats )
                     {
-                        ArtifactRouter result = strategy.findRouter();
+                        ArtifactRouter result = strategy.findRouter( session );
                         if ( result != null )
                         {
                             routes.merge( result );
                         }
                     }
                 }
-
-                final String centralMirrorsUrl = 
config.getCanonicalMirrorsUrl();
-                if ( centralMirrorsUrl != null && 
centralMirrorsUrl.trim().length() > 0 )
-                {
-                    routes.addMirrors( getMirrorMapping( centralMirrorsUrl, 
config, client ) );
-                }
-                
-                final String centralGroupsUrl = config.getCanonicalGroupsUrl();
-                if ( centralGroupsUrl != null && 
centralGroupsUrl.trim().length() > 0 )
-                {
-                    routes.addGroups( getGroupMapping( centralGroupsUrl, 
config, client ) );
-                }
             }
             catch ( final ArtifactRouterException e )
             {
@@ -290,212 +260,4 @@ public class DefaultRouterLoader
         return strat;
     }
 
-    private Set<MirrorRoute> getMirrorMapping( final String routerUrl, final 
ArtifactRouterConfiguration config,
-                                                 final HttpClient client )
-    {
-        if ( routerUrl != null && routerUrl.trim().length() > 0 )
-        {
-            if ( logger.isDebugEnabled() )
-            {
-                logger.debug( "Grabbing mirror mappings from: " + 
routerUrl.toString() );
-            }
-            System.out.println( "Grabbing mirror mappings from: " + routerUrl 
);
-
-            final HttpGet get = new HttpGet( routerUrl );
-            get.addHeader( "Accept", "application/json;q=0.9,*/*;q=0.8" );
-
-            try
-            {
-                return client.execute( get, new 
ResponseHandler<Set<MirrorRoute>>()
-                {
-                    public Set<MirrorRoute> handleResponse( final HttpResponse 
response )
-                        throws /* ClientProtocolException, */IOException
-                    {
-                        final int statusCode = 
response.getStatusLine().getStatusCode();
-                        if ( statusCode == 200 )
-                        {
-                            InputStream stream = null;
-                            try
-                            {
-                                stream = response.getEntity().getContent();
-                                final ByteArrayOutputStream baos = new 
ByteArrayOutputStream();
-                                IOUtil.copy( stream, baos );
-
-                                String content = null;
-                                final Header contentType = 
response.getFirstHeader( "Content-Type" );
-                                if ( contentType != null )
-                                {
-                                    final HeaderElement[] contentTypeElts = 
contentType.getElements();
-
-                                    if ( contentTypeElts != null )
-                                    {
-                                        for ( final HeaderElement elt : 
contentTypeElts )
-                                        {
-                                            final NameValuePair nv = 
elt.getParameterByName( "charset" );
-                                            if ( nv != null )
-                                            {
-                                                content = new String( 
baos.toByteArray(), nv.getValue() );
-                                            }
-                                        }
-                                    }
-                                }
-
-                                if ( content == null )
-                                {
-                                    content = new String( baos.toByteArray() );
-                                }
-
-                                if ( logger.isDebugEnabled() )
-                                {
-                                    logger.debug( "Response code/message: '" + 
response.getStatusLine().getStatusCode()
-                                        + " " + 
response.getStatusLine().getReasonPhrase() + "'\nContent is:\n\n"
-                                        + content );
-                                }
-
-                                return 
ArtifactRouteSerializer.deserializeMirrors( content );
-                            }
-                            catch ( final ArtifactRouterModelException e )
-                            {
-                                logger.error( "Failed to retrieve mirror 
mapping from: " + routerUrl, e );
-                            }
-                            finally
-                            {
-                                close( stream );
-                            }
-                        }
-                        else if ( logger.isDebugEnabled() )
-                        {
-                            logger.debug( "Response: " + 
response.getStatusLine().getStatusCode() + " "
-                                + response.getStatusLine().getReasonPhrase() );
-                        }
-
-                        return null;
-                    }
-                } );
-            }
-            catch ( final ClientProtocolException e )
-            {
-                if ( logger.isDebugEnabled() )
-                {
-                    logger.debug( "Failed to read proxied repositories from: 
'" + routerUrl + "'. Reason: "
-                                      + e.getMessage(), e );
-                }
-            }
-            catch ( final IOException e )
-            {
-                if ( logger.isDebugEnabled() )
-                {
-                    logger.debug( "Failed to read proxied repositories from: 
'" + routerUrl + "'. Reason: "
-                                      + e.getMessage(), e );
-                }
-            }
-        }
-
-        return null;
-    }
-
-    private Set<GroupRoute> getGroupMapping( final String routerUrl, final 
ArtifactRouterConfiguration config,
-                                               final HttpClient client )
-  {
-      if ( routerUrl != null && routerUrl.trim().length() > 0 )
-      {
-          if ( logger.isDebugEnabled() )
-          {
-              logger.debug( "Grabbing mirror mappings from: " + 
routerUrl.toString() );
-          }
-          System.out.println( "Grabbing mirror mappings from: " + routerUrl );
-
-          final HttpGet get = new HttpGet( routerUrl );
-          get.addHeader( "Accept", "application/json;q=0.9,*/*;q=0.8" );
-
-          try
-          {
-              return client.execute( get, new 
ResponseHandler<Set<GroupRoute>>()
-              {
-                  public Set<GroupRoute> handleResponse( final HttpResponse 
response )
-                      throws /* ClientProtocolException, */IOException
-                  {
-                      final int statusCode = 
response.getStatusLine().getStatusCode();
-                      if ( statusCode == 200 )
-                      {
-                          InputStream stream = null;
-                          try
-                          {
-                              stream = response.getEntity().getContent();
-                              final ByteArrayOutputStream baos = new 
ByteArrayOutputStream();
-                              IOUtil.copy( stream, baos );
-
-                              String content = null;
-                              final Header contentType = 
response.getFirstHeader( "Content-Type" );
-                              if ( contentType != null )
-                              {
-                                  final HeaderElement[] contentTypeElts = 
contentType.getElements();
-
-                                  if ( contentTypeElts != null )
-                                  {
-                                      for ( final HeaderElement elt : 
contentTypeElts )
-                                      {
-                                          final NameValuePair nv = 
elt.getParameterByName( "charset" );
-                                          if ( nv != null )
-                                          {
-                                              content = new String( 
baos.toByteArray(), nv.getValue() );
-                                          }
-                                      }
-                                  }
-                              }
-
-                              if ( content == null )
-                              {
-                                  content = new String( baos.toByteArray() );
-                              }
-
-                              if ( logger.isDebugEnabled() )
-                              {
-                                  logger.debug( "Response code/message: '" + 
response.getStatusLine().getStatusCode()
-                                      + " " + 
response.getStatusLine().getReasonPhrase() + "'\nContent is:\n\n"
-                                      + content );
-                              }
-
-                              return 
ArtifactRouteSerializer.deserializeGroups( content );
-                          }
-                          catch ( final ArtifactRouterModelException e )
-                          {
-                              logger.error( "Failed to retrieve mirror mapping 
from: " + routerUrl, e );
-                          }
-                          finally
-                          {
-                              close( stream );
-                          }
-                      }
-                      else if ( logger.isDebugEnabled() )
-                      {
-                          logger.debug( "Response: " + 
response.getStatusLine().getStatusCode() + " "
-                              + response.getStatusLine().getReasonPhrase() );
-                      }
-
-                      return null;
-                  }
-              } );
-          }
-          catch ( final ClientProtocolException e )
-          {
-              if ( logger.isDebugEnabled() )
-              {
-                  logger.debug( "Failed to read proxied repositories from: '" 
+ routerUrl + "'. Reason: "
-                                    + e.getMessage(), e );
-              }
-          }
-          catch ( final IOException e )
-          {
-              if ( logger.isDebugEnabled() )
-              {
-                  logger.debug( "Failed to read proxied repositories from: '" 
+ routerUrl + "'. Reason: "
-                                    + e.getMessage(), e );
-              }
-          }
-      }
-
-      return null;
-  }
-
 }

Added: 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/discovery/ArtifactRouterDiscoveryStrategy.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/discovery/ArtifactRouterDiscoveryStrategy.java?rev=1130392&view=auto
==============================================================================
--- 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/discovery/ArtifactRouterDiscoveryStrategy.java
 (added)
+++ 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/discovery/ArtifactRouterDiscoveryStrategy.java
 Thu Jun  2 03:13:03 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.artifact.router.loader.discovery;
+
+/*
+ * 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.ArtifactRouter;
+import org.apache.maven.artifact.router.ArtifactRouterException;
+import org.apache.maven.artifact.router.session.ArtifactRouterSession;
+
+public interface ArtifactRouterDiscoveryStrategy
+{
+
+    ArtifactRouter findRouter( final ArtifactRouterSession session )
+        throws ArtifactRouterException;
+
+}

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

Added: 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/discovery/DNSDiscoveryStrategy.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/discovery/DNSDiscoveryStrategy.java?rev=1130392&view=auto
==============================================================================
--- 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/discovery/DNSDiscoveryStrategy.java
 (added)
+++ 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/loader/discovery/DNSDiscoveryStrategy.java
 Thu Jun  2 03:13:03 2011
@@ -0,0 +1,152 @@
+/*
+ * 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.artifact.router.loader.discovery;
+
+/*
+ * 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.ArtifactRouter;
+import org.apache.maven.artifact.router.ArtifactRouterException;
+import org.apache.maven.artifact.router.conf.RouterSource;
+import org.apache.maven.artifact.router.loader.ArtifactRouterReader;
+import org.apache.maven.artifact.router.session.ArtifactRouterSession;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+@Component( role = ArtifactRouterDiscoveryStrategy.class, hint = "dns" )
+final class DNSDiscoveryStrategy
+    implements ArtifactRouterDiscoveryStrategy
+{
+    
+//    @Requirement
+//    private Logger logger;
+    
+    @Requirement
+    private ArtifactRouterReader routerReader;
+
+    public ArtifactRouter findRouter( final ArtifactRouterSession session )
+        throws ArtifactRouterException
+    {
+        final Map<String, String> env = new HashMap<String, String>();
+        env.put( "java.naming.factory.initial", 
"com.sun.jndi.dns.DnsContextFactory" );
+
+        DirContext jndiContext;
+        try
+        {
+            jndiContext = new InitialDirContext( new Hashtable<String, 
String>( env ) );
+        }
+        catch ( final NamingException e )
+        {
+            throw new ArtifactRouterException( "Failed to initialize JNDI 
context for mirror-router DNS lookups: "
+                            + e.getMessage(), e );
+        }
+
+        InetAddress[] addresses;
+        try
+        {
+            final InetAddress lh = InetAddress.getLocalHost();
+            addresses = InetAddress.getAllByName( lh.getHostName() );
+        }
+        catch ( final UnknownHostException e )
+        {
+            throw new ArtifactRouterException( "Failed to retrieve local 
hostnames for mirror router: " + e.getMessage(),
+                                             e );
+        }
+
+        for ( final InetAddress addr : addresses )
+        {
+            final String hostname = addr.getCanonicalHostName();
+
+            int idx = hostname.indexOf( '.' );
+            if ( idx > -1 )
+            {
+                final String domain = hostname.substring( idx + 1 );
+                final Attributes attrs;
+                try
+                {
+                    attrs = jndiContext.getAttributes( "_maven." + domain, new 
String[] { "TXT" } );
+                }
+                catch ( final NamingException e )
+                {
+                    continue;
+                }
+
+                String txtRecord = null;
+                try
+                {
+                    txtRecord = (String) attrs.get( "TXT" ).get();
+                }
+                catch ( final NamingException e )
+                {
+                }
+
+                if ( txtRecord != null )
+                {
+                    idx = txtRecord.indexOf( "::" );
+                    
+                    String id;
+                    String url;
+                    if ( idx < 0 )
+                    {
+                        id = null;
+                        url = txtRecord;
+                    }
+                    else
+                    {
+                        id = txtRecord.substring( 0, idx );
+                        url = txtRecord.substring( idx + 2 );
+                    }
+                    
+                    return routerReader.loadRouter( new RouterSource( id, url 
), session );
+                }
+            }
+        }
+
+        return null;
+    }
+
+}

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

Added: 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/session/ArtifactRouterSession.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/session/ArtifactRouterSession.java?rev=1130392&view=auto
==============================================================================
--- 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/session/ArtifactRouterSession.java
 (added)
+++ 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/session/ArtifactRouterSession.java
 Thu Jun  2 03:13:03 2011
@@ -0,0 +1,52 @@
+/*
+ * 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.artifact.router.session;
+
+import org.apache.maven.artifact.router.conf.RouterSource;
+import org.apache.maven.settings.Proxy;
+import org.apache.maven.settings.Server;
+
+import java.io.File;
+import java.util.List;
+
+public interface ArtifactRouterSession
+{
+
+    public String[] getDiscoveryStrategies();
+
+    Proxy getProxy( String protocol );
+    
+    Server getServer( String id );
+
+    List<RouterSource> getSources();
+
+    File getRoutesFile();
+
+    boolean isClear();
+
+    boolean isDisabled();
+
+    boolean isOffline();
+
+    boolean isUpdate();
+    
+    
+
+}

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

Added: 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/session/DefaultArtifactRouterSession.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/session/DefaultArtifactRouterSession.java?rev=1130392&view=auto
==============================================================================
--- 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/session/DefaultArtifactRouterSession.java
 (added)
+++ 
maven/maven-3/branches/mirror-group-routing/maven-routem-impl/src/main/java/org/apache/maven/artifact/router/session/DefaultArtifactRouterSession.java
 Thu Jun  2 03:13:03 2011
@@ -0,0 +1,159 @@
+/*
+ * 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.artifact.router.session;
+
+import org.apache.maven.artifact.router.conf.ArtifactRouterConfiguration;
+import org.apache.maven.artifact.router.conf.RouterSource;
+import org.apache.maven.settings.Proxy;
+import org.apache.maven.settings.Server;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+
+public class DefaultArtifactRouterSession
+    implements ArtifactRouterSession
+{
+    
+    private ArtifactRouterConfiguration config;
+    
+    private final List<Server> servers;
+    
+    private final List<Proxy> proxies;
+    
+    public DefaultArtifactRouterSession( final ArtifactRouterConfiguration 
config, final List<Server> servers,
+                                         final List<Proxy> proxies )
+    {
+        this.config = config;
+        this.servers = servers;
+        this.proxies = proxies;
+    }
+
+    public DefaultArtifactRouterSession( ArtifactRouterConfiguration config )
+    {
+        this.config = config;
+        this.servers = Collections.emptyList();
+        this.proxies = Collections.emptyList();
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#getDiscoveryStrategies()
+     */
+    public String[] getDiscoveryStrategies()
+    {
+        return config.getDiscoveryStrategies();
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#getProxy(java.lang.String)
+     */
+    public Proxy getProxy( String protocol )
+    {
+        if ( proxies != null )
+        {
+            for ( Proxy proxy : proxies )
+            {
+                if ( proxy.isActive() && proxy.getProtocol().equals( protocol 
) )
+                {
+                    return proxy;
+                }
+            }
+        }
+        
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#getServer(java.lang.String,
 java.lang.String)
+     */
+    public Server getServer( String id )
+    {
+        if ( servers != null )
+        {
+            for ( Server server : servers )
+            {
+                if ( server.getId().equals( id ) )
+                {
+                    return server;
+                }
+            }
+        }
+        
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#getSources()
+     */
+    public List<RouterSource> getSources()
+    {
+        return config.getSources();
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#getRoutesFile()
+     */
+    public File getRoutesFile()
+    {
+        return config.getRoutesFile();
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#isClear()
+     */
+    public boolean isClear()
+    {
+        return config.isClear();
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#isDisabled()
+     */
+    public boolean isDisabled()
+    {
+        return config.isDisabled();
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#isOffline()
+     */
+    public boolean isOffline()
+    {
+        return config.isOffline();
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see 
org.apache.maven.artifact.router.session.ArtifactRouterSession#isUpdate()
+     */
+    public boolean isUpdate()
+    {
+        return config.isUpdate();
+    }
+
+}

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


Reply via email to