summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-02-14 10:44:53 (EST)
committerEike Stepper2007-02-14 10:44:53 (EST)
commit8bbad56489994baf6d8021043735639e7cb70fc0 (patch)
treec69879b44c27efce9379740409516927a91e4eea
parentcfbb439e13c8403f3dc43ddcb068a709ae53b75a (diff)
downloadcdo-8bbad56489994baf6d8021043735639e7cb70fc0.zip
cdo-8bbad56489994baf6d8021043735639e7cb70fc0.tar.gz
cdo-8bbad56489994baf6d8021043735639e7cb70fc0.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java34
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java34
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ClientTCPConnectorImpl.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorDescriptionImpl.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorFactoryImpl.java31
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorDescription.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorFactory.java21
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportContainer.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportUtil.java243
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnectorFactory.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnector.java)10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/user/Credentials.java19
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/user/User.java19
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java6
17 files changed, 363 insertions, 101 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
index 23a813e..e6bff21 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
@@ -22,7 +22,7 @@ import org.eclipse.net4j.util.Net4jUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.registry.IRegistry;
-import org.eclipse.internal.net4j.transport.tcp.AbstractTCPConnector;
+import org.eclipse.internal.net4j.transport.AbstractConnector;
import org.eclipse.internal.net4j.transport.tcp.TCPAcceptorImpl;
import org.eclipse.internal.net4j.transport.tcp.TCPSelectorImpl;
@@ -42,7 +42,7 @@ public class SignalTest extends AbstractOMTest
private TCPAcceptorImpl acceptor;
- private AbstractTCPConnector connector;
+ private AbstractConnector connector;
@Override
protected void setUp() throws Exception
@@ -57,7 +57,7 @@ public class SignalTest extends AbstractOMTest
assertTrue(selector.isActive());
acceptor = (TCPAcceptorImpl)Net4jUtil.createTCPAcceptor(bufferPool, selector);
- connector = (AbstractTCPConnector)Net4jUtil.createTCPConnector(bufferPool, selector, "localhost");
+ connector = (AbstractConnector)Net4jUtil.createTCPConnector(bufferPool, selector, "localhost");
}
@Override
@@ -68,7 +68,7 @@ public class SignalTest extends AbstractOMTest
if (connector != null)
{
connector.disconnect();
- assertFalse(connector.isActive());
+ assertFalse(LifecycleUtil.isActive(connector));
assertFalse(connector.isConnected());
connector = null;
}
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 f36c728..b69fe54 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,6 @@
**************************************************************************/
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 org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.transport.Channel;
@@ -46,8 +41,7 @@ import java.util.concurrent.TimeUnit;
/**
* @author Eike Stepper
*/
-public abstract class AbstractConnector<DESCRIPTION extends ConnectorDescription> extends AbstractLifecycle implements
- Connector<DESCRIPTION>, BufferProvider
+public abstract class AbstractConnector extends AbstractLifecycle implements Connector, BufferProvider
{
private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_CONNECTOR, AbstractConnector.class);
@@ -61,7 +55,7 @@ public abstract class AbstractConnector<DESCRIPTION extends ConnectorDescription
private int connectorID = getNextConnectorID();
- private DESCRIPTION description;
+ private ConnectorDescription description;
private ConnectorCredentials credentials;
@@ -202,12 +196,12 @@ public abstract class AbstractConnector<DESCRIPTION extends ConnectorDescription
return getType() == Type.SERVER;
}
- public DESCRIPTION getDescription()
+ public ConnectorDescription getDescription()
{
return description;
}
- public void setDescription(DESCRIPTION description)
+ public void setDescription(ConnectorDescription description)
{
this.description = description;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java
deleted file mode 100644
index bfbba2e..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.eclipse.internal.net4j.transport;
-
-import org.eclipse.net4j.transport.ProtocolFactory;
-import org.eclipse.net4j.util.registry.HashMapRegistry;
-
-/**
- * @author Eike Stepper
- */
-public final class ClientProtocolFactoryRegistry extends HashMapRegistry<String, ProtocolFactory>
-{
- public void register(ProtocolFactory factory)
- {
- String key = factory.getProtocolID();
- if (containsKey(key))
- {
- throw new IllegalStateException("Duplicate key: " + factory);
- }
-
- put(key, factory);
- }
-
- @Override
- protected ProtocolFactory register(String protocolName, ProtocolFactory factory)
- {
- if (factory.isForClients())
- {
- return super.register(protocolName, factory);
- }
- else
- {
- throw new IllegalArgumentException("Protocol factory is not for clients: " + factory);
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java
deleted file mode 100644
index db291e1..0000000
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.eclipse.internal.net4j.transport;
-
-import org.eclipse.net4j.transport.ProtocolFactory;
-import org.eclipse.net4j.util.registry.HashMapRegistry;
-
-/**
- * @author Eike Stepper
- */
-public final class ServerProtocolFactoryRegistry extends HashMapRegistry<String, ProtocolFactory>
-{
- public void register(ProtocolFactory factory)
- {
- String key = factory.getProtocolID();
- if (containsKey(key))
- {
- throw new IllegalStateException("Duplicate key: " + factory);
- }
-
- put(key, factory);
- }
-
- @Override
- protected ProtocolFactory register(String protocolName, ProtocolFactory factory)
- {
- if (factory.isForServers())
- {
- return super.register(protocolName, factory);
- }
- else
- {
- throw new IllegalArgumentException("Protocol factory is not for servers: " + factory);
- }
- }
-} \ No newline at end of file
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 e0b6803..edf647d 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
@@ -14,7 +14,6 @@ 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.TCPConnectorDescription;
import org.eclipse.net4j.transport.tcp.TCPSelector;
import org.eclipse.net4j.transport.tcp.TCPSelectorListener;
import org.eclipse.net4j.util.Net4jUtil;
@@ -36,8 +35,7 @@ import java.util.Queue;
/**
* @author Eike Stepper
*/
-public abstract class AbstractTCPConnector extends AbstractConnector<TCPConnectorDescription> implements
- Connector<TCPConnectorDescription>, TCPSelectorListener.Active
+public abstract class AbstractTCPConnector extends AbstractConnector implements Connector, 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 0f91a63..de69f94 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
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.internal.net4j.transport.tcp;
+import org.eclipse.net4j.transport.tcp.TCPConnectorDescription;
+
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -47,8 +49,9 @@ public class ClientTCPConnectorImpl extends AbstractTCPConnector
protected void onActivate() throws Exception
{
super.onActivate();
- InetAddress addr = InetAddress.getByName(getDescription().getHost());
- InetSocketAddress sAddr = new InetSocketAddress(addr, getDescription().getPort());
+ TCPConnectorDescription description = (TCPConnectorDescription)getDescription();
+ InetAddress addr = InetAddress.getByName(description.getHost());
+ InetSocketAddress sAddr = new InetSocketAddress(addr, description.getPort());
getSocketChannel().connect(sAddr);
}
}
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
index 5c2701f..5861650 100644
--- 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
@@ -11,6 +11,7 @@
package org.eclipse.internal.net4j.transport.tcp;
import org.eclipse.net4j.transport.tcp.TCPConnectorDescription;
+import org.eclipse.net4j.transport.tcp.TCPConnectorFactory;
import org.eclipse.net4j.util.ObjectUtil;
import java.io.Serializable;
@@ -33,6 +34,11 @@ public class TCPConnectorDescriptionImpl implements TCPConnectorDescription, Clo
this.port = port;
}
+ public String getFactoryID()
+ {
+ return TCPConnectorFactory.ID;
+ }
+
public String getHost()
{
return host;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorFactoryImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorFactoryImpl.java
new file mode 100644
index 0000000..eb0748d
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPConnectorFactoryImpl.java
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * 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.Connector;
+import org.eclipse.net4j.transport.tcp.TCPConnectorFactory;
+
+/**
+ * @author Eike Stepper
+ */
+public class TCPConnectorFactoryImpl implements TCPConnectorFactory
+{
+ public String getID()
+ {
+ return ID;
+ }
+
+ public Connector createConnector()
+ {
+ ClientTCPConnectorImpl connector = new ClientTCPConnectorImpl();
+ return connector;
+ }
+}
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 6d07c5a..50dcc9d 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
@@ -29,7 +29,7 @@ import org.eclipse.internal.net4j.transport.ChannelImpl;
*
* @author Eike Stepper
*/
-public interface Connector<DESCRIPTION extends ConnectorDescription>
+public interface Connector
{
public Integer getID();
@@ -39,7 +39,7 @@ public interface Connector<DESCRIPTION extends ConnectorDescription>
public boolean isServer();
- public DESCRIPTION getDescription();
+ public ConnectorDescription getDescription();
public ConnectorCredentials getCredentials();
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
index 219c4b0..ce27d88 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorDescription.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorDescription.java
@@ -15,5 +15,5 @@ package org.eclipse.net4j.transport;
*/
public interface ConnectorDescription
{
- public String getDisplayName();
+ public String getFactoryID();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorFactory.java
new file mode 100644
index 0000000..3d0b6e6
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorFactory.java
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * 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 ConnectorFactory
+{
+ public String getID();
+
+ public Connector createConnector();
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportContainer.java
index 6e925a0..01be042 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportContainer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportContainer.java
@@ -19,6 +19,8 @@ public interface TransportContainer
{
public BufferPool getBufferPool();
+ public IRegistry<String, ConnectorFactory> getConnectorFactoryRegistry();
+
public IRegistry<ProtocolFactoryID, ProtocolFactory> getProtocolFactoryRegistry();
public IRegistry<Integer, Connector> getConnectorRegistry();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportUtil.java
new file mode 100644
index 0000000..82600c4
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/TransportUtil.java
@@ -0,0 +1,243 @@
+/***************************************************************************
+ * 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;
+
+import org.eclipse.net4j.transport.Connector.Type;
+import org.eclipse.net4j.transport.tcp.TCPAcceptor;
+import org.eclipse.net4j.transport.tcp.TCPConnectorDescription;
+import org.eclipse.net4j.transport.tcp.TCPSelector;
+import org.eclipse.net4j.util.registry.HashMapRegistry;
+import org.eclipse.net4j.util.registry.IRegistry;
+
+import org.eclipse.internal.net4j.transport.BufferFactoryImpl;
+import org.eclipse.internal.net4j.transport.BufferPoolImpl;
+import org.eclipse.internal.net4j.transport.BufferUtil;
+import org.eclipse.internal.net4j.transport.ProtocolFactoryIDImpl;
+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;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+/**
+ * @author Eike Stepper
+ */
+public final class TransportUtil
+{
+ private TransportUtil()
+ {
+ }
+
+ public static BufferProvider createBufferFactory(short bufferCapacity)
+ {
+ return new BufferFactoryImpl(bufferCapacity);
+ }
+
+ public static BufferProvider createBufferFactory()
+ {
+ return new BufferFactoryImpl(BufferUtil.DEFAULT_BUFFER_CAPACITY);
+ }
+
+ public static BufferPool createBufferPool(BufferProvider factory)
+ {
+ return new BufferPoolImpl(factory);
+ }
+
+ public static BufferPool createBufferPool(short bufferCapacity)
+ {
+ return createBufferPool(createBufferFactory(bufferCapacity));
+ }
+
+ public static BufferPool createBufferPool()
+ {
+ return createBufferPool(createBufferFactory());
+ }
+
+ public static ProtocolFactoryID createProtocolFactoryID(Type type, String protocolID)
+ {
+ return new ProtocolFactoryIDImpl(type, protocolID);
+ }
+
+ public static Connector createConnector(TransportContainer container, String connectorFactoryID)
+ {
+ IRegistry<String, ConnectorFactory> registry = container.getConnectorFactoryRegistry();
+ if (registry == null)
+ {
+ return null;
+ }
+
+ ConnectorFactory connectorFactory = registry.get(connectorFactoryID);
+ if (connectorFactory == null)
+ {
+ return null;
+ }
+
+ return connectorFactory.createConnector();
+ }
+
+ public static Connector createEmbeddedConnector(BufferProvider bufferProvider)
+ {
+ ClientEmbeddedConnectorImpl connector = new ClientEmbeddedConnectorImpl();
+ connector.setBufferProvider(bufferProvider);
+ return connector;
+ }
+
+ public static TCPAcceptor createTCPAcceptor(BufferProvider bufferProvider, TCPSelector selector, String address,
+ int port)
+ {
+ TCPAcceptorImpl acceptor = new TCPAcceptorImpl();
+ acceptor.setBufferProvider(bufferProvider);
+ acceptor.setSelector(selector);
+ acceptor.setListenPort(port);
+ acceptor.setListenAddr(address);
+ return acceptor;
+ }
+
+ public static TCPAcceptor createTCPAcceptor(BufferProvider bufferProvider, TCPSelector selector)
+ {
+ return createTCPAcceptor(bufferProvider, selector, TCPAcceptor.DEFAULT_ADDRESS, TCPAcceptor.DEFAULT_PORT);
+ }
+
+ public static Connector createTCPConnector(BufferProvider bufferProvider, TCPSelector selector, String host, int port)
+ {
+ ClientTCPConnectorImpl connector = new ClientTCPConnectorImpl();
+ connector.setBufferProvider(bufferProvider);
+ connector.setSelector(selector);
+ connector.setDescription(new TCPConnectorDescriptionImpl(host, port));
+ return connector;
+ }
+
+ public static Connector createTCPConnector(BufferProvider bufferProvider, TCPSelector selector, String host)
+ {
+ return createTCPConnector(bufferProvider, selector, host, TCPConnectorDescription.DEFAULT_PORT);
+ }
+
+ public static TCPSelector createTCPSelector()
+ {
+ return new TCPSelectorImpl();
+ }
+
+ public static Collection<Channel> getChannels(TransportContainer container, String protocolID, Set<Type> types)
+ {
+ if (types == null)
+ {
+ types = ProtocolFactory.SYMMETRIC;
+ }
+
+ IRegistry<ChannelID, Channel> channelRegistry = container.getChannelRegistry();
+ if (channelRegistry == null)
+ {
+ return null;
+ }
+
+ Collection<Channel> channels = channelRegistry.values();
+ Collection<Channel> result = new ArrayList(channels.size());
+ for (Channel channel : channels)
+ {
+ if (types.contains(channel.getConnector().getType()))
+ {
+ if (protocolID == null || protocolID.length() == 0)
+ {
+ result.add(channel);
+ }
+ else
+ {
+ if (channel.getReceiveHandler() instanceof Protocol)
+ {
+ Protocol protocol = (Protocol)channel.getReceiveHandler();
+ if (protocolID.equals(protocol.getProtocolID()))
+ {
+ result.add(channel);
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static Collection<Channel> getChannels(TransportContainer container, String protocolID)
+ {
+ return getChannels(container, protocolID, null);
+ }
+
+ public static Collection<Channel> getChannels(TransportContainer container, Set<Type> types)
+ {
+ return getChannels(container, null, types);
+ }
+
+ public static Map<Type, IRegistry<ProtocolFactoryID, ProtocolFactory>> createProtocolFactoryRegistries(Set<Type> types)
+ {
+ Map<Type, IRegistry<ProtocolFactoryID, ProtocolFactory>> result = new HashMap();
+ for (Type type : types)
+ {
+ result.put(type, new HashMapRegistry());
+ }
+
+ return result;
+ }
+
+ public static Set<Type> registerProtocolFactory(ProtocolFactory factory,
+ Map<Type, IRegistry<ProtocolFactoryID, ProtocolFactory>> registries)
+ {
+ Set<Type> result = new HashSet();
+ for (Entry<Type, IRegistry<ProtocolFactoryID, ProtocolFactory>> entry : registries.entrySet())
+ {
+ Type type = entry.getKey();
+ IRegistry<ProtocolFactoryID, ProtocolFactory> registry = entry.getValue();
+ if (factory.getConnectorTypes().contains(type))
+ {
+ ProtocolFactoryID id = factory.createID(type);
+ if (!registry.containsKey(id))
+ {
+ registry.put(id, factory);
+ }
+ else
+ {
+ result.add(type);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static Set<Type> deregisterProtocolFactory(ProtocolFactory factory,
+ Map<Type, IRegistry<ProtocolFactoryID, ProtocolFactory>> registries)
+ {
+ Set<Type> result = new HashSet();
+ for (Entry<Type, IRegistry<ProtocolFactoryID, ProtocolFactory>> entry : registries.entrySet())
+ {
+ Type type = entry.getKey();
+ IRegistry<ProtocolFactoryID, ProtocolFactory> registry = entry.getValue();
+ if (factory.getConnectorTypes().contains(type))
+ {
+ ProtocolFactoryID id = factory.createID(type);
+ ProtocolFactory old = registry.remove(id);
+ if (old != null)
+ {
+ result.add(type);
+ }
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnectorFactory.java
index 5365922..e98f8d4 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/tcp/TCPConnectorFactory.java
@@ -10,16 +10,12 @@
**************************************************************************/
package org.eclipse.net4j.transport.tcp;
-import org.eclipse.net4j.transport.Connector;
+import org.eclipse.net4j.transport.ConnectorFactory;
/**
* @author Eike Stepper
*/
-public interface TCPConnector extends Connector
+public interface TCPConnectorFactory extends ConnectorFactory
{
- public static final int DEFAULT_PORT = TCPAcceptor.DEFAULT_PORT;
-
- public int getPort();
-
- public String getHost();
+ public static final String ID = "TCP";
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/user/Credentials.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/user/Credentials.java
new file mode 100644
index 0000000..60a87ac
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/user/Credentials.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.user;
+
+/**
+ * @author Eike Stepper
+ */
+public interface Credentials
+{
+ public String getID();
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/user/User.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/user/User.java
new file mode 100644
index 0000000..9b07af0
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/user/User.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.user;
+
+/**
+ * @author Eike Stepper
+ */
+public interface User
+{
+ public String getID();
+}
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 a119032..86afa5a 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
@@ -106,8 +106,7 @@ public final class Net4jUtil
return createTCPAcceptor(bufferProvider, selector, TCPAcceptor.DEFAULT_ADDRESS, TCPAcceptor.DEFAULT_PORT);
}
- public static Connector<TCPConnectorDescription> createTCPConnector(BufferProvider bufferProvider,
- TCPSelector selector, String host, int port)
+ public static Connector createTCPConnector(BufferProvider bufferProvider, TCPSelector selector, String host, int port)
{
ClientTCPConnectorImpl connector = new ClientTCPConnectorImpl();
connector.setBufferProvider(bufferProvider);
@@ -116,8 +115,7 @@ public final class Net4jUtil
return connector;
}
- public static Connector<TCPConnectorDescription> createTCPConnector(BufferProvider bufferProvider,
- TCPSelector selector, String host)
+ public static Connector createTCPConnector(BufferProvider bufferProvider, TCPSelector selector, String host)
{
return createTCPConnector(bufferProvider, selector, host, TCPConnectorDescription.DEFAULT_PORT);
}