maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ogusa...@apache.org
Subject svn commit: r762494 - in /maven/mercury/trunk: mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/ mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/ mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/ ...
Date Mon, 06 Apr 2009 20:26:48 GMT
Author: ogusakov
Date: Mon Apr  6 20:26:47 2009
New Revision: 762494

URL: http://svn.apache.org/viewvc?rev=762494&view=rev
Log:
added close() implementation to the remoteRepoReaderM2() to correctly stop httpClient daemons

Modified:
    maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Dep.java
    maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java
    maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
    maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
    maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java
    maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryWriterM2.java
    maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
    maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/DefaultDeployer.java
    maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/Deployer.java
    maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/DefaultRetriever.java
    maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java

Modified: maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Dep.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Dep.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Dep.java
(original)
+++ maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Dep.java
Mon Apr  6 20:26:47 2009
@@ -209,6 +209,8 @@
         List<ArtifactMetadata> res =
             _transitive ? db.resolveConflicts( scope, aql, ail, ael )
                             : toArtifactMetadataList( depList );
+            
+        db.close();
 
         if ( Util.isEmpty( res ) )
         {

Modified: maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java
(original)
+++ maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java
Mon Apr  6 20:26:47 2009
@@ -120,6 +120,12 @@
    * @param listener
    */
   public abstract void unRegister( MercuryEventListener listener );
+  
+  /**
+   * release all resources 
+   * 
+   */
+  public abstract void close();
   //-----------------------------------------------------
   //-----------------------------------------------------
 

Modified: maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
(original)
+++ maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
Mon Apr  6 20:26:47 2009
@@ -652,4 +652,10 @@
             _eventManager.getListeners().addAll( eventManager.getListeners() );
 
     }
+    
+    public void close()
+    {
+        if( _reader != null )
+            _reader.close();
+    }
 }

Modified: maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
(original)
+++ maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
Mon Apr  6 20:26:47 2009
@@ -277,6 +277,8 @@
                 DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL,
repos, null, null, null );
 
             List<ArtifactMetadata> res = depBuilder.resolveConflicts( scope, artifacts,
inclusions, exclusions );
+            
+            depBuilder.close();
 
             return res;
         }
@@ -304,6 +306,8 @@
                 DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL,
repos, null, null, null );
 
             MetadataTreeNode res = depBuilder.resolveConflictsAsTree( scope, artifacts, inclusions,
exclusions );
+            
+            depBuilder.close();
 
             return res;
         }

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java
(original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java
Mon Apr  6 20:26:47 2009
@@ -530,7 +530,7 @@
         retriever.setServers( servers );
         
         RetrievalResponse response = retriever.retrieve( request );
-
+        
         if ( response.hasExceptions() )
         {
             // record all bugs on the first artifact as jetty transport does not 
@@ -1104,12 +1104,13 @@
 
     public void close()
     {
-        // TODO Auto-generated method stub
-
+        if( _transport != null )
+            _transport.stop();
     }
 
     public String[] getProtocols()
     {
         return _protocols;
     }
+
 }

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryWriterM2.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryWriterM2.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryWriterM2.java
(original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryWriterM2.java
Mon Apr  6 20:26:47 2009
@@ -126,6 +126,8 @@
   //---------------------------------------------------------------------------------------------------------------
   public void close()
   {
+      if( _transport != null )
+          _transport.stop();
   }
   //---------------------------------------------------------------------------------------------------------------
   public void writeArtifacts( Collection<Artifact> artifacts )

Modified: maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
(original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
Mon Apr  6 20:26:47 2009
@@ -282,6 +282,25 @@
         
         _initialized = true;
     }
+    
+    /**
+     * close all readers is they are started
+     */
+    public void close()
+    {
+        if( ! _initialized )
+            return;
+        
+        try
+        {
+            for( RepositoryReader rr : _repositoryReaders )
+                rr.close();
+        }
+        finally
+        {
+            _initialized = false;
+        }
+    }
 
     // ----------------------------------------------------------------------------------------------------------------------------
     public MetadataResults readVersions( Collection<ArtifactMetadata> query )

Modified: maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/DefaultDeployer.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/DefaultDeployer.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/DefaultDeployer.java
(original)
+++ maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/DefaultDeployer.java
Mon Apr  6 20:26:47 2009
@@ -35,6 +35,8 @@
 import org.apache.maven.mercury.crypto.api.StreamObserverException;
 import org.apache.maven.mercury.crypto.api.StreamObserverFactory;
 import org.apache.maven.mercury.crypto.api.StreamVerifierFactory;
+import org.apache.maven.mercury.logging.IMercuryLogger;
+import org.apache.maven.mercury.logging.MercuryLoggerManager;
 import org.apache.maven.mercury.spi.http.client.DestinationRealmResolver;
 import org.apache.maven.mercury.spi.http.client.FileExchange;
 import org.apache.maven.mercury.spi.http.client.HandshakeExchange;
@@ -51,6 +53,8 @@
  */
 public class DefaultDeployer implements Deployer
 {
+    private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( DefaultDeployer.class
);
+    
     private HttpClient _httpClient;
     private BatchIdGenerator _idGenerator;
     private Set<Server> _servers = new HashSet<Server>();
@@ -84,7 +88,7 @@
         _httpClient = client;
         try
         {
-            if ( _httpClient.isStarted() )
+            if ( !_httpClient.isStarted() )
             {
                 _httpClient.start();
             }
@@ -358,5 +362,24 @@
         }
         return observers;
     }
+    
+    public void stop()
+    {
+        if( _httpClient == null )
+            return;
+        
+        if( _httpClient.isStopped() || _httpClient.isStopping() )
+            return;
+        
+        try
+        {
+            _httpClient.stop();
+        }
+        catch ( Exception e )
+        {
+            LOG.error( e.getMessage() );
+        }
+            
+    }
 
 }

Modified: maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/Deployer.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/Deployer.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/Deployer.java
(original)
+++ maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/deploy/Deployer.java
Mon Apr  6 20:26:47 2009
@@ -36,4 +36,10 @@
      * has occurred.
      */
     void deploy( DeployRequest request, DeployCallback callback );
+    
+    /**
+     * stop and release all resources
+     * @throws Exception 
+     */
+    void stop();
 }

