maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r792795 - in /maven/maven-2/branches/maven-2.2.x: ./ maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/ maven-core/ maven-core/src/main/java/org/apache/maven/extension/ maven-core/src/main/resources/META-INF/plexus/
Date Fri, 10 Jul 2009 04:01:42 GMT
Author: jdcasey
Date: Fri Jul 10 04:01:41 2009
New Revision: 792795

URL: http://svn.apache.org/viewvc?rev=792795&view=rev
Log:
[MNG-4228] NEED ITS. This implements wagon-impl selection using 'maven.wagon.proto=implname'
form of system property. Switched out extension loading to use component descriptor lookup
instead of component lookup to avoid killing the system in the event that one wagon extension
cannot load. This last is because something has screwed up the loading of the dav+http/s wagons,
and it affects unrelated ITs.

This implementation needs ITs to verify the selectable wagon behavior, and another to verify
the presence and loadability of the dav+http/s wagons.

Modified:
    maven/maven-2/branches/maven-2.2.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
    maven/maven-2/branches/maven-2.2.x/maven-core/pom.xml
    maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java
    maven/maven-2/branches/maven-2.2.x/maven-core/src/main/resources/META-INF/plexus/components.xml
    maven/maven-2/branches/maven-2.2.x/pom.xml

Modified: maven/maven-2/branches/maven-2.2.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=792795&r1=792794&r2=792795&view=diff
==============================================================================
--- maven/maven-2/branches/maven-2.2.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
(original)
+++ maven/maven-2/branches/maven-2.2.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
Fri Jul 10 04:01:41 2009
@@ -46,6 +46,7 @@
 import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.configuration.PlexusConfigurationException;
 import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
@@ -82,6 +83,10 @@
 
     private static final String MAVEN_ARTIFACT_PROPERTIES = "META-INF/maven/org.apache.maven/maven-artifact/pom.properties";
 
+    public static final String DELEGATE_PROPERTY_BASE = "maven.wagon.";
+
+    private static final String WAGON_IMPL_CONFIGURATION = "wagonImpl";
+
     private static int anonymousMirrorIdSeed = 0;
     
     private PlexusContainer container;
@@ -98,7 +103,7 @@
     private Map mirrors = new LinkedHashMap();
 
     /** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration
*/
-    private Map serverConfigurationMap = new HashMap();
+    private Map<String, XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String,
XmlPlexusConfiguration>();
 
     private TransferListener downloadMonitor;
 
@@ -108,7 +113,7 @@
 
     private boolean interactive = true;
 
-    private Map availableWagons = new HashMap();
+    private Map<String, PlexusContainer> availableWagons = new HashMap<String, PlexusContainer>();
 
     private RepositoryPermissions defaultRepositoryPermissions;
 
@@ -125,22 +130,29 @@
             throw new UnsupportedProtocolException( "The repository " + repository + " does
not specify a protocol" );
         }
 
-        Wagon wagon = getWagon( protocol );
+        Wagon wagon = getWagon( protocol, repository.getId() );
 
         configureWagon( wagon, repository.getId(), protocol );
 
         return wagon;
     }
-
+    
     public Wagon getWagon( String protocol )
         throws UnsupportedProtocolException
     {
-        PlexusContainer container = getWagonContainer( protocol );
+        return getWagon( protocol, null );
+    }
+    
+    private Wagon getWagon( String protocol, String repositoryId )
+        throws UnsupportedProtocolException
+    {
+        String hint = getWagonHint( protocol, repositoryId );
+        PlexusContainer container = getWagonContainer( hint );
 
         Wagon wagon;
         try
         {
-            wagon = (Wagon) container.lookup( Wagon.ROLE, protocol );
+            wagon = (Wagon) container.lookup( Wagon.ROLE, hint );
         }
         catch ( ComponentLookupException e1 )
         {
@@ -152,15 +164,47 @@
 
         return wagon;
     }
+    
+    private String getWagonHint( String protocol, String repositoryId )
+    {
+        // TODO: Implement a better way to get the hint, via settings.xml or something.
+        String impl = null;
+        
+        if ( repositoryId != null && serverConfigurationMap.containsKey( repositoryId
) )
+        {
+            XmlPlexusConfiguration config = serverConfigurationMap.get( repositoryId );
+            
+            Xpp3Dom dom = config.getXpp3Dom();
+            for ( int i = 0; i < dom.getChildCount(); i++ )
+            {
+                Xpp3Dom domChild = dom.getChild( i );
+                if ( WAGON_IMPL_CONFIGURATION.equals( domChild.getName() ) )
+                {
+                    impl = domChild.getValue();
+                    dom.removeChild( i );
+                    break;
+                }
+                
+                i++;
+            }
+        }
+        
+        if ( impl == null )
+        {
+            impl = System.getProperty( DELEGATE_PROPERTY_BASE + protocol, null );
+        }
+        
+        return impl == null ? protocol : protocol + "-" + impl;
+    }
 
-    private PlexusContainer getWagonContainer( String protocol )
+    private PlexusContainer getWagonContainer( String hint )
     {
         PlexusContainer container = this.container;
-
-        if ( availableWagons.containsKey( protocol ) )
+        if ( availableWagons.containsKey( hint ) )
         {
-            container = (PlexusContainer) availableWagons.get( protocol );
+            container = availableWagons.get( hint );
         }
+        
         return container;
     }
 
@@ -194,7 +238,7 @@
         Wagon wagon;
         try
         {
-            wagon = getWagon( protocol );
+            wagon = getWagon( protocol, repository.getId() );
 
             configureWagon( wagon, repository );
         }
@@ -308,7 +352,7 @@
         {
             disconnectWagon( wagon );
 
-            releaseWagon( protocol, wagon );
+            releaseWagon( protocol, wagon, repository.getId() );
         }
     }
 
@@ -413,7 +457,7 @@
         Wagon wagon;
         try
         {
-            wagon = getWagon( protocol );
+            wagon = getWagon( protocol, repository.getId() );
 
             configureWagon( wagon, repository );
         }
@@ -595,7 +639,7 @@
         {
             disconnectWagon( wagon );
 
-            releaseWagon( protocol, wagon );
+            releaseWagon( protocol, wagon, repository.getId() );
         }
 
         if ( downloaded )
@@ -749,9 +793,11 @@
     }
 
     private void releaseWagon( String protocol,
-                               Wagon wagon )
+                               Wagon wagon, String repositoryId )
     {
-        PlexusContainer container = getWagonContainer( protocol );
+        String hint = getWagonHint( protocol, repositoryId );
+        
+        PlexusContainer container = getWagonContainer( hint );
         try
         {
             container.release( wagon );
@@ -1015,10 +1061,11 @@
         this.interactive = interactive;
     }
 
+    @SuppressWarnings( "unchecked" )
     public void registerWagons( Collection wagons,
                                 PlexusContainer extensionContainer )
     {
-        for ( Iterator i = wagons.iterator(); i.hasNext(); )
+        for ( Iterator<String> i = wagons.iterator(); i.hasNext(); )
         {
             availableWagons.put( i.next(), extensionContainer );
         }

Modified: maven/maven-2/branches/maven-2.2.x/maven-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/maven-core/pom.xml?rev=792795&r1=792794&r2=792795&view=diff
==============================================================================
--- maven/maven-2/branches/maven-2.2.x/maven-core/pom.xml (original)
+++ maven/maven-2/branches/maven-2.2.x/maven-core/pom.xml Fri Jul 10 04:01:41 2009
@@ -65,6 +65,13 @@
         </exclusion>
       </exclusions>
     </dependency>
+    <!-- NOTE: Listing this last causes it to be the default Wagon implementation
+         when the bare protocol is used to lookup the http/https wagons.
+    -->
+    <dependency>
+      <groupId>org.apache.maven.wagon</groupId>
+      <artifactId>wagon-http-lightweight</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-jdk14</artifactId>

Modified: maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java
URL: http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java?rev=792795&r1=792794&r2=792795&view=diff
==============================================================================
--- maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java
(original)
+++ maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java
Fri Jul 10 04:01:41 2009
@@ -265,17 +265,9 @@
     {
         if ( extensionContainer != null )
         {
-            try
-            {
-                Map wagons = extensionContainer.lookupMap( Wagon.ROLE );
-                getLogger().debug( "Wagons to register: " + wagons.keySet() );
-                wagonManager.registerWagons( wagons.keySet(), extensionContainer );
-            }
-            catch ( ComponentLookupException e )
-            {
-                // no wagons found in the extension
-                getLogger().debug( "No wagons found in the extensions or other internal error:
" + e.getMessage(), e );
-            }
+            Map wagons = extensionContainer.getComponentDescriptorMap( Wagon.ROLE );
+            getLogger().debug( "Wagons to register: " + wagons.keySet() );
+            wagonManager.registerWagons( wagons.keySet(), extensionContainer );
         }
         else
         {

Modified: maven/maven-2/branches/maven-2.2.x/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=792795&r1=792794&r2=792795&view=diff
==============================================================================
--- maven/maven-2/branches/maven-2.2.x/maven-core/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/maven-2/branches/maven-2.2.x/maven-core/src/main/resources/META-INF/plexus/components.xml
Fri Jul 10 04:01:41 2009
@@ -622,5 +622,32 @@
         <_configuration-file>~/.m2/settings-security.xml</_configuration-file>
       </configuration>
     </component>    
+    
+    <component>
+      <role>org.apache.maven.wagon.Wagon</role>
+      <role-hint>http-sun</role-hint>
+      <implementation>org.apache.maven.wagon.providers.http.LightweightHttpWagon</implementation>
+      <instantiation-strategy>per-lookup</instantiation-strategy>
+      <description>LightweightHttpWagon</description>
+    </component>
+    <component>
+      <role>org.apache.maven.wagon.Wagon</role>
+      <role-hint>https-sun</role-hint>
+      <implementation>org.apache.maven.wagon.providers.http.LightweightHttpsWagon</implementation>
+      <instantiation-strategy>per-lookup</instantiation-strategy>
+      <description>LIghtweightHttpsWagon</description>
+    </component>
+    <component>
+      <role>org.apache.maven.wagon.Wagon</role>
+      <role-hint>https-httpclient</role-hint>
+      <implementation>org.apache.maven.wagon.providers.http.HttpWagon</implementation>
+      <instantiation-strategy>per-lookup</instantiation-strategy>
+    </component>
+    <component>
+      <role>org.apache.maven.wagon.Wagon</role>
+      <role-hint>http-httpclient</role-hint>
+      <implementation>org.apache.maven.wagon.providers.http.HttpWagon</implementation>
+      <instantiation-strategy>per-lookup</instantiation-strategy>
+    </component>
   </components>
 </component-set>

Modified: maven/maven-2/branches/maven-2.2.x/pom.xml
URL: http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/pom.xml?rev=792795&r1=792794&r2=792795&view=diff
==============================================================================
--- maven/maven-2/branches/maven-2.2.x/pom.xml (original)
+++ maven/maven-2/branches/maven-2.2.x/pom.xml Fri Jul 10 04:01:41 2009
@@ -451,6 +451,11 @@
         <version>${wagonVersion}</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.maven.wagon</groupId>
+        <artifactId>wagon-http-lightweight</artifactId>
+        <version>${wagonVersion}</version>
+      </dependency>
+      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-jdk14</artifactId>
         <version>1.5.6</version>



Mime
View raw message