Author: ron.sigal(a)jboss.com
Date: 2008-06-10 01:47:14 -0400 (Tue, 10 Jun 2008)
New Revision: 4283
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-981: Moved validateLocator() from ServerInvoker to InvokerLocator.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2008-06-10
05:46:06 UTC (rev 4282)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2008-06-10
05:47:14 UTC (rev 4283)
@@ -1127,69 +1127,15 @@
}
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 originalLocator = locator;
+ locator = InvokerLocator.validateLocator(locator);
+
+ // need to update the locator key used in the invoker registry
+ InvokerRegistry.updateServerInvokerLocator(originalLocator, 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.valueOf(bindByHost).booleanValue();
- }
- 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
- externalLocator = new InvokerLocator(locator.protocol,
- newHost,
- locator.getPort(),
- locator.getPath(),
- locator.getParameters());
-
- // need to update the locator key used in the invoker registry
- InvokerRegistry.updateServerInvokerLocator(locator, externalLocator);
- }
-
- return externalLocator;
- }
-
protected int assignPort() throws IOException
{
int port;
Show replies by date