synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asan...@apache.org
Subject svn commit: r610362 - /webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/ServerManager.java
Date Wed, 09 Jan 2008 12:17:58 GMT
Author: asankha
Date: Wed Jan  9 04:17:54 2008
New Revision: 610362

URL: http://svn.apache.org/viewvc?rev=610362&view=rev
Log:
SYNAPSE-220

Modified:
    webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/ServerManager.java

Modified: webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/ServerManager.java
URL: http://svn.apache.org/viewvc/webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/ServerManager.java?rev=610362&r1=610361&r2=610362&view=diff
==============================================================================
--- webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/ServerManager.java
(original)
+++ webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/ServerManager.java
Wed Jan  9 04:17:54 2008
@@ -28,12 +28,10 @@
 import org.apache.synapse.core.SynapseEnvironment;
 import org.apache.synapse.config.SynapseConfiguration;
 import org.apache.synapse.util.ClasspathURLStreamHandler;
+import org.apache.synapse.transport.nhttp.NhttpConstants;
 
 import java.io.File;
-import java.net.ServerSocket;
-import java.net.URL;
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
+import java.net.*;
 import java.util.Iterator;
 import java.util.Collection;
 
@@ -176,6 +174,7 @@
         if (trsIn != null) {
 
             int port = 8080;
+            String bindAddress = null;
 
             String strPort = System.getProperty("port");
             if (strPort != null) {
@@ -184,18 +183,28 @@
                     port = new Integer(strPort).intValue();
                 } catch (NumberFormatException e) {
                     // user supplied parameter is not a valid integer. so use the port in
configuration.
-                    log.error("Given port is not a valid integer. Port specified in the configuration
is used for the server.");
-                    port = Integer.parseInt(trsIn.getParameter("port").getValue().toString());
+                    log.error("System property 'port' does not provide a valid integer");
                 }
+            }
 
-            } else {
-                port = Integer.parseInt(trsIn.getParameter("port").getValue().toString());
+            Parameter param = trsIn.getParameter("port");
+            if (param != null && param.getValue() != null) {
+                port = Integer.parseInt(param.getValue().toString());
+            }
+
+            param = trsIn.getParameter(NhttpConstants.BIND_ADDRESS);
+            if (param != null && param.getValue() != null) {
+                bindAddress = ((String) param.getValue()).trim();
             }
 
             while (true) {
                 ServerSocket sock = null;
                 try {
-                    sock = new ServerSocket(port);
+                    if (bindAddress == null) {
+                        sock = new ServerSocket(port);
+                    } else {
+                        sock = new ServerSocket(port, 50, InetAddress.getByName(bindAddress));
+                    }
                     trsIn.getParameter("port").setValue(Integer.toString(port));
                     break;
                 } catch (Exception e) {



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org


Mime
View raw message