summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-01-20 20:12:30 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-01-20 20:12:30 +0000
commit468c848e6fa977c72c9f614a3dbfe42fb0f24712 (patch)
tree41d1bcaa5c0ccc918d3f4ecb8720ab250d477a0d /sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
parent40927759620bd4e899551941eae0ded45e7e8fb1 (diff)
Update to use as the default the network interface set as default on the machine, which users can change as necessary
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1061488 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java46
1 files changed, 2 insertions, 44 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
index 79bffd3b21..bd44e69867 100644
--- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
+++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
@@ -19,10 +19,7 @@
package org.apache.tuscany.sca.endpoint.hazelcast;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
@@ -30,8 +27,7 @@ import java.util.Properties;
/**
* Utility to parse the config properties.
*
- * bind - ip[:port] - defines the local bind address and port, it defaults to the network interface with the widest
- * class (ie class A is wider than class B) on port 14820 and if that port in use it will try
+ * bind - ip[:port] - defines the local bind address and port, it defaults port 14820 and if that port in use it will try
* incrementing by one till a free port is found.
*
* multicast - groupip:port | off - defines if multicast discovery is used and if so what multicast ip group and port is used
@@ -65,12 +61,7 @@ public class RegistryConfig {
private void init(Properties properties) {
String bindValue = properties.getProperty("bind");
- if (bindValue == null) {
- InetAddress addr = chooseLocalAddress();
- if (addr != null) {
- this.bindAddress = addr.getHostAddress();
- }
- } else {
+ if (bindValue != null) {
if (bindValue.indexOf(":") == -1) {
this.bindAddress = bindValue;
} else {
@@ -143,37 +134,4 @@ public class RegistryConfig {
public String getPassword() {
return password;
}
-
- /**
- * Use the NIC address with the widest class, ie class A instead of class B or C.
- * Bit crude but in a lot of environments a class A address (eg 10.x.x.x) is likely
- * a better choice than a class C address (eg 192.x.x.x). And the alternative to
- * this is to just choose the first address of the first network interface which
- * likely isn't a better choice than this approach.
- */
- protected InetAddress chooseLocalAddress() {
- InetAddress chosen = null;
- try {
- Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
- while (nis.hasMoreElements()) {
- NetworkInterface ni = nis.nextElement();
- Enumeration<InetAddress> ips = ni.getInetAddresses();
- while (ips.hasMoreElements()) {
- InetAddress addr = ips.nextElement();
- if (!addr.isLoopbackAddress()) {
- if (chosen == null) {
- chosen = addr;
- } else {
- if (((int) addr.getAddress()[0] & 0xFF) < ((int) chosen.getAddress()[0] & 0xFF)) {
- chosen = addr;
- }
- }
- }
- }
- }
- } catch (Exception e) {
- // ignore
- }
- return chosen;
- }
}