maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r512346 - in /maven/wagon/trunk: wagon-manager/src/main/java/org/apache/maven/wagon/manager/ wagon-provider-api/src/main/java/org/apache/maven/wagon/ wagon-provider-api/src/main/java/org/apache/maven/wagon/events/ wagon-provider-api/src/mai...
Date Tue, 27 Feb 2007 17:57:45 GMT
Author: jdcasey
Date: Tue Feb 27 09:57:43 2007
New Revision: 512346

URL: http://svn.apache.org/viewvc?view=rev&rev=512346
Log:
Fixing backward compat with 1.0-beta-2, according to clirr checks on wagon-provider-api.

Modified:
    maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/DefaultWagonManager.java
    maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/MirroredWagon.java
    maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/WagonManager.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java

Modified: maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/DefaultWagonManager.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/DefaultWagonManager.java
(original)
+++ maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/DefaultWagonManager.java
Tue Feb 27 09:57:43 2007
@@ -97,6 +97,9 @@
 
     private List listeners = new ArrayList();
 
+    // this is a reverse-mapping of className to hint, to make it simpler to release legacy
wagons. 
+    private Map availableWagonHintsByClassName = new HashMap();
+
     public void addProxy( String protocol, ProxyInfo proxyInfo )
     {
         if ( StringUtils.isEmpty( protocol ) )
@@ -172,7 +175,7 @@
             throw new IllegalArgumentException( Messages
                 .getString( "wagon.manager.repository.mirror.may.not.equal.repository", mirrorId
) ); //$NON-NLS-1$
         }
-
+        
         // repositoryIdToMirror can't point to a mirror repository.
         RepositorySettings repoSettings = getRepositorySettings( repositoryIdToMirror );
         if ( repoSettings.isMirror() )
@@ -279,10 +282,11 @@
     }
 
     public Wagon getWagon( String repositoryId )
-        throws WagonConfigurationException, UnsupportedProtocolException, RepositoryNotFoundException,
+        throws WagonConfigurationException, UnsupportedProtocolException, RepositoryNotFoundException,

         NotOnlineException
     {
         RepositorySettings settings = getRepositorySettings( repositoryId );
+        
         String fetchId = repositoryId;
         boolean hasMirror = settings.hasMirror();
         Wagon wagon = null;
@@ -294,8 +298,9 @@
         }
 
         Repository repository = getRepository( fetchId );
+        
         String protocol = repository.getProtocol();
-
+        
         if ( !protocol.equals( "file" ) && !isOnline() )
         {
             throw new NotOnlineException( "Unable to honor request for " + protocol
@@ -314,8 +319,9 @@
             wagon = getRawWagon( protocol );
         }
 
-        // Configure Wagon
-        wagon.setRepository( repository );
+        // Configure Wagon; make a defensive copy of the repository, in case the wagon alters
it.
+        wagon.setRepository( new Repository( repository.getId(), repository.getUrl() ) );
+        
         wagon.setAuthenticationInfo( settings.getAuthentication() );
 
         ProxyInfo proxy = getProxy( protocol );
@@ -337,7 +343,7 @@
                     + "] from defined configuration.", e );
             }
         }
-
+        
         // Return Wagon
         return wagon;
     }
