activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r375923 - /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
Date Wed, 08 Feb 2006 11:03:05 GMT
Author: rajdavies
Date: Wed Feb  8 03:03:02 2006
New Revision: 375923

URL: http://svn.apache.org/viewcvs?rev=375923&view=rev
Log:
support defining local address and port for a socket - e.g:
ssl://localhost:5666/localhost:60606
where the path (localhost:60606) - defines the local address and local port

For jira issue: AMQ-529

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java?rev=375923&r1=375922&r2=375923&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
Wed Feb  8 03:03:02 2006
@@ -16,6 +16,14 @@
  */
 package org.apache.activemq.transport.tcp;
 
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
 import org.activeio.command.WireFormat;
 import org.apache.activemq.openwire.OpenWireFormat;
 import org.apache.activemq.transport.MutexTransport;
@@ -28,19 +36,11 @@
 import org.apache.activemq.util.IOExceptionSupport;
 import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.util.URISupport;
-
-import javax.net.ServerSocketFactory;
-import javax.net.SocketFactory;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class TcpTransportFactory extends TransportFactory {
-
+    private static final Log log = LogFactory.getLog(TcpTransportFactory.class);
     public TransportServer doBind(String brokerId, final URI location) throws IOException
{
         try {
             Map options = new HashMap(URISupport.parseParamters(location));
@@ -90,8 +90,24 @@
         return transport;
     }
 
-    protected Transport createTransport(URI location, WireFormat wf) throws UnknownHostException,
IOException {
-        return new TcpTransport(wf, location);
+    protected Transport createTransport(URI location,WireFormat wf) throws UnknownHostException,IOException{
+        URI localLocation=null;
+        String path=location.getPath();
+        // see if the path is a local URI location
+        if(path!=null&&path.length()>0){
+            int localPortIndex=path.indexOf(':');
+            try{
+                Integer.parseInt(path.substring((localPortIndex+1),path.length()));
+                String localString=location.getScheme()+ ":/" + path;
+                localLocation=new URI(localString);
+            }catch(Exception e){
+                log.warn("path isn't a valid local location for TcpTransport to use",e);
+            }
+        }
+        if(localLocation!=null){
+            return new TcpTransport(wf,location,localLocation);
+        }
+        return new TcpTransport(wf,location);
     }
 
     protected ServerSocketFactory createServerSocketFactory() {



Mime
View raw message