Author: remy.maucherat(a)jboss.com
Date: 2008-05-22 13:14:48 -0400 (Thu, 22 May 2008)
New Revision: 637
Modified:
trunk/java/org/jboss/web/cluster/ClusterListener.java
Log:
- Extract connection logic (will be nice when SSL is added).
Modified: trunk/java/org/jboss/web/cluster/ClusterListener.java
===================================================================
--- trunk/java/org/jboss/web/cluster/ClusterListener.java 2008-05-22 17:00:45 UTC (rev
636)
+++ trunk/java/org/jboss/web/cluster/ClusterListener.java 2008-05-22 17:14:48 UTC (rev
637)
@@ -280,12 +280,7 @@
// Automagical JVM route (address + port + engineName)
try {
if (localAddress == null) {
- Socket connection = null;
- if (proxyAddress == null) {
- connection = new Socket(InetAddress.getLocalHost(),
proxyPort);
- } else {
- connection = new Socket(proxyAddress, proxyPort);
- }
+ Socket connection = getConnection();
localAddress = connection.getLocalAddress();
if (localAddress != null) {
IntrospectionUtils.setProperty(connector.getProtocolHandler(), "address",
localAddress.getHostAddress());
@@ -655,11 +650,7 @@
}
// Then, connect to the proxy
- if (proxyAddress == null) {
- connection = new Socket("127.0.0.1", proxyPort);
- } else {
- connection = new Socket(proxyAddress, proxyPort);
- }
+ connection = getConnection();
connection.setSoTimeout(socketTimeout);
String requestLine = command + " " + ((wildcard) ? "*" :
proxyURL) + " HTTP/1.0";
@@ -763,4 +754,17 @@
}
+ /**
+ * Return a connection to the proxy.
+ */
+ protected Socket getConnection()
+ throws IOException {
+ if (proxyAddress == null) {
+ return new Socket(InetAddress.getLocalHost(), proxyPort);
+ } else {
+ return new Socket(proxyAddress, proxyPort);
+ }
+ }
+
+
}
Show replies by date