@@ -405,13 +411,22 @@
         try
         {
             discoveredWagonProviders = searchContainer.lookupMap( Wagon.ROLE );
-            Iterator it = discoveredWagonProviders.keySet().iterator();
+            Iterator it = discoveredWagonProviders.entrySet().iterator();
 
             while ( it.hasNext() )
             {
-                String wagonHint = (String) it.next();
+                Map.Entry entry = (Map.Entry) it.next();
+                
+                String wagonHint = (String) entry.getKey();
+                Object wagonInstance = entry.getValue();
+                
+                getLogger().debug( "Registering wagon for: " + wagonHint );
+                
                 Wagon wagon = (Wagon) searchContainer.lookup( Wagon.ROLE, wagonHint );
-                if ( !StringUtils.equals( wagon.getProtocol(), wagonHint ) )
+                
+                // TODO: Remove this null check once we're clear of backward compat issues
with
+                // wagons <= 1.0-beta-2.
+                if ( wagon.getProtocol() != null && !StringUtils.equals( wagon.getProtocol(),
wagonHint ) )
                 {
                     throw new IllegalStateException( "Plexus Hint [" + wagonHint + "] and
Wagon.getProtocol() ["
                         + wagon.getProtocol() + "] do not agree." );
@@ -422,6 +437,7 @@
                 // TODO: need to restore parent wagons if extension container overwrites
them.
 
                 this.availableWagons.put( wagonHint, searchContainer );
+                this.availableWagonHintsByClassName.put( wagonInstance.getClass().getName(),
wagonHint );
             }
         }
         catch ( ComponentLookupException e )
@@ -469,18 +485,41 @@
                 }
             }
 
-            try
+            String hint = findWagonHint( wagon );
+            
+            if ( hint != null )
             {
-                getWagonContainer( wagon.getProtocol() ).release( wagon );
-            }
-            catch ( ComponentLifecycleException e )
-            {
-                getLogger().warn( "Unable to release wagon (" + wagon.getClass().getName()
+ ")", e );
-            }
-            catch ( UnsupportedProtocolException e )
-            {
-                getLogger().warn( "Unable to release wagon (" + wagon.getClass().getName()
+ "): " + e.getMessage(), e );
+                try
+                {
+                    getWagonContainer( hint ).release( wagon );
+                }
+                catch ( ComponentLifecycleException e )
+                {
+                    getLogger().warn( "Unable to release wagon (" + wagon.getClass().getName()
+ ")", e );
+                }
+                catch ( UnsupportedProtocolException e )
+                {
+                    getLogger().warn( "Unable to release wagon (" + wagon.getClass().getName()
+ "): " + e.getMessage(), e );
+                }
             }
         }
+    }
+
+    private String findWagonHint( Wagon wagon )
+    {
+        String result = null;
+        
+        result = wagon.getProtocol();
+        
+        if ( result == null )
+        {
+            getLogger().debug( "Looking for key of wagon-class: " + wagon.getClass().getName()
+ " in availableWagons:\n" + String.valueOf( availableWagonHintsByClassName ).replace( ',',
'\n' ) );
+            
+            result = (String) availableWagonHintsByClassName.get( wagon.getClass().getName()
);
+        }
+        
+        getLogger().debug( "Found wagon-class: " + wagon.getClass().getName() + " under key:
" + result );
+        
+        return result;
     }
 }

Modified: maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/MirroredWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/MirroredWagon.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/MirroredWagon.java
(original)
+++ maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/MirroredWagon.java
Tue Feb 27 09:57:43 2007
@@ -444,4 +444,12 @@
     {
         return mirrors;
     }
+
+    /**
+     * @deprecated Provided for backward compatibility. Use {@link MirroredWagon#connect()}
instead.
+     */
+    public void openConnection()
+        throws ConnectionException, AuthenticationException
+    {
+    }
 }

Modified: maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/WagonManager.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/WagonManager.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/WagonManager.java
(original)
+++ maven/wagon/trunk/wagon-manager/src/main/java/org/apache/maven/wagon/manager/WagonManager.java
Tue Feb 27 09:57:43 2007
@@ -144,7 +144,7 @@
     Wagon getWagon( String repositoryId )
         throws UnsupportedProtocolException, RepositoryNotFoundException, WagonConfigurationException,
         NotOnlineException;
-
+    
     /**
      * Flag indicating that the interactivity of wagons.
      *  

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
Tue Feb 27 09:57:43 2007
@@ -124,7 +124,7 @@
      * @throws ConnectionException
      * @throws AuthenticationException
      */
-    protected abstract void openConnection()
+    public abstract void openConnection()
         throws ConnectionException, AuthenticationException;
 
     public void connect()