Modified: maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/DefaultRetriever.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/DefaultRetriever.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/DefaultRetriever.java
(original)
+++ maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/DefaultRetriever.java
Mon Apr  6 20:26:47 2009
@@ -34,6 +34,8 @@
 import org.apache.maven.mercury.crypto.api.StreamObserverFactory;
 import org.apache.maven.mercury.crypto.api.StreamVerifierException;
 import org.apache.maven.mercury.crypto.api.StreamVerifierFactory;
+import org.apache.maven.mercury.logging.IMercuryLogger;
+import org.apache.maven.mercury.logging.MercuryLoggerManager;
 import org.apache.maven.mercury.spi.http.client.DestinationRealmResolver;
 import org.apache.maven.mercury.spi.http.client.HttpClientException;
 import org.apache.maven.mercury.transport.api.Binding;
@@ -42,9 +44,10 @@
 
 public class DefaultRetriever implements Retriever
 {
+    private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( DefaultRetriever.class
);
+    
     private HttpClient _httpClient;
     private Set<Server> _servers = new HashSet<Server>();
-    
 
     public DefaultRetriever()
         throws HttpClientException
@@ -55,7 +58,6 @@
         try
         {
             //TODO: What are all the reasons that the httpclient couldn't start up correctly?
-            
             _httpClient.start();
         }
         catch ( Exception e )
@@ -71,7 +73,7 @@
         _httpClient = client;
         try
         {
-            if ( _httpClient.isStarted() )
+            if ( !_httpClient.isStarted() )
             {
                 _httpClient.start();
             }
@@ -337,5 +339,24 @@
         }
         return observers;
     }
+    
+    public void stop()
+    {
+        if( _httpClient == null )
+            return;
+        
+        if( _httpClient.isStopped() || _httpClient.isStopping() )
+            return;
+        
+        try
+        {
+            _httpClient.stop();
+        }
+        catch ( Exception e )
+        {
+            LOG.error( e.getMessage() );
+        }
+            
+    }
 
 }

Modified: maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java?rev=762494&r1=762493&r2=762494&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java
(original)
+++ maven/mercury/trunk/mercury-transport/mercury-transport-http/src/main/java/org/apache/maven/mercury/spi/http/client/retrieve/Retriever.java
Mon Apr  6 20:26:47 2009
@@ -48,4 +48,10 @@
      * @param callback
      */
     void retrieve( RetrievalRequest request, RetrievalCallback callback );
+    
+    /**
+     * stop and release all resources
+     * @throws Exception 
+     */
+    void stop();
 }



Mime
View raw message