activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r618656 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: transport/ transport/failover/ transport/fanout/ transport/mock/ transport/vm/ util/
Date Tue, 05 Feb 2008 14:06:46 GMT
Author: rajdavies
Date: Tue Feb  5 06:06:43 2008
New Revision: 618656

URL: http://svn.apache.org/viewvc?rev=618656&view=rev
Log:
add isConnected() flag to a Transport

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/Transport.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFilter.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportSupport.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/fanout/FanoutTransport.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/mock/MockTransport.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceSupport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/Transport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/Transport.java?rev=618656&r1=618655&r2=618656&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/Transport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/Transport.java
Tue Feb  5 06:06:43 2008
@@ -143,6 +143,11 @@
     boolean isDisposed();
     
     /**
+     * @return true if the transport is connected
+     */
+    boolean isConnected();
+    
+    /**
      * reconnect to another location
      * @param uri
      * @throws IOException on failure of if not supported

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFilter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFilter.java?rev=618656&r1=618655&r2=618656&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFilter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFilter.java
Tue Feb  5 06:06:43 2008
@@ -129,6 +129,10 @@
 	public boolean isDisposed() {
 		return next.isDisposed();
 	}
+	
+	public boolean isConnected() {
+        return next.isConnected();
+    }
 
 	public void reconnect(URI uri) throws IOException {
 		next.reconnect(uri);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportSupport.java?rev=618656&r1=618655&r2=618656&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportSupport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportSupport.java
Tue Feb  5 06:06:43 2008
@@ -115,5 +115,9 @@
 	public boolean isDisposed() {
 		return isStopped();
 	}
+	
+	public  boolean isConnected() {
+	    return isStarted();
+	}
 
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=618656&r1=618655&r2=618656&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Tue Feb  5 06:06:43 2008
@@ -57,6 +57,7 @@
 
     private TransportListener transportListener;
     private boolean disposed;
+    private boolean connected;
     private final CopyOnWriteArrayList<URI> uris = new CopyOnWriteArrayList<URI>();
 
     private final Object reconnectMutex = new Object();
@@ -182,6 +183,7 @@
                 failedConnectTransportURI=connectedTransportURI;
                 connectedTransport = null;
                 connectedTransportURI = null;
+                connected=false;
             }
             reconnectTask.wakeup();
         }
@@ -211,6 +213,7 @@
             }
             started = false;
             disposed = true;
+            connected = false;
 
             if (connectedTransport != null) {
                 transportToStop = connectedTransport;
@@ -593,6 +596,7 @@
                             }else {
                                 LOG.info("Successfully reconnected to " + uri);
                             }
+                            connected=true;
                             return false;
                         } catch (Exception e) {
                             failure = e;
@@ -669,14 +673,17 @@
 	   return false;
    }
 
-public boolean isDisposed() {
-	return disposed;
-}
-
-public void reconnect(URI uri) throws IOException {
-	add(new URI[] {uri});
-}
-
-
+    public boolean isDisposed() {
+    	return disposed;
+    }
+    
+    
+    public boolean isConnected() {
+        return connected;
+    }
+    
+    public void reconnect(URI uri) throws IOException {
+    	add(new URI[] {uri});
+    }
 
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/fanout/FanoutTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/fanout/FanoutTransport.java?rev=618656&r1=618655&r2=618656&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/fanout/FanoutTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/fanout/FanoutTransport.java
Tue Feb  5 06:06:43 2008
@@ -56,6 +56,7 @@
 
     private TransportListener transportListener;
     private boolean disposed;
+    private boolean connected;
 
     private final Object reconnectMutex = new Object();
     private final ConnectionStateTracker stateTracker = new ConnectionStateTracker();
@@ -281,6 +282,7 @@
                     restoreTransport(th);
                 }
             }
+            connected=true;
         }
     }
 
@@ -293,6 +295,7 @@
             }
             started = false;
             disposed = true;
+            connected=false;
 
             for (Iterator<FanoutTransportHandler> iter = transports.iterator(); iter.hasNext();)
{
                 FanoutTransportHandler th = iter.next();
@@ -578,4 +581,9 @@
 	public boolean isDisposed() {
 		return disposed;
 	}
+	
+
+    public boolean isConnected() {
+        return connected;
+    }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/mock/MockTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/mock/MockTransport.java?rev=618656&r1=618655&r2=618656&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/mock/MockTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/mock/MockTransport.java
Tue Feb  5 06:06:43 2008
@@ -143,9 +143,12 @@
 	public boolean isDisposed() {
 		return getNext().isDisposed();
 	}
+	
+	public boolean isConnected() {
+       return getNext().isConnected();
+    }
 
 	public void reconnect(URI uri) throws IOException {
 		getNext().reconnect(uri);
 	}
-
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java?rev=618656&r1=618655&r2=618656&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
Tue Feb  5 06:06:43 2008
@@ -17,13 +17,11 @@
 package org.apache.activemq.transport.vm;
 
 import java.io.IOException;
-import java.io.InterruptedIOException;
 import java.net.URI;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.command.Command;
 import org.apache.activemq.thread.Task;
 import org.apache.activemq.thread.TaskRunner;
 import org.apache.activemq.thread.TaskRunnerFactory;
@@ -330,6 +328,10 @@
 
 	public boolean isDisposed() {
 		return disposed;
+	}
+	
+	public boolean isConnected() {
+	    return started;
 	}
 
 	public void reconnect(URI uri) throws IOException {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceSupport.java?rev=618656&r1=618655&r2=618656&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceSupport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceSupport.java
Tue Feb  5 06:06:43 2008
@@ -45,7 +45,13 @@
 
     public void start() throws Exception {
         if (started.compareAndSet(false, true)) {
-            doStart();
+            boolean success = false;
+            try {
+                doStart();
+                success = true;
+            } finally {
+                started.set(success);
+            }
         }
     }
 



Mime
View raw message