[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting ...
Ron Sigal
ron_sigal at yahoo.com
Mon Oct 8 16:48:41 EDT 2007
User: rsigal
Date: 07/10/08 16:48:41
Modified: src/main/org/jboss/remoting Tag: remoting_2_2_0_GA
ServerInvoker.java
Log:
JBREM-687: When it replaces host 0.0.0.0 in InvokerLocator with real address (or name), it reregisters with InvokerRegistry.
Revision Changes Path
No revision
No revision
1.52.2.28.4.5 +62 -1 JBossRemoting/src/main/org/jboss/remoting/ServerInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServerInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/ServerInvoker.java,v
retrieving revision 1.52.2.28.4.4
retrieving revision 1.52.2.28.4.5
diff -u -b -r1.52.2.28.4.4 -r1.52.2.28.4.5
--- ServerInvoker.java 23 Aug 2007 03:01:33 -0000 1.52.2.28.4.4
+++ ServerInvoker.java 8 Oct 2007 20:48:40 -0000 1.52.2.28.4.5
@@ -54,6 +54,8 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -67,7 +69,7 @@
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
*
- * @version $Revision: 1.52.2.28.4.4 $
+ * @version $Revision: 1.52.2.28.4.5 $
*/
public abstract class ServerInvoker extends AbstractInvoker implements ServerInvokerMBean
{
@@ -1072,6 +1074,65 @@
}
createServerSocketFactory();
+
+ // need to check invoker locator to see if need to provide binding address (in the case 0.0.0.0 was used)
+ locator = validateLocator(locator);
+ }
+
+ /**
+ * InvokerLocator leaves address 0.0.0.0 unchanged. Once serverBindAddress has been
+ * extracted from the InvokerLocator, it is necessary to transform 0.0.0.0 into an
+ * address that contacted over the network. See JBREM-687.
+ */
+ private InvokerLocator validateLocator(InvokerLocator locator) throws MalformedURLException
+ {
+ InvokerLocator externalLocator = locator;
+
+ String host = locator.getHost();
+ String newHost = null;
+ if(host == null || InvokerLocator.ANY.equals(host))
+ {
+ // now need to get some external bindable address
+ boolean byHost = true;
+ String bindByHost = System.getProperty(InvokerLocator.BIND_BY_HOST, "True");
+ try
+ {
+ byHost = Boolean.parseBoolean(bindByHost);
+ }
+ catch(Exception e)
+ {
+ }
+ try
+ {
+ if(byHost)
+ {
+ newHost = InetAddress.getLocalHost().getHostName();
+ }
+ else
+ {
+ newHost = InetAddress.getLocalHost().getHostAddress();
+ }
+ }
+ catch (UnknownHostException e)
+ {
+ log.debug("Could not get host by name or address.", e);
+ }
+ if(newHost == null)
+ {
+ // now what? step through network interfaces?
+ throw new RuntimeException("Can not determine bindable address for locator (" + locator + ")");
+ }
+
+ // now create new locator with new host
+ String oldLocatorUrl = locator.getLocatorURI();
+ String newLocatorUrl = oldLocatorUrl.replace(InvokerLocator.ANY, newHost);
+ externalLocator = new InvokerLocator(newLocatorUrl);
+
+ // need to update the locator key used in the invoker registry
+ InvokerRegistry.updateServerInvokerLocator(locator, externalLocator);
+ }
+
+ return externalLocator;
}
protected int assignPort() throws IOException
More information about the jboss-cvs-commits
mailing list