Author: ron.sigal(a)jboss.com
Date: 2008-05-20 21:58:36 -0400 (Tue, 20 May 2008)
New Revision: 4203
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/InvokerLocator.java
Log:
JBREM-980: Moved validateLocator() from ServerInvoker to InvokerLocator.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/InvokerLocator.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/InvokerLocator.java 2008-05-19
03:15:53 UTC (rev 4202)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/InvokerLocator.java 2008-05-21
01:58:36 UTC (rev 4203)
@@ -224,6 +224,58 @@
public static final String DEFAULT_PORT = "defaultPort";
+ /**
+ * 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.
+ */
+ public static 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
+ try
+ {
+ newHost = (String)AccessController.doPrivileged( new
PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ String bindByHost = System.getProperty(InvokerLocator.BIND_BY_HOST,
"True");
+ boolean byHost = Boolean.valueOf(bindByHost).booleanValue();
+ if(byHost)
+ {
+ return InetAddress.getLocalHost().getHostName();
+ }
+ else
+ {
+ return InetAddress.getLocalHost().getHostAddress();
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ log.debug("Could not get host by name or address.", e.getCause());
+ }
+
+ if(newHost == null)
+ {
+ // now what? step through network interfaces?
+ throw new RuntimeException("Can not determine bindable address for
locator (" + locator + ")");
+ }
+
+ externalLocator = new InvokerLocator(locator.protocol, newHost, locator.port,
+ locator.getPath(),
locator.getParameters());
+ }
+
+ return externalLocator;
+ }
+
+
public static void extractHomes(String homeList, List list, int defaultPort)
{
StringTokenizer tok = new StringTokenizer(homeList, "!");
Show replies by date