Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2013-10-04 16:49:44 -0400
committerslewis2013-10-04 16:49:44 -0400
commit7406a01b71db879a6609ffee056ed973ae2308ea (patch)
treeab3b0d06cf116a132db34584ea9db7ac4be395bb
parent2ac63d97d78811e72d3671202c6f590a35310de3 (diff)
downloadorg.eclipse.ecf-7406a01b71db879a6609ffee056ed973ae2308ea.tar.gz
org.eclipse.ecf-7406a01b71db879a6609ffee056ed973ae2308ea.tar.xz
org.eclipse.ecf-7406a01b71db879a6609ffee056ed973ae2308ea.zip
Additions to support functionality added via bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418634
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLServerSOContainerGroup.java7
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF2
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroup.java16
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroupFactory.java34
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java17
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java18
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.server.generic/src/org/eclipse/ecf/tests/server/generic/GenericServerContainerGroupFactoryTest.java54
7 files changed, 127 insertions, 21 deletions
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLServerSOContainerGroup.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLServerSOContainerGroup.java
index 96229e2d3..df185998b 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLServerSOContainerGroup.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLServerSOContainerGroup.java
@@ -49,6 +49,13 @@ public class SSLServerSOContainerGroup extends SOContainerGroup implements ISock
this(name, group, port, backlog, null);
}
+ /**
+ * @since 4.4
+ */
+ public SSLServerSOContainerGroup(String name, ThreadGroup group, int port, InetAddress bindAddress) {
+ this(name, group, port, Server.DEFAULT_BACKLOG, bindAddress);
+ }
+
public SSLServerSOContainerGroup(String name, ThreadGroup group, int port) {
this(name, group, port, DEFAULT_BACKLOG);
}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF b/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF
index 514a7fe47..8b2eb863c 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.server.generic;singleton:=true
-Bundle-Version: 6.0.0.qualifier
+Bundle-Version: 7.0.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.server.generic.Activator
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroup.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroup.java
index ee3c48ff0..ffe43df3e 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroup.java
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroup.java
@@ -10,8 +10,7 @@
package org.eclipse.ecf.server.generic;
import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
+import java.net.*;
import java.util.*;
import org.eclipse.ecf.core.*;
import org.eclipse.ecf.core.identity.ID;
@@ -30,8 +29,8 @@ public class GenericServerContainerGroup implements IGenericServerContainerGroup
class GenericServerSOContainerGroup extends TCPServerSOContainerGroup {
- public GenericServerSOContainerGroup(String name, int port) {
- super(name, port);
+ public GenericServerSOContainerGroup(String name, int port, InetAddress bindAddress) {
+ super(name, null, port, bindAddress);
}
public Map getMap() {
@@ -40,7 +39,14 @@ public class GenericServerContainerGroup implements IGenericServerContainerGroup
}
public GenericServerContainerGroup(String hostname, int port, Map defaultContainerProperties) {
- this.serverGroup = new GenericServerSOContainerGroup(hostname, port);
+ this(hostname, port, null, defaultContainerProperties);
+ }
+
+ /**
+ * @since 7.0
+ */
+ public GenericServerContainerGroup(String hostname, int port, InetAddress bindAddress, Map defaultContainerProperties) {
+ this.serverGroup = new GenericServerSOContainerGroup(hostname, port, bindAddress);
this.defaultContainerProperties = defaultContainerProperties;
}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroupFactory.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroupFactory.java
index df593b939..47d8c4cc0 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroupFactory.java
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/GenericServerContainerGroupFactory.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.ecf.server.generic;
+import java.net.InetAddress;
import java.util.*;
import org.eclipse.core.runtime.Assert;
@@ -20,12 +21,17 @@ public class GenericServerContainerGroupFactory implements IGenericServerContain
protected class SCGData {
private String hostname;
private int port;
+ private InetAddress bindAddress;
- public SCGData(String hostname, int port) {
+ /**
+ * @since 7.0
+ */
+ public SCGData(String hostname, int port, InetAddress bindAddress) {
Assert.isNotNull(hostname);
Assert.isTrue(port > 0);
this.hostname = hostname;
this.port = port;
+ this.bindAddress = bindAddress;
}
public String getHostname() {
@@ -48,13 +54,23 @@ public class GenericServerContainerGroupFactory implements IGenericServerContain
public int hashCode() {
return this.hostname.hashCode() ^ this.port;
}
+
+ /**
+ * @since 7.0
+ */
+ public InetAddress getBindAddress() {
+ return bindAddress;
+ }
}
private Hashtable serverContainerGroups = new Hashtable();
- public IGenericServerContainerGroup createContainerGroup(String hostname, int port, Map defaultContainerProperties) throws GenericServerContainerGroupCreateException {
+ /**
+ * @since 7.0
+ */
+ public IGenericServerContainerGroup createContainerGroup(String hostname, int port, InetAddress bindAddress, Map defaultContainerProperties) throws GenericServerContainerGroupCreateException {
synchronized (serverContainerGroups) {
- SCGData scgdata = new SCGData(hostname, port);
+ SCGData scgdata = new SCGData(hostname, port, bindAddress);
if (serverContainerGroups.contains(scgdata))
throw new GenericServerContainerGroupCreateException("Cannot container group hostname=" + hostname + " port=" + port + " already exists"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IGenericServerContainerGroup scg = createGenericServerContainerGroup(scgdata, defaultContainerProperties);
@@ -63,6 +79,10 @@ public class GenericServerContainerGroupFactory implements IGenericServerContain
}
}
+ public IGenericServerContainerGroup createContainerGroup(String hostname, int port, Map defaultContainerProperties) throws GenericServerContainerGroupCreateException {
+ return createContainerGroup(hostname, port, null, defaultContainerProperties);
+ }
+
protected boolean isSSLTransportSpecified(Map defaultContainerProperties) {
boolean sslTransport = false;
if (defaultContainerProperties != null) {
@@ -81,8 +101,8 @@ public class GenericServerContainerGroupFactory implements IGenericServerContain
*/
protected IGenericServerContainerGroup createGenericServerContainerGroup(SCGData scgdata, Map defaultContainerProperties) throws GenericServerContainerGroupCreateException {
if (isSSLTransportSpecified(defaultContainerProperties))
- return new SSLGenericServerContainerGroup(scgdata.getHostname(), scgdata.getPort(), defaultContainerProperties);
- return new GenericServerContainerGroup(scgdata.getHostname(), scgdata.getPort(), defaultContainerProperties);
+ return new SSLGenericServerContainerGroup(scgdata.getHostname(), scgdata.getPort(), scgdata.getBindAddress(), defaultContainerProperties);
+ return new GenericServerContainerGroup(scgdata.getHostname(), scgdata.getPort(), scgdata.getBindAddress(), defaultContainerProperties);
}
public IGenericServerContainerGroup createContainerGroup(String hostname, int port) throws GenericServerContainerGroupCreateException {
@@ -108,7 +128,7 @@ public class GenericServerContainerGroupFactory implements IGenericServerContain
public IGenericServerContainerGroup getContainerGroup(String hostname, int port) {
if (hostname == null)
return null;
- SCGData scgdata = new SCGData(hostname, port);
+ SCGData scgdata = new SCGData(hostname, port, null);
synchronized (serverContainerGroups) {
return (IGenericServerContainerGroup) serverContainerGroups.get(scgdata);
}
@@ -130,7 +150,7 @@ public class GenericServerContainerGroupFactory implements IGenericServerContain
public IGenericServerContainerGroup removeContainerGroup(String hostname, int port) {
if (hostname == null)
return null;
- SCGData scgdata = new SCGData(hostname, port);
+ SCGData scgdata = new SCGData(hostname, port, null);
synchronized (serverContainerGroups) {
return (IGenericServerContainerGroup) serverContainerGroups.remove(scgdata);
}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java
index 930e03247..6db04ecfe 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.ecf.server.generic;
+import java.net.InetAddress;
import java.util.Map;
import org.eclipse.ecf.core.IContainer;
@@ -39,6 +40,22 @@ public interface IGenericServerContainerGroupFactory {
* @param hostname the hostname associated with the new container group. Must not be <code>null</code>.
* @param port the port that the new container group will listen on (once {@link IGenericServerContainerGroup#startListening()}
* is called). Should be a valid tcp port, openable for listening by this process via {@link IGenericServerContainerGroup#startListening()}.
+ * @param bindAddress an InetAddress specifying what the resulting container group will bind the ServerSocket to when {@link IGenericServerContainerGroup#startListening()}
+ * is called. May be <code>null</code>. If <code>null</code> then the ServerSocket binding will occur for any/all available addresses
+ * @param defaultContainerProperties a Map of default properties passed to any IContainer instances created within the resulting group.
+ * @return new generic server container group. Will not return <code>null</code>.
+ * @throws GenericServerContainerGroupCreateException if a container group exists for the given hostname and port combination.
+ *
+ * @see IGenericServerContainerGroup
+ * @since 7.0
+ */
+ public IGenericServerContainerGroup createContainerGroup(String hostname, int port, InetAddress bindAddress, Map defaultContainerProperties) throws GenericServerContainerGroupCreateException;
+
+ /**
+ * Create a new container group given a hostname, port, and a Map of default container properties.
+ * @param hostname the hostname associated with the new container group. Must not be <code>null</code>.
+ * @param port the port that the new container group will listen on (once {@link IGenericServerContainerGroup#startListening()}
+ * is called). Should be a valid tcp port, openable for listening by this process via {@link IGenericServerContainerGroup#startListening()}.
* @param defaultContainerProperties a Map of default properties passed to any IContainer instances created within the resulting group.
* @return new generic server container group. Will not return <code>null</code>.
* @throws GenericServerContainerGroupCreateException if a container group exists for the given hostname and port combination.
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java
index d21ded359..4b8ce4a63 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java
@@ -10,8 +10,7 @@
package org.eclipse.ecf.server.generic;
import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
+import java.net.*;
import java.util.*;
import org.eclipse.ecf.core.*;
import org.eclipse.ecf.core.identity.ID;
@@ -30,8 +29,8 @@ public class SSLGenericServerContainerGroup implements IGenericServerContainerGr
class SSLGenericServerSOContainerGroup extends SSLServerSOContainerGroup {
- public SSLGenericServerSOContainerGroup(String name, int port) {
- super(name, port);
+ public SSLGenericServerSOContainerGroup(String name, int port, InetAddress bindAddress) {
+ super(name, null, port, bindAddress);
}
public Map getMap() {
@@ -39,11 +38,18 @@ public class SSLGenericServerContainerGroup implements IGenericServerContainerGr
}
}
- public SSLGenericServerContainerGroup(String hostname, int port, Map defaultContainerProperties) {
- this.serverGroup = new SSLGenericServerSOContainerGroup(hostname, port);
+ /**
+ * @since 7.0
+ */
+ public SSLGenericServerContainerGroup(String hostname, int port, InetAddress bindAddress, Map defaultContainerProperties) {
+ this.serverGroup = new SSLGenericServerSOContainerGroup(hostname, port, bindAddress);
this.defaultContainerProperties = defaultContainerProperties;
}
+ public SSLGenericServerContainerGroup(String hostname, int port, Map defaultContainerProperties) {
+ this(hostname, port, null, defaultContainerProperties);
+ }
+
private String getHost() {
return serverGroup.getName();
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.server.generic/src/org/eclipse/ecf/tests/server/generic/GenericServerContainerGroupFactoryTest.java b/tests/bundles/org.eclipse.ecf.tests.server.generic/src/org/eclipse/ecf/tests/server/generic/GenericServerContainerGroupFactoryTest.java
index b288f3926..9a161c058 100644
--- a/tests/bundles/org.eclipse.ecf.tests.server.generic/src/org/eclipse/ecf/tests/server/generic/GenericServerContainerGroupFactoryTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.server.generic/src/org/eclipse/ecf/tests/server/generic/GenericServerContainerGroupFactoryTest.java
@@ -9,6 +9,8 @@
******************************************************************************/
package org.eclipse.ecf.tests.server.generic;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.URI;
import org.eclipse.ecf.server.generic.IGenericServerContainerGroup;
@@ -20,12 +22,14 @@ public class GenericServerContainerGroupFactoryTest extends TestCase {
private static final String hostname = "localhost";
private static final int port = 4000;
+ private InetAddress allAddress;
private IGenericServerContainerGroupFactory gscgFactory;
protected void setUp() throws Exception {
super.setUp();
gscgFactory = Activator.getDefault().getGenericServerContainerGroupFactory();
+ allAddress = new InetSocketAddress((InetAddress) null,0).getAddress();
}
protected void tearDown() throws Exception {
@@ -33,8 +37,12 @@ public class GenericServerContainerGroupFactoryTest extends TestCase {
gscgFactory = null;
}
+ protected IGenericServerContainerGroup createContainerGroup(InetAddress bindAddress) throws Exception {
+ return gscgFactory.createContainerGroup(hostname, port, bindAddress, null);
+ }
+
protected IGenericServerContainerGroup createContainerGroup() throws Exception {
- return gscgFactory.createContainerGroup(hostname, port);
+ return createContainerGroup(null);
}
protected void removeContainerGroup() throws Exception {
@@ -42,15 +50,57 @@ public class GenericServerContainerGroupFactoryTest extends TestCase {
}
public void testCreateContainerGroup() throws Exception {
- IGenericServerContainerGroup containerGroup = createContainerGroup();
+ IGenericServerContainerGroup containerGroup = createContainerGroup(null);
+ assertNotNull(containerGroup);
+ URI groupEndpoint = containerGroup.getGroupEndpoint();
+ assertNotNull(groupEndpoint);
+ assertTrue(groupEndpoint.getHost().equals(hostname));
+ assertTrue(groupEndpoint.getPort()==port);
+ removeContainerGroup();
+ }
+
+ public void testCreateContainerGroupListen() throws Exception {
+ IGenericServerContainerGroup containerGroup = createContainerGroup(null);
+ assertNotNull(containerGroup);
+ URI groupEndpoint = containerGroup.getGroupEndpoint();
+ assertNotNull(groupEndpoint);
+ assertTrue(groupEndpoint.getHost().equals(hostname));
+ assertTrue(groupEndpoint.getPort()==port);
+ assertTrue(!containerGroup.isListening());
+ containerGroup.startListening();
+ assertTrue(containerGroup.isListening());
+ containerGroup.stopListening();
+ assertTrue(!containerGroup.isListening());
+ removeContainerGroup();
+ }
+
+
+ public void testCreateContainerGroupWithBindAddress() throws Exception {
+ IGenericServerContainerGroup containerGroup = createContainerGroup(this.allAddress);
+ assertNotNull(containerGroup);
+ URI groupEndpoint = containerGroup.getGroupEndpoint();
+ assertNotNull(groupEndpoint);
+ assertTrue(groupEndpoint.getHost().equals(hostname));
+ assertTrue(groupEndpoint.getPort()==port);
+ removeContainerGroup();
+ }
+
+ public void testCreateContainerGroupWithBindAddressListen() throws Exception {
+ IGenericServerContainerGroup containerGroup = createContainerGroup(this.allAddress);
assertNotNull(containerGroup);
URI groupEndpoint = containerGroup.getGroupEndpoint();
assertNotNull(groupEndpoint);
assertTrue(groupEndpoint.getHost().equals(hostname));
assertTrue(groupEndpoint.getPort()==port);
+ assertTrue(!containerGroup.isListening());
+ containerGroup.startListening();
+ assertTrue(containerGroup.isListening());
+ containerGroup.stopListening();
+ assertTrue(!containerGroup.isListening());
removeContainerGroup();
}
+
public void testGetContainerGroup() throws Exception {
IGenericServerContainerGroup gscg = gscgFactory.getContainerGroup(hostname, port);
assertNull(gscg);

Back to the top