summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-02-14 08:15:52 (EST)
committerEike Stepper2007-02-14 08:15:52 (EST)
commitbe1781906d8d44d2214a978efc2c159b9ff03bef (patch)
tree124829e6bb89b7dc4776bf9e294555ecb5262524
parent7e5afea8556b0301903f8fab004c2c9276d41082 (diff)
downloadcdo-be1781906d8d44d2214a978efc2c159b9ff03bef.zip
cdo-be1781906d8d44d2214a978efc2c159b9ff03bef.tar.gz
cdo-be1781906d8d44d2214a978efc2c159b9ff03bef.tar.bz2
Introduced protocol
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java9
-rw-r--r--plugins/org.eclipse.net4j/.classpath2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java23
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java34
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorDescriptionImpl.java91
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorDescription.java19
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptor.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptorListener.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnectorDescription.java25
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java19
13 files changed, 198 insertions, 58 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
index c4da8d1..39bf62b 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
@@ -19,7 +19,6 @@ import org.eclipse.net4j.transport.Connector;
import org.eclipse.net4j.transport.ProtocolFactory;
import org.eclipse.net4j.transport.tcp.TCPAcceptor;
import org.eclipse.net4j.transport.tcp.TCPAcceptorListener;
-import org.eclipse.net4j.transport.tcp.TCPConnector;
import org.eclipse.net4j.util.Net4jUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.registry.HashMapRegistry;
@@ -268,7 +267,7 @@ public class TCPTransportTest extends AbstractOMTest
acceptor.setReceiveExecutor(Executors.newCachedThreadPool());
acceptor.addAcceptorListener(new TCPAcceptorListener()
{
- public void notifyConnectorAccepted(TCPAcceptor acceptor, TCPConnector connector)
+ public void notifyConnectorAccepted(TCPAcceptor acceptor, Connector connector)
{
connector.addChannelListener(new Connector.ChannelListener()
{
@@ -329,7 +328,7 @@ public class TCPTransportTest extends AbstractOMTest
acceptor.setReceiveExecutor(Executors.newCachedThreadPool());
acceptor.addAcceptorListener(new TCPAcceptorListener()
{
- public void notifyConnectorAccepted(TCPAcceptor acceptor, TCPConnector connector)
+ public void notifyConnectorAccepted(TCPAcceptor acceptor, Connector connector)
{
connector.addChannelListener(new Connector.ChannelListener()
{
@@ -397,7 +396,7 @@ public class TCPTransportTest extends AbstractOMTest
acceptor.setReceiveExecutor(Executors.newCachedThreadPool());
acceptor.addAcceptorListener(new TCPAcceptorListener()
{
- public void notifyConnectorAccepted(TCPAcceptor acceptor, TCPConnector connector)
+ public void notifyConnectorAccepted(TCPAcceptor acceptor, Connector connector)
{
connector.addChannelListener(new Connector.ChannelListener()
{
@@ -479,7 +478,7 @@ public class TCPTransportTest extends AbstractOMTest
acceptor.setReceiveExecutor(Executors.newCachedThreadPool());
acceptor.addAcceptorListener(new TCPAcceptorListener()
{
- public void notifyConnectorAccepted(TCPAcceptor acceptor, TCPConnector connector)
+ public void notifyConnectorAccepted(TCPAcceptor acceptor, Connector connector)
{
connector.addChannelListener(new Connector.ChannelListener()
{
diff --git a/plugins/org.eclipse.net4j/.classpath b/plugins/org.eclipse.net4j/.classpath
index b69fb15..a0d07ad 100644
--- a/plugins/org.eclipse.net4j/.classpath
+++ b/plugins/org.eclipse.net4j/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry excluding="org/eclipse/internal/net4j/component/InactiveException.java|org/eclipse/net4j/transport/ChannelMultiplexer.java|org/eclipse/net4j/util/registry/delegating/AbstractCachingRegistry.java|org/eclipse/net4j/util/registry/delegating/DelegatingRegistry.java|org/eclipse/net4j/util/registry/delegating/HashCacheRegistry.java" kind="src" path="src"/>
+ <classpathentry excluding="org/eclipse/internal/net4j/component/InactiveException.java|org/eclipse/net4j/transport/ChannelMultiplexer.java|org/eclipse/net4j/util/registry/delegating/AbstractCachingRegistry.java|org/eclipse/net4j/util/registry/delegating/DelegatingRegistry.java|org/eclipse/net4j/util/registry/delegating/HashCacheRegistry.java|org/eclipse/net4j/transport/tcp/TCPConnector.java" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
index de9bdc4..8336bb6 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
@@ -10,11 +10,19 @@
**************************************************************************/
package org.eclipse.internal.net4j.transport;
+import static org.eclipse.net4j.transport.Connector.State.CONNECTED;
+import static org.eclipse.net4j.transport.Connector.State.CONNECTING;
+import static org.eclipse.net4j.transport.Connector.State.DISCONNECTED;
+import static org.eclipse.net4j.transport.Connector.State.NEGOTIATING;
+import static org.eclipse.net4j.transport.Connector.Type.CLIENT;
+import static org.eclipse.net4j.transport.Connector.Type.SERVER;
+
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.Connector;
import org.eclipse.net4j.transport.ConnectorCredentials;
+import org.eclipse.net4j.transport.ConnectorDescription;
import org.eclipse.net4j.transport.ConnectorException;
import org.eclipse.net4j.transport.Protocol;
import org.eclipse.net4j.transport.ProtocolFactory;
@@ -39,7 +47,8 @@ import java.util.concurrent.TimeUnit;
/**
* @author Eike Stepper
*/
-public abstract class AbstractConnector extends AbstractLifecycle implements Connector, BufferProvider
+public abstract class AbstractConnector<DESCRIPTION extends ConnectorDescription> extends AbstractLifecycle implements
+ Connector<DESCRIPTION>, BufferProvider
{
private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_CONNECTOR, AbstractConnector.class);
@@ -60,6 +69,8 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
private int connectorID = getNextConnectorID();
+ private DESCRIPTION description;
+
private ConnectorCredentials credentials;
private IRegistry<String, ProtocolFactory> protocolFactoryRegistry;
@@ -187,6 +198,16 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
return getType() == Type.SERVER;
}
+ public DESCRIPTION getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(DESCRIPTION description)
+ {
+ this.description = description;
+ }
+
public ConnectorCredentials getCredentials()
{
return credentials;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
index e48fef9..5c2e7dc 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java
@@ -12,8 +12,9 @@ package org.eclipse.internal.net4j.transport.tcp;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.Channel;
+import org.eclipse.net4j.transport.Connector;
import org.eclipse.net4j.transport.ConnectorException;
-import org.eclipse.net4j.transport.tcp.TCPConnector;
+import org.eclipse.net4j.transport.tcp.TCPConnectorDescription;
import org.eclipse.net4j.transport.tcp.TCPSelector;
import org.eclipse.net4j.transport.tcp.TCPSelectorListener;
import org.eclipse.net4j.util.Net4jUtil;
@@ -35,8 +36,8 @@ import java.util.Queue;
/**
* @author Eike Stepper
*/
-public abstract class AbstractTCPConnector extends AbstractConnector implements TCPConnector,
- TCPSelectorListener.Active
+public abstract class AbstractTCPConnector extends AbstractConnector<TCPConnectorDescription> implements
+ Connector<TCPConnectorDescription>, TCPSelectorListener.Active
{
private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_CONNECTOR, AbstractTCPConnector.class);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java
index f645629..0f91a63 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java
@@ -18,34 +18,10 @@ import java.net.InetSocketAddress;
*/
public class ClientTCPConnectorImpl extends AbstractTCPConnector
{
- private String host;
-
- private int port = DEFAULT_PORT;
-
public ClientTCPConnectorImpl()
{
}
- public String getHost()
- {
- return host;
- }
-
- public void setHost(String host)
- {
- this.host = host;
- }
-
- public int getPort()
- {
- return port;
- }
-
- public void setPort(int port)
- {
- this.port = port;
- }
-
public Type getType()
{
return Type.CLIENT;
@@ -54,16 +30,16 @@ public class ClientTCPConnectorImpl extends AbstractTCPConnector
@Override
public String toString()
{
- return "ClientTCPConnector[" + host + ":" + port + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return "ClientTCPConnector[" + getDescription() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
protected void onAboutToActivate() throws Exception
{
super.onAboutToActivate();
- if (host == null || host.length() == 0)
+ if (getDescription() == null)
{
- throw new IllegalArgumentException("host == null || host.length() == 0"); //$NON-NLS-1$
+ throw new IllegalStateException("getDescription() == null"); //$NON-NLS-1$
}
}
@@ -71,8 +47,8 @@ public class ClientTCPConnectorImpl extends AbstractTCPConnector
protected void onActivate() throws Exception
{
super.onActivate();
- InetAddress addr = InetAddress.getByName(host);
- InetSocketAddress sAddr = new InetSocketAddress(addr, port);
+ InetAddress addr = InetAddress.getByName(getDescription().getHost());
+ InetSocketAddress sAddr = new InetSocketAddress(addr, getDescription().getPort());
getSocketChannel().connect(sAddr);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
index 21ac6b6..16d4256 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java
@@ -12,10 +12,10 @@ package org.eclipse.internal.net4j.transport.tcp;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferProvider;
+import org.eclipse.net4j.transport.Connector;
import org.eclipse.net4j.transport.ProtocolFactory;
import org.eclipse.net4j.transport.tcp.TCPAcceptor;
import org.eclipse.net4j.transport.tcp.TCPAcceptorListener;
-import org.eclipse.net4j.transport.tcp.TCPConnector;
import org.eclipse.net4j.transport.tcp.TCPSelector;
import org.eclipse.net4j.transport.tcp.TCPSelectorListener;
import org.eclipse.net4j.util.Net4jUtil;
@@ -63,7 +63,7 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
private ServerSocketChannel serverSocketChannel;
- private Set<TCPConnector> acceptedConnectors = new HashSet(0);
+ private Set<Connector> acceptedConnectors = new HashSet(0);
/**
* An optional executor to be used by the {@link Channel}s to process their
@@ -158,15 +158,15 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
this.listenPort = listenPort;
}
- public TCPConnector[] getAcceptedConnectors()
+ public Connector[] getAcceptedConnectors()
{
- ArrayList<TCPConnector> result;
+ ArrayList<Connector> result;
synchronized (acceptedConnectors)
{
result = new ArrayList(acceptedConnectors);
}
- return result.toArray(new TCPConnector[result.size()]);
+ return result.toArray(new Connector[result.size()]);
}
public void addAcceptorListener(TCPAcceptorListener listener)
@@ -271,7 +271,7 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
bufferProvider, selector);
}
- protected void fireConnectorAccepted(TCPConnector connector)
+ protected void fireConnectorAccepted(Connector connector)
{
for (TCPAcceptorListener listener : listeners)
{
@@ -329,7 +329,7 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
@Override
protected void onDeactivate() throws Exception
{
- for (TCPConnector connector : getAcceptedConnectors())
+ for (Connector connector : getAcceptedConnectors())
{
LifecycleUtil.deactivate(connector);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorDescriptionImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorDescriptionImpl.java
new file mode 100644
index 0000000..fa4b5ed
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorDescriptionImpl.java
@@ -0,0 +1,91 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.internal.net4j.transport.tcp;
+
+import org.eclipse.net4j.transport.tcp.TCPConnectorDescription;
+import org.eclipse.net4j.util.ObjectUtil;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class TCPConnectorDescriptionImpl implements TCPConnectorDescription, Cloneable, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private String host;
+
+ private int port = DEFAULT_PORT;
+
+ public TCPConnectorDescriptionImpl()
+ {
+ }
+
+ public String getHost()
+ {
+ return host;
+ }
+
+ public void setHost(String host)
+ {
+ this.host = host;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
+
+ public String getDisplayName()
+ {
+ return MessageFormat.format("{0}:{1}", host, port);
+ }
+
+ @Override
+ protected Object clone() throws CloneNotSupportedException
+ {
+ TCPConnectorDescriptionImpl description = new TCPConnectorDescriptionImpl();
+ description.setHost(host);
+ description.setPort(port);
+ return description;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof TCPConnectorDescription)
+ {
+ TCPConnectorDescription that = (TCPConnectorDescription)obj;
+ return this.port == that.getPort() && ObjectUtil.equals(this.host, that.getHost());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return port ^ host.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return getDisplayName();
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
index 8ab36b3..1ebdcd3 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
@@ -35,7 +35,7 @@ import java.util.concurrent.ExecutorService;
*
* @author Eike Stepper
*/
-public interface Connector
+public interface Connector<DESCRIPTION extends ConnectorDescription>
{
@Singleton(stateful = true)
public static final IRegistry<Integer, Connector> REGISTRY = new HashMapRegistry();
@@ -48,9 +48,9 @@ public interface Connector
public boolean isServer();
- public ConnectorCredentials getCredentials();
+ public DESCRIPTION getDescription();
- public void setCredentials(ConnectorCredentials credentials);
+ public ConnectorCredentials getCredentials();
public State getState();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorDescription.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorDescription.java
new file mode 100644
index 0000000..219c4b0
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorDescription.java
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.transport;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ConnectorDescription
+{
+ public String getDisplayName();
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptor.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptor.java
index 0290559..349d89c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptor.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.transport.tcp;
+import org.eclipse.net4j.transport.Connector;
import org.eclipse.net4j.transport.ProtocolFactory;
import org.eclipse.net4j.util.registry.IRegistry;
@@ -28,7 +29,7 @@ public interface TCPAcceptor
public int getPort();
- public TCPConnector[] getAcceptedConnectors();
+ public Connector[] getAcceptedConnectors();
public IRegistry<String, ProtocolFactory> getProtocolFactoryRegistry();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptorListener.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptorListener.java
index e03438b..c075457 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptorListener.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPAcceptorListener.java
@@ -10,10 +10,12 @@
**************************************************************************/
package org.eclipse.net4j.transport.tcp;
+import org.eclipse.net4j.transport.Connector;
+
/**
* @author Eike Stepper
*/
public interface TCPAcceptorListener
{
- public void notifyConnectorAccepted(TCPAcceptor acceptor, TCPConnector connector);
+ public void notifyConnectorAccepted(TCPAcceptor acceptor, Connector connector);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnectorDescription.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnectorDescription.java
new file mode 100644
index 0000000..b1ee32a
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnectorDescription.java
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.transport.tcp;
+
+import org.eclipse.net4j.transport.ConnectorDescription;
+
+/**
+ * @author Eike Stepper
+ */
+public interface TCPConnectorDescription extends ConnectorDescription
+{
+ public static final int DEFAULT_PORT = TCPAcceptor.DEFAULT_PORT;
+
+ public String getHost();
+
+ public int getPort();
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java
index 81d4871..d0a419d 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java
@@ -18,7 +18,7 @@ import org.eclipse.net4j.transport.Protocol;
import org.eclipse.net4j.transport.ProtocolFactory;
import org.eclipse.net4j.transport.Connector.Type;
import org.eclipse.net4j.transport.tcp.TCPAcceptor;
-import org.eclipse.net4j.transport.tcp.TCPConnector;
+import org.eclipse.net4j.transport.tcp.TCPConnectorDescription;
import org.eclipse.net4j.transport.tcp.TCPSelector;
import org.eclipse.internal.net4j.transport.BufferFactoryImpl;
@@ -27,6 +27,7 @@ import org.eclipse.internal.net4j.transport.BufferUtil;
import org.eclipse.internal.net4j.transport.embedded.ClientEmbeddedConnectorImpl;
import org.eclipse.internal.net4j.transport.tcp.ClientTCPConnectorImpl;
import org.eclipse.internal.net4j.transport.tcp.TCPAcceptorImpl;
+import org.eclipse.internal.net4j.transport.tcp.TCPConnectorDescriptionImpl;
import org.eclipse.internal.net4j.transport.tcp.TCPSelectorImpl;
import java.util.ArrayList;
@@ -90,20 +91,24 @@ public final class Net4jUtil
return createTCPAcceptor(bufferProvider, selector, TCPAcceptor.DEFAULT_ADDRESS, TCPAcceptor.DEFAULT_PORT);
}
- public static TCPConnector createTCPConnector(BufferProvider bufferProvider, TCPSelector selector, String host,
- int port)
+ public static Connector<TCPConnectorDescription> createTCPConnector(BufferProvider bufferProvider,
+ TCPSelector selector, String host, int port)
{
+ TCPConnectorDescriptionImpl description = new TCPConnectorDescriptionImpl();
+ description.setHost(host);
+ description.setPort(port);
+
ClientTCPConnectorImpl connector = new ClientTCPConnectorImpl();
connector.setBufferProvider(bufferProvider);
connector.setSelector(selector);
- connector.setHost(host);
- connector.setPort(port);
+ connector.setDescription(description);
return connector;
}
- public static TCPConnector createTCPConnector(BufferProvider bufferProvider, TCPSelector selector, String host)
+ public static Connector<TCPConnectorDescription> createTCPConnector(BufferProvider bufferProvider,
+ TCPSelector selector, String host)
{
- return createTCPConnector(bufferProvider, selector, host, TCPConnector.DEFAULT_PORT);
+ return createTCPConnector(bufferProvider, selector, host, TCPConnectorDescription.DEFAULT_PORT);
}
public static TCPSelector createTCPSelector()