@@ -773,4 +773,17 @@
     {
         throw new UnsupportedOperationException( "The wagon you are using has not implemented
resourceExists()" );
     }
+    
+    /**
+     * Get the protocol for this wagon.
+     * 
+     * NOTE: This requires that the wagon only support 1 protocol.
+     * 
+     * @return the protocol supported by this wagon. By default, return null.
+     */
+    public String getProtocol()
+    {
+        return null;
+    }
+
 }

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java (original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java Tue
Feb 27 09:57:43 2007
@@ -250,4 +250,17 @@
 
     boolean hasTransferListener( TransferListener listener );
 
+    /**
+     * Handle the protocol specific connection opening process.
+     * 
+     * Note: Providers should look for the values in {@link #getRepository()}, {@link #getAuthenticationInfo()},
and
+     * {@link #getProxyInfo()} to properly establish their connection.
+     * 
+     * @deprecated Use {@link Wagon#connect()} instead.
+     * 
+     * @throws ConnectionException
+     * @throws AuthenticationException
+     */
+    void openConnection()
+        throws ConnectionException, AuthenticationException;
 }

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
Tue Feb 27 09:57:43 2007
@@ -122,6 +122,35 @@
     }
 
     /**
+     * Creates new instance of SessionEvent
+     *
+     * @deprecated Use {@link SessionEvent#SessionEvent(Wagon, Repository, int)} instead
+     * @param wagon     <code>Wagon</code> object which created this event
+     * @param eventType the type of the event
+     */
+    public SessionEvent( final Wagon wagon, final int eventType )
+    {
+        super( wagon );
+        this.eventType = eventType;
+    }
+
+    /**
+     * Creates new instance of SessionEvent. Sets event type to <code>SESSION_ERROR_OCCURRED</code>
+     *
+     * @param wagon     <code>Wagon</code> object which created this event
+     * @param repository <code>Repository</code> object that this event belongs
to.
+     * @param exception the exception
+     * @deprecated Use {@link SessionEvent#SessionEvent(Wagon, Repository, Exception)} instead.
+     */
+    public SessionEvent( final Wagon wagon, final Exception exception )
+    {
+        super( wagon );
+        this.exception = exception;
+        this.eventType = SESSION_ERROR_OCCURRED;
+
+    }
+
+    /**
      * @return Returns the type.
      */
     public int getEventType()

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
Tue Feb 27 09:57:43 2007
@@ -98,6 +98,31 @@
     }
 
     /**
+     * @deprecated Use {@link TransferEvent#TransferEvent(Wagon, Repository, Resource, Exception,
int)} instead
+     */
+    public TransferEvent( final Wagon wagon, final Resource resource, final Exception exception,
final int requestType )
+    {
+        this( wagon, resource, TRANSFER_ERROR, requestType );
+
+        this.exception = exception;
+    }
+    
+    /**
+     * @deprecated Use {@link TransferEvent#TransferEvent(Wagon, Repository, Resource, int,
int)} instead
+     */
+    public TransferEvent( final Wagon wagon, final Resource resource, final int eventType,
final int requestType )
+    {
+        super( wagon );
+
+        this.resource = resource;
+
+        setEventType( eventType );
+
+        setRequestType( requestType );
+
+    }
+
+    /**
      * @return Returns the resource.
      */
     public Resource getResource()

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
Tue Feb 27 09:57:43 2007
@@ -51,6 +51,16 @@
     }
 
     /**
+     * @param source The Wagon object on which the WagonEvent initially occurred
+     * @deprecated Use {@link WagonEvent#WagonEvent(Wagon, Repository)} instead.
+     */
+    public WagonEvent( final Wagon source )
+    {
+        super( source );
+        this.repository = new Repository( "unknown" );
+    }
+
+    /**
      * Returns The Wagon object on which the WagonEvent initially occurred
      *
      * @return The Wagon object on which the WagonEvent initially occurred

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java?view=diff&rev=512346&r1=512345&r2=512346
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
Tue Feb 27 09:57:43 2007
@@ -71,6 +71,11 @@
 
     }
 
+    public Repository( String id )
+    {
+        setId( id );
+    }
+
     public Repository( String id, String url )
     {
         setId( id );



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message