summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-27 14:19:36 (EDT)
committerEike Stepper2006-10-27 14:19:36 (EDT)
commit973147137a23cfb368e0d387b9513fdae4ef46b4 (patch)
treedadc84cc98b59b68de65182d5daff2c06a809ceb
parent1ef01a19c081aad82ebe8322fde584ae90ff59ab (diff)
downloadcdo-973147137a23cfb368e0d387b9513fdae4ef46b4.zip
cdo-973147137a23cfb368e0d387b9513fdae4ef46b4.tar.gz
cdo-973147137a23cfb368e0d387b9513fdae4ef46b4.tar.bz2
Added registries for connectors and channels
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/HugeData.java485
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java10
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java20
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java4
-rw-r--r--plugins/org.eclipse.net4j/.options2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java70
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java24
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java87
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java8
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/AbstractTCPConnector.java16
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java46
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPAcceptorImpl.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/package.html2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Buffer.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Channel.java10
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ChannelID.java21
-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/util/BufferOutputStream.java12
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/ChannelOutputStream.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java (renamed from plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jFactory.java)58
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ObjectUtil.java41
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/StringUtil.java1
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractCachingRegistry.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractMappingRegistry.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/IRegistryElement.java2
27 files changed, 736 insertions, 219 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/HugeData.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/HugeData.java
index f2b7650..60cd5d1 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/HugeData.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/HugeData.java
@@ -634,11 +634,11 @@ public final class HugeData
+ NL
+ " {"
+ NL
- + " short channelID = findFreeChannelID();"
+ + " short channelIndex = findFreeChannelIndex();"
+ NL
- + " ChannelImpl channel = createChannel(channelID, protocolID);"
+ + " ChannelImpl channel = createChannel(channelIndex, protocolID);"
+ NL
- + " registerChannelWithPeer(channelID, protocolID);"
+ + " registerChannelWithPeer(channelIndex, protocolID);"
+ NL
+ ""
+ NL
@@ -674,7 +674,7 @@ public final class HugeData
+ NL
+ ""
+ NL
- + " public ChannelImpl createChannel(short channelID, String protocolID)"
+ + " public ChannelImpl createChannel(short channelIndex, String protocolID)"
+ NL
+ " {"
+ NL
@@ -693,87 +693,404 @@ public final class HugeData
+ " {"
+ NL
+ " System.out.println(toString() + \": Opening channel with protocol \" + protocolID);"
- + NL + " }" + NL + "" + NL
- + " ChannelImpl channel = new ChannelImpl(receiveExecutor);" + NL
- + " channel.setChannelID(channelID);" + NL + " channel.setMultiplexer(this);" + NL
- + " channel.setReceiveHandler(protocol);" + NL
- + " channel.addLifecycleListener(channelLifecycleListener);" + NL
- + " addChannel(channel);" + NL + " return channel;" + NL + " }" + NL + "" + NL
- + " public ChannelImpl getChannel(short channelID)" + NL + " {" + NL + " try" + NL
- + " {" + NL + " ChannelImpl channel = channels.get(channelID);" + NL
- + " if (channel == null || channel == NULL_CHANNEL)" + NL + " {" + NL
- + " throw new NullPointerException();" + NL + " }" + NL + "" + NL
- + " return channel;" + NL + " }" + NL + " catch (IndexOutOfBoundsException ex)"
- + NL + " {" + NL
- + " System.out.println(toString() + \": Invalid channelID \" + channelID);" + NL
- + " return null;" + NL + " }" + NL + " }" + NL + "" + NL
- + " protected List<BufferQueue> getChannelBufferQueues()" + NL + " {" + NL
- + " final List<BufferQueue> result = new ArrayList<BufferQueue>();" + NL
- + " synchronized (channels)" + NL + " {" + NL
- + " for (final ChannelImpl channel : channels)" + NL + " {" + NL
- + " if (channel != NULL_CHANNEL)" + NL + " {" + NL
- + " BufferQueue bufferQueue = channel.getSendQueue();" + NL
- + " result.add(bufferQueue);" + NL + " }" + NL + " }" + NL + " }"
- + NL + "" + NL + " return result;" + NL + " }" + NL + "" + NL
- + " protected short findFreeChannelID()" + NL + " {" + NL + " synchronized (channels)"
- + NL + " {" + NL + " int size = channels.size();" + NL
- + " for (short i = 0; i < size; i++)" + NL + " {" + NL
- + " if (channels.get(i) == NULL_CHANNEL)" + NL + " {" + NL
- + " return i;" + NL + " }" + NL + " }" + NL + "" + NL
- + " channels.add(NULL_CHANNEL);" + NL + " return (short)size;" + NL + " }"
- + NL + " }" + NL + "" + NL + " protected void addChannel(ChannelImpl channel)" + NL
- + " {" + NL + " short channelID = channel.getChannelID();" + NL
- + " while (channelID >= channels.size())" + NL + " {" + NL
- + " channels.add(NULL_CHANNEL);" + NL + " }" + NL + "" + NL
- + " channels.set(channelID, channel);" + NL + " }" + NL + "" + NL
- + " protected void removeChannel(ChannelImpl channel)" + NL + " {" + NL
- + " channel.removeLifecycleListener(channelLifecycleListener);" + NL
- + " int channelID = channel.getChannelID();" + NL + "" + NL
- + " System.out.println(toString() + \": Removing channel \" + channelID);" + NL
- + " channels.set(channelID, NULL_CHANNEL);" + NL + " }" + NL + "" + NL
- + " protected Protocol createProtocol(String protocolID)" + NL + " {" + NL
- + " if (protocolID == null || protocolID.length() == 0)" + NL + " {" + NL
- + " return null;" + NL + " }" + NL + "" + NL
- + " IRegistry<String, ProtocolFactory> registry = getProtocolFactoryRegistry();" + NL
- + " if (registry == null)" + NL + " {" + NL + " return null;" + NL + " }"
- + NL + "" + NL + " ProtocolFactory factory = registry.lookup(protocolID);" + NL
- + " if (factory == null)" + NL + " {" + NL + " return null;" + NL + " }" + NL
- + "" + NL + " System.out.println(toString() + \": Creating protocol \" + protocolID);"
- + NL + " return factory.createProtocol();" + NL + " }" + NL + "" + NL
- + " protected void fireChannelOpened(Channel channel)" + NL + " {" + NL
- + " for (ChannelListener listener : channelListeners)" + NL + " {" + NL + " try"
- + NL + " {" + NL + " listener.notifyChannelOpened(channel);" + NL + " }"
- + NL + " catch (Exception ex)" + NL + " {" + NL + " ex.printStackTrace();"
- + NL + " }" + NL + " }" + NL + " }" + NL + "" + NL
- + " protected void fireChannelClosing(Channel channel)" + NL + " {" + NL
- + " for (ChannelListener listener : channelListeners)" + NL + " {" + NL + " try"
- + NL + " {" + NL + " listener.notifyChannelClosing(channel);" + NL + " }"
- + NL + " catch (Exception ex)" + NL + " {" + NL + " ex.printStackTrace();"
- + NL + " }" + NL + " }" + NL + " }" + NL + "" + NL
- + " protected void fireStateChanged(State newState, State oldState)" + NL + " {" + NL
- + " for (StateListener listener : stateListeners)" + NL + " {" + NL + " try"
- + NL + " {" + NL + " listener.notifyStateChanged(this, newState, oldState);"
- + NL + " }" + NL + " catch (Exception ex)" + NL + " {" + NL
- + " ex.printStackTrace();" + NL + " }" + NL + " }" + NL + " }" + NL + ""
- + NL + " @Override" + NL + " protected void onAccessBeforeActivate() throws Exception"
- + NL + " {" + NL + " super.onAccessBeforeActivate();" + NL
- + " if (bufferProvider == null)" + NL + " {" + NL
- + " throw new IllegalStateException(\"bufferProvider == null\");" + NL + " }" + NL
- + "" + NL + " if (protocolFactoryRegistry == null)" + NL + " {" + NL
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " ChannelImpl channel = new ChannelImpl(receiveExecutor);"
+ + NL
+ + " channel.setChannelIndex(channelIndex);"
+ + NL
+ + " channel.setMultiplexer(this);"
+ + NL
+ + " channel.setReceiveHandler(protocol);"
+ + NL
+ + " channel.addLifecycleListener(channelLifecycleListener);"
+ + NL
+ + " addChannel(channel);"
+ + NL
+ + " return channel;"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " public ChannelImpl getChannel(short channelIndex)"
+ + NL
+ + " {"
+ + NL
+ + " try"
+ + NL
+ + " {"
+ + NL
+ + " ChannelImpl channel = channels.get(channelIndex);"
+ + NL
+ + " if (channel == null || channel == NULL_CHANNEL)"
+ + NL
+ + " {"
+ + NL
+ + " throw new NullPointerException();"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " return channel;"
+ + NL
+ + " }"
+ + NL
+ + " catch (IndexOutOfBoundsException ex)"
+ + NL
+ + " {"
+ + NL
+ + " System.out.println(toString() + \": Invalid channelIndex \" + channelIndex);"
+ + NL
+ + " return null;"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected List<BufferQueue> getChannelBufferQueues()"
+ + NL
+ + " {"
+ + NL
+ + " final List<BufferQueue> result = new ArrayList<BufferQueue>();"
+ + NL
+ + " synchronized (channels)"
+ + NL
+ + " {"
+ + NL
+ + " for (final ChannelImpl channel : channels)"
+ + NL
+ + " {"
+ + NL
+ + " if (channel != NULL_CHANNEL)"
+ + NL
+ + " {"
+ + NL
+ + " BufferQueue bufferQueue = channel.getSendQueue();"
+ + NL
+ + " result.add(bufferQueue);"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " return result;"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected short findFreeChannelIndex()"
+ + NL
+ + " {"
+ + NL
+ + " synchronized (channels)"
+ + NL
+ + " {"
+ + NL
+ + " int size = channels.size();"
+ + NL
+ + " for (short i = 0; i < size; i++)"
+ + NL
+ + " {"
+ + NL
+ + " if (channels.get(i) == NULL_CHANNEL)"
+ + NL
+ + " {"
+ + NL
+ + " return i;"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " channels.add(NULL_CHANNEL);"
+ + NL
+ + " return (short)size;"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected void addChannel(ChannelImpl channel)"
+ + NL
+ + " {"
+ + NL
+ + " short channelIndex = channel.getChannelIndex();"
+ + NL
+ + " while (channelIndex >= channels.size())"
+ + NL
+ + " {"
+ + NL
+ + " channels.add(NULL_CHANNEL);"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " channels.set(channelIndex, channel);"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected void removeChannel(ChannelImpl channel)"
+ + NL
+ + " {"
+ + NL
+ + " channel.removeLifecycleListener(channelLifecycleListener);"
+ + NL
+ + " int channelIndex = channel.getChannelIndex();"
+ + NL
+ + ""
+ + NL
+ + " System.out.println(toString() + \": Removing channel \" + channelIndex);"
+ + NL
+ + " channels.set(channelIndex, NULL_CHANNEL);"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected Protocol createProtocol(String protocolID)"
+ + NL
+ + " {"
+ + NL
+ + " if (protocolID == null || protocolID.length() == 0)"
+ + NL
+ + " {"
+ + NL
+ + " return null;"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " IRegistry<String, ProtocolFactory> registry = getProtocolFactoryRegistry();"
+ + NL
+ + " if (registry == null)"
+ + NL
+ + " {"
+ + NL
+ + " return null;"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " ProtocolFactory factory = registry.lookup(protocolID);"
+ + NL
+ + " if (factory == null)"
+ + NL
+ + " {"
+ + NL
+ + " return null;"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " System.out.println(toString() + \": Creating protocol \" + protocolID);"
+ + NL
+ + " return factory.createProtocol();"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected void fireChannelOpened(Channel channel)"
+ + NL
+ + " {"
+ + NL
+ + " for (ChannelListener listener : channelListeners)"
+ + NL
+ + " {"
+ + NL
+ + " try"
+ + NL
+ + " {"
+ + NL
+ + " listener.notifyChannelOpened(channel);"
+ + NL
+ + " }"
+ + NL
+ + " catch (Exception ex)"
+ + NL
+ + " {"
+ + NL
+ + " ex.printStackTrace();"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected void fireChannelClosing(Channel channel)"
+ + NL
+ + " {"
+ + NL
+ + " for (ChannelListener listener : channelListeners)"
+ + NL
+ + " {"
+ + NL
+ + " try"
+ + NL
+ + " {"
+ + NL
+ + " listener.notifyChannelClosing(channel);"
+ + NL
+ + " }"
+ + NL
+ + " catch (Exception ex)"
+ + NL
+ + " {"
+ + NL
+ + " ex.printStackTrace();"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected void fireStateChanged(State newState, State oldState)"
+ + NL
+ + " {"
+ + NL
+ + " for (StateListener listener : stateListeners)"
+ + NL
+ + " {"
+ + NL
+ + " try"
+ + NL
+ + " {"
+ + NL
+ + " listener.notifyStateChanged(this, newState, oldState);"
+ + NL
+ + " }"
+ + NL
+ + " catch (Exception ex)"
+ + NL
+ + " {"
+ + NL
+ + " ex.printStackTrace();"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " @Override"
+ + NL
+ + " protected void onAccessBeforeActivate() throws Exception"
+ + NL
+ + " {"
+ + NL
+ + " super.onAccessBeforeActivate();"
+ + NL
+ + " if (bufferProvider == null)"
+ + NL
+ + " {"
+ + NL
+ + " throw new IllegalStateException(\"bufferProvider == null\");"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " if (protocolFactoryRegistry == null)"
+ + NL
+ + " {"
+ + NL
+ " System.out.println(toString() + \": (INFO) protocolFactoryRegistry == null\");"
- + NL + " }" + NL + "" + NL + " if (receiveExecutor == null)" + NL + " {" + NL
- + " System.out.println(toString() + \": (INFO) receiveExecutor == null\");" + NL
- + " }" + NL + " }" + NL + "" + NL + " @Override" + NL
- + " protected void onActivate() throws Exception" + NL + " {" + NL
- + " super.onActivate();" + NL + " setState(State.CONNECTING);" + NL + " }" + NL + ""
- + NL + " @Override" + NL + " protected void onDeactivate() throws Exception" + NL + " {"
- + NL + " setState(State.DISCONNECTED);" + NL
- + " for (short i = 0; i < channels.size(); i++)" + NL + " {" + NL
- + " ChannelImpl channel = channels.get(i);" + NL + " if (channel != null)" + NL
- + " {" + NL + " LifecycleUtil.deactivate(channel);" + NL + " }" + NL
- + " }" + NL + "" + NL + " channels.clear();" + NL + " super.onDeactivate();" + NL
- + " }" + NL + "" + NL
- + " protected abstract void registerChannelWithPeer(short channelID, String protocolID)"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " if (receiveExecutor == null)"
+ + NL
+ + " {"
+ + NL
+ + " System.out.println(toString() + \": (INFO) receiveExecutor == null\");"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " @Override"
+ + NL
+ + " protected void onActivate() throws Exception"
+ + NL
+ + " {"
+ + NL
+ + " super.onActivate();"
+ + NL
+ + " setState(State.CONNECTING);"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " @Override"
+ + NL
+ + " protected void onDeactivate() throws Exception"
+ + NL
+ + " {"
+ + NL
+ + " setState(State.DISCONNECTED);"
+ + NL
+ + " for (short i = 0; i < channels.size(); i++)"
+ + NL
+ + " {"
+ + NL
+ + " ChannelImpl channel = channels.get(i);"
+ + NL
+ + " if (channel != null)"
+ + NL
+ + " {"
+ + NL
+ + " LifecycleUtil.deactivate(channel);"
+ + NL
+ + " }"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " channels.clear();"
+ + NL
+ + " super.onDeactivate();"
+ + NL
+ + " }"
+ + NL
+ + ""
+ + NL
+ + " protected abstract void registerChannelWithPeer(short channelIndex, String protocolID)"
+ NL + " throws ConnectorException;" + NL + "" + NL + " /**" + NL
+ " * Is registered with each {@link Channel} of this {@link Connector}." + NL
+ " * <p>" + NL + " * " + NL + " * @author Eike Stepper" + NL + " */" + NL
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 9c4f1e7..c6b919a 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
@@ -10,13 +10,13 @@
**************************************************************************/
package org.eclipse.net4j.tests;
-import org.eclipse.net4j.Net4jFactory;
import org.eclipse.net4j.tests.signal.Request1;
import org.eclipse.net4j.tests.signal.Request2;
import org.eclipse.net4j.tests.signal.TestSignalProtocol;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.ProtocolFactory;
+import org.eclipse.net4j.util.Net4jUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.registry.HashMapRegistry;
import org.eclipse.net4j.util.registry.IRegistry;
@@ -46,16 +46,16 @@ public class SignalTest extends AbstractOMTest
protected void setUp() throws Exception
{
super.setUp();
- bufferPool = Net4jFactory.createBufferPool((short)64);
+ bufferPool = Net4jUtil.createBufferPool((short)64);
LifecycleUtil.activate(bufferPool);
assertTrue(LifecycleUtil.isActive(bufferPool));
- selector = (TCPSelectorImpl)Net4jFactory.createTCPSelector();
+ selector = (TCPSelectorImpl)Net4jUtil.createTCPSelector();
selector.activate();
assertTrue(selector.isActive());
- acceptor = (TCPAcceptorImpl)Net4jFactory.createTCPAcceptor(bufferPool, selector);
- connector = (AbstractTCPConnector)Net4jFactory.createTCPConnector(bufferPool, selector,
+ acceptor = (TCPAcceptorImpl)Net4jUtil.createTCPAcceptor(bufferPool, selector);
+ connector = (AbstractTCPConnector)Net4jUtil.createTCPConnector(bufferPool, selector,
"localhost");
}
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 cb71f60..41f0c31 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
@@ -10,7 +10,6 @@
**************************************************************************/
package org.eclipse.net4j.tests;
-import org.eclipse.net4j.Net4jFactory;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.transport.Channel;
@@ -21,6 +20,7 @@ import org.eclipse.net4j.transport.tcp.TCPAcceptorListener;
import org.eclipse.net4j.transport.tcp.TCPConnector;
import org.eclipse.net4j.transport.util.ChannelInputStream;
import org.eclipse.net4j.transport.util.ChannelOutputStream;
+import org.eclipse.net4j.util.Net4jUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.registry.HashCacheRegistry;
import org.eclipse.net4j.util.registry.HashMapRegistry;
@@ -59,16 +59,16 @@ public class TCPTransportTest extends AbstractOMTest
protected void setUp() throws Exception
{
super.setUp();
- bufferPool = Net4jFactory.createBufferPool();
+ bufferPool = Net4jUtil.createBufferPool();
LifecycleUtil.activate(bufferPool);
assertTrue(LifecycleUtil.isActive(bufferPool));
- selector = (TCPSelectorImpl)Net4jFactory.createTCPSelector();
+ selector = (TCPSelectorImpl)Net4jUtil.createTCPSelector();
selector.activate();
assertTrue(selector.isActive());
- acceptor = (TCPAcceptorImpl)Net4jFactory.createTCPAcceptor(bufferPool, selector);
- connector = (AbstractTCPConnector)Net4jFactory.createTCPConnector(bufferPool, selector,
+ acceptor = (TCPAcceptorImpl)Net4jUtil.createTCPAcceptor(bufferPool, selector);
+ connector = (AbstractTCPConnector)Net4jUtil.createTCPConnector(bufferPool, selector,
"localhost");
}
@@ -141,7 +141,7 @@ public class TCPTransportTest extends AbstractOMTest
for (int i = 0; i < 3; i++)
{
Buffer buffer = bufferPool.provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelID());
+ ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelIndex());
byteBuffer.putInt(1970);
channel.handleBuffer(buffer);
}
@@ -164,7 +164,7 @@ public class TCPTransportTest extends AbstractOMTest
for (int i = 0; i < COUNT; i++)
{
Buffer buffer = bufferPool.provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelID());
+ ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelIndex());
byteBuffer.putInt(1970);
channel.handleBuffer(buffer);
}
@@ -192,7 +192,7 @@ public class TCPTransportTest extends AbstractOMTest
for (int i = 0; i < COUNT; i++)
{
Buffer buffer = bufferPool.provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelID());
+ ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelIndex());
byteBuffer.putInt(1970);
channel.handleBuffer(buffer);
}
@@ -220,7 +220,7 @@ public class TCPTransportTest extends AbstractOMTest
for (int i = 0; i < COUNT; i++)
{
Buffer buffer = bufferPool.provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelID());
+ ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelIndex());
byteBuffer.putInt(1970);
channel.handleBuffer(buffer);
}
@@ -246,7 +246,7 @@ public class TCPTransportTest extends AbstractOMTest
for (int i = 0; i < COUNT; i++)
{
Buffer buffer = bufferPool.provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelID());
+ ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelIndex());
byteBuffer.putInt(1970);
channel.handleBuffer(buffer);
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java
index 215d4be..afd05db 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java
@@ -51,10 +51,6 @@ public class TestProtocolFactory extends AbstractProtocolFactory implements Prot
return new TestProtocol(channel);
}
- public void dispose()
- {
- }
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j/.options b/plugins/org.eclipse.net4j/.options
index 2aa7225..d4803f3 100644
--- a/plugins/org.eclipse.net4j/.options
+++ b/plugins/org.eclipse.net4j/.options
@@ -7,7 +7,7 @@ org.eclipse.net4j/debug.registry = true
org.eclipse.net4j/debug.om = true
org.eclipse.net4j/debug.buffer = true
-org.eclipse.net4j/debug.buffer.stream = true
+org.eclipse.net4j/debug.buffer.stream = false
org.eclipse.net4j/debug.channel = true
org.eclipse.net4j/debug.selector = true
org.eclipse.net4j/debug.acceptor = true
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 46853d7..f2873f4 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
@@ -53,6 +53,14 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
}
};
+ private static final int MIN_CONNECTOR_ID = 1;
+
+ private static final int MAX_CONNECTOR_ID = Integer.MAX_VALUE;
+
+ private static int nextConnectorID = MIN_CONNECTOR_ID;
+
+ private int connectorID = getNextConnectorID();
+
private ConnectorCredentials credentials;
private IRegistry<String, ProtocolFactory> protocolFactoryRegistry;
@@ -98,6 +106,11 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
}
+ public Integer getID()
+ {
+ return connectorID;
+ }
+
public abstract void multiplexBuffer(Channel channel);
public ExecutorService getReceiveExecutor()
@@ -204,10 +217,10 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
state = newState;
fireStateChanged(newState, oldState);
-
switch (newState)
{
case DISCONNECTED:
+ REGISTRY.deregister(connectorID);
if (finishedConnecting != null)
{
finishedConnecting.countDown();
@@ -238,6 +251,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
case CONNECTED:
finishedConnecting.countDown(); // Just in case of suspicion
finishedNegotiating.countDown();
+ REGISTRY.register(this);
break;
}
@@ -334,9 +348,9 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
public Channel openChannel(String protocolID) throws ConnectorException
{
- short channelID = findFreeChannelID();
- ChannelImpl channel = createChannel(channelID, protocolID);
- registerChannelWithPeer(channelID, protocolID);
+ short channelIndex = findFreeChannelIndex();
+ ChannelImpl channel = createChannel(channelIndex, protocolID);
+ registerChannelWithPeer(channelIndex, protocolID);
try
{
@@ -354,17 +368,17 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
return channel;
}
- public ChannelImpl createChannel(short channelID, String protocolID)
+ public ChannelImpl createChannel(short channelIndex, String protocolID)
{
ChannelImpl channel = new ChannelImpl(receiveExecutor);
Protocol protocol = createProtocol(protocolID, channel);
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Opening channel " + channelID //$NON-NLS-1$
+ TRACER.trace(toString() + ": Opening channel " + channelIndex //$NON-NLS-1$
+ (protocol == null ? " without protocol" : " with protocol " + protocolID)); //$NON-NLS-1$ //$NON-NLS-2$
}
- channel.setChannelID(channelID);
+ channel.setChannelIndex(channelIndex);
channel.setConnector(this);
channel.setReceiveHandler(protocol);
channel.addLifecycleListener(channelLifecycleListener);
@@ -372,11 +386,11 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
return channel;
}
- public ChannelImpl getChannel(short channelID)
+ public ChannelImpl getChannel(short channelIndex)
{
try
{
- ChannelImpl channel = channels.get(channelID);
+ ChannelImpl channel = channels.get(channelIndex);
if (channel == null || channel == NULL_CHANNEL)
{
throw new NullPointerException();
@@ -388,7 +402,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Invalid channelID " + channelID); //$NON-NLS-1$
+ TRACER.trace(toString() + ": Invalid channelIndex " + channelIndex); //$NON-NLS-1$
}
return null;
@@ -413,7 +427,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
return result;
}
- protected short findFreeChannelID()
+ protected short findFreeChannelIndex()
{
synchronized (channels)
{
@@ -432,25 +446,25 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
protected void addChannel(ChannelImpl channel)
{
- short channelID = channel.getChannelID();
- while (channelID >= channels.size())
+ short channelIndex = channel.getChannelIndex();
+ while (channelIndex >= channels.size())
{
channels.add(NULL_CHANNEL);
}
- channels.set(channelID, channel);
+ channels.set(channelIndex, channel);
}
protected void removeChannel(ChannelImpl channel)
{
channel.removeLifecycleListener(channelLifecycleListener);
- int channelID = channel.getChannelID();
+ int channelIndex = channel.getChannelIndex();
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Removing channel " + channelID); //$NON-NLS-1$
+ TRACER.trace(toString() + ": Removing channel " + channelIndex); //$NON-NLS-1$
}
- channels.set(channelID, NULL_CHANNEL);
+ channels.set(channelIndex, NULL_CHANNEL);
}
protected Protocol createProtocol(String protocolID, Channel channel)
@@ -584,9 +598,29 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
super.onDeactivate();
}
- protected abstract void registerChannelWithPeer(short channelID, String protocolID)
+ protected abstract void registerChannelWithPeer(short channelIndex, String protocolID)
throws ConnectorException;
+ private int getNextConnectorID()
+ {
+ int id = nextConnectorID;
+ if (nextConnectorID == MAX_CONNECTOR_ID)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(toString() + ": ID wrap around"); //$NON-NLS-1$
+ }
+
+ nextConnectorID = MIN_CONNECTOR_ID;
+ }
+ else
+ {
+ ++nextConnectorID;
+ }
+
+ return id;
+ }
+
/**
* Is registered with each {@link Channel} of this {@link Connector}.
* <p>
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java
index b3f3ae4..3f14c60 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractProtocolFactory.java
@@ -36,8 +36,4 @@ public abstract class AbstractProtocolFactory implements ProtocolFactory
{
return isForClients() && isForServers();
}
-
- public void dispose()
- {
- }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
index 3570ed0..bfaed8e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
@@ -41,7 +41,7 @@ public class BufferImpl implements Buffer
private BufferProvider bufferProvider;
- private short channelID;
+ private short channelIndex;
private boolean eos;
@@ -75,14 +75,14 @@ public class BufferImpl implements Buffer
this.bufferProvider = bufferProvider;
}
- public short getChannelID()
+ public short getChannelIndex()
{
if (state == State.INITIAL || state == State.READING_HEADER)
{
throw new IllegalStateException("state == " + state); //$NON-NLS-1$
}
- return channelID;
+ return channelIndex;
}
public short getCapacity()
@@ -120,7 +120,7 @@ public class BufferImpl implements Buffer
{
byteBuffer.clear();
state = State.INITIAL;
- channelID = NO_CHANNEL;
+ channelIndex = NO_CHANNEL;
eos = false;
}
@@ -157,7 +157,7 @@ public class BufferImpl implements Buffer
}
byteBuffer.flip();
- channelID = byteBuffer.getShort();
+ channelIndex = byteBuffer.getShort();
short payloadSize = byteBuffer.getShort();
if (payloadSize < 0)
{
@@ -194,13 +194,13 @@ public class BufferImpl implements Buffer
return byteBuffer;
}
- public ByteBuffer startPutting(short channelID)
+ public ByteBuffer startPutting(short channelIndex)
{
if (state == State.PUTTING)
{
- if (channelID != this.channelID)
+ if (channelIndex != this.channelIndex)
{
- throw new IllegalArgumentException("channelID != this.channelID"); //$NON-NLS-1$
+ throw new IllegalArgumentException("channelIndex != this.channelIndex"); //$NON-NLS-1$
}
}
else if (state != State.INITIAL)
@@ -210,7 +210,7 @@ public class BufferImpl implements Buffer
else
{
state = State.PUTTING;
- this.channelID = channelID;
+ this.channelIndex = channelIndex;
byteBuffer.clear();
byteBuffer.position(BufferImpl.HEADER_SIZE);
@@ -228,9 +228,9 @@ public class BufferImpl implements Buffer
if (state == State.PUTTING)
{
- if (channelID == NO_CHANNEL)
+ if (channelIndex == NO_CHANNEL)
{
- throw new IllegalStateException("channelID == NO_CHANNEL"); //$NON-NLS-1$
+ throw new IllegalStateException("channelIndex == NO_CHANNEL"); //$NON-NLS-1$
}
int payloadSize = byteBuffer.position() - BufferImpl.HEADER_SIZE + EOS_OFFSET;
@@ -246,7 +246,7 @@ public class BufferImpl implements Buffer
}
byteBuffer.flip();
- byteBuffer.putShort(channelID);
+ byteBuffer.putShort(channelIndex);
byteBuffer.putShort((short)payloadSize);
byteBuffer.position(0);
state = State.WRITING;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
index 5aa0842..42e6e78 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ChannelImpl.java
@@ -14,7 +14,9 @@ import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferHandler;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.transport.Channel;
+import org.eclipse.net4j.transport.ChannelID;
import org.eclipse.net4j.transport.Connector;
+import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.concurrent.AsynchronousWorkSerializer;
import org.eclipse.net4j.util.concurrent.SynchronousWorkSerializer;
import org.eclipse.net4j.util.concurrent.WorkSerializer;
@@ -23,6 +25,7 @@ import org.eclipse.net4j.util.om.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.transport.BufferImpl.State;
+import org.eclipse.internal.net4j.transport.tcp.ControlChannelImpl;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -36,7 +39,7 @@ public class ChannelImpl extends AbstractLifecycle implements Channel, BufferPro
private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_CHANNEL,
ChannelImpl.class);
- private short channelID = BufferImpl.NO_CHANNEL;
+ private short channelIndex = BufferImpl.NO_CHANNEL;
private AbstractConnector connector;
@@ -57,19 +60,24 @@ public class ChannelImpl extends AbstractLifecycle implements Channel, BufferPro
this.receiveExecutor = receiveExecutor;
}
- public short getChannelID()
+ public ChannelID getID()
{
- return channelID;
+ return new ChannelIDImpl();
}
- public void setChannelID(short channelID)
+ public short getChannelIndex()
{
- if (channelID == BufferImpl.NO_CHANNEL)
+ return channelIndex;
+ }
+
+ public void setChannelIndex(short channelIndex)
+ {
+ if (channelIndex == BufferImpl.NO_CHANNEL)
{
- throw new IllegalArgumentException("channelID == INVALID_CHANNEL_ID"); //$NON-NLS-1$
+ throw new IllegalArgumentException("channelIndex == INVALID_CHANNEL_ID"); //$NON-NLS-1$
}
- this.channelID = channelID;
+ this.channelIndex = channelIndex;
}
public Connector getConnector()
@@ -171,16 +179,16 @@ public class ChannelImpl extends AbstractLifecycle implements Channel, BufferPro
@Override
public String toString()
{
- return "Channel[" + connector + ", channelID=" + channelID + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return "Channel[" + connector + ", channelIndex=" + channelIndex + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
protected void onAboutToActivate() throws Exception
{
super.onAboutToActivate();
- if (channelID == BufferImpl.NO_CHANNEL)
+ if (channelIndex == BufferImpl.NO_CHANNEL)
{
- throw new IllegalStateException("channelID == INVALID_CHANNEL_ID"); //$NON-NLS-1$
+ throw new IllegalStateException("channelIndex == INVALID_CHANNEL_ID"); //$NON-NLS-1$
}
if (connector == null)
@@ -202,14 +210,69 @@ public class ChannelImpl extends AbstractLifecycle implements Channel, BufferPro
{
receiveSerializer = new AsynchronousWorkSerializer(receiveExecutor);
}
+
+ if (!(this instanceof ControlChannelImpl))
+ {
+ Channel.REGISTRY.register(this);
+ }
}
@Override
protected void onDeactivate() throws Exception
{
+ if (!(this instanceof ControlChannelImpl))
+ {
+ Channel.REGISTRY.deregister(getID());
+ }
+
receiveSerializer = null;
- sendQueue.clear();
- sendQueue = null;
+ if (sendQueue != null)
+ {
+ sendQueue.clear();
+ sendQueue = null;
+ }
+
super.onDeactivate();
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class ChannelIDImpl implements ChannelID
+ {
+ public Connector getConnector()
+ {
+ return connector;
+ }
+
+ public short getChannelIndex()
+ {
+ return channelIndex;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ChannelID)
+ {
+ ChannelID that = (ChannelID)obj;
+ return channelIndex == that.getChannelIndex()
+ && ObjectUtil.equals(connector, that.getConnector());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(connector) ^ channelIndex;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ChannelID[" + connector + ", channelIndex=" + channelIndex + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
index dbd0a48..c1fbcc7 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
@@ -44,12 +44,12 @@ public abstract class AbstractEmbeddedConnector extends AbstractConnector
}
@Override
- protected void registerChannelWithPeer(short channelID, String protocolID)
+ protected void registerChannelWithPeer(short channelIndex, String protocolID)
throws ConnectorException
{
try
{
- ChannelImpl channel = getPeer().createChannel(channelID, protocolID);
+ ChannelImpl channel = getPeer().createChannel(channelIndex, protocolID);
if (channel == null)
{
throw new ConnectorException("Failed to register channel with peer"); //$NON-NLS-1$
@@ -69,8 +69,8 @@ public abstract class AbstractEmbeddedConnector extends AbstractConnector
public void multiplexBuffer(Channel localChannel)
{
- short channelID = localChannel.getChannelID();
- ChannelImpl peerChannel = peer.getChannel(channelID);
+ short channelIndex = localChannel.getChannelIndex();
+ ChannelImpl peerChannel = peer.getChannel(channelIndex);
if (peerChannel == null)
{
throw new IllegalStateException("peerChannel == null"); //$NON-NLS-1$
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 8974e39..6df749f 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
@@ -10,13 +10,13 @@
**************************************************************************/
package org.eclipse.internal.net4j.transport.tcp;
-import org.eclipse.net4j.Net4jFactory;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.ConnectorException;
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;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.ContextTracer;
@@ -148,9 +148,9 @@ public abstract class AbstractTCPConnector extends AbstractConnector implements
ByteBuffer byteBuffer = inputBuffer.startGetting(socketChannel);
if (byteBuffer != null)
{
- short channelID = inputBuffer.getChannelID();
- ChannelImpl channel = channelID == ControlChannelImpl.CONTROL_CHANNEL_ID ? controlChannel
- : getChannel(channelID);
+ short channelIndex = inputBuffer.getChannelIndex();
+ ChannelImpl channel = channelIndex == ControlChannelImpl.CONTROL_CHANNEL_ID ? controlChannel
+ : getChannel(channelIndex);
if (channel != null)
{
channel.handleBufferFromMultiplexer(inputBuffer);
@@ -244,10 +244,10 @@ public abstract class AbstractTCPConnector extends AbstractConnector implements
}
@Override
- protected void registerChannelWithPeer(short channelID, String protocolID)
+ protected void registerChannelWithPeer(short channelIndex, String protocolID)
throws ConnectorException
{
- if (!controlChannel.registerChannel(channelID, protocolID))
+ if (!controlChannel.registerChannel(channelIndex, protocolID))
{
throw new ConnectorException("Failed to register channel with peer"); //$NON-NLS-1$
}
@@ -258,7 +258,7 @@ public abstract class AbstractTCPConnector extends AbstractConnector implements
{
if (isConnected())
{
- controlChannel.deregisterChannel(channel.getChannelID());
+ controlChannel.deregisterChannel(channel.getChannelIndex());
}
super.removeChannel(channel);
@@ -270,7 +270,7 @@ public abstract class AbstractTCPConnector extends AbstractConnector implements
super.onAboutToActivate();
if (selector == null)
{
- selector = Net4jFactory.createTCPSelector();
+ selector = Net4jUtil.createTCPSelector();
LifecycleUtil.activate(selector);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
index 38d2459..850dbcf 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
@@ -48,41 +48,41 @@ public final class ControlChannelImpl extends ChannelImpl
public ControlChannelImpl(AbstractTCPConnector connector)
{
super(connector.getReceiveExecutor());
- setChannelID(CONTROL_CHANNEL_ID);
+ setChannelIndex(CONTROL_CHANNEL_ID);
setConnector(connector);
}
- public boolean registerChannel(short channelID, String protocolID)
+ public boolean registerChannel(short channelIndex, String protocolID)
{
- assertValidChannelID(channelID);
- Synchronizer<Boolean> registration = registrations.correlate(channelID);
+ assertValidChannelIndex(channelIndex);
+ Synchronizer<Boolean> registration = registrations.correlate(channelIndex);
Buffer buffer = provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(CONTROL_CHANNEL_ID);
byteBuffer.put(OPCODE_REGISTRATION);
- byteBuffer.putShort(channelID);
+ byteBuffer.putShort(channelIndex);
BufferUtil.putUTF8(byteBuffer, protocolID);
handleBuffer(buffer);
return registration.get(REGISTRATION_TIMEOUT);
}
- public void deregisterChannel(short channelID)
+ public void deregisterChannel(short channelIndex)
{
- assertValidChannelID(channelID);
+ assertValidChannelIndex(channelIndex);
Buffer buffer = provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(CONTROL_CHANNEL_ID);
byteBuffer.put(OPCODE_DEREGISTRATION);
- byteBuffer.putShort(channelID);
+ byteBuffer.putShort(channelIndex);
handleBuffer(buffer);
}
- private void assertValidChannelID(short channelID)
+ private void assertValidChannelIndex(short channelIndex)
{
- if (channelID <= CONTROL_CHANNEL_ID)
+ if (channelIndex <= CONTROL_CHANNEL_ID)
{
- throw new IllegalArgumentException("channelID <= CONTROL_CHANNEL_ID"); //$NON-NLS-1$
+ throw new IllegalArgumentException("channelIndex <= CONTROL_CHANNEL_ID"); //$NON-NLS-1$
}
}
@@ -96,15 +96,15 @@ public final class ControlChannelImpl extends ChannelImpl
{
case OPCODE_REGISTRATION:
{
- short channelID = byteBuffer.getShort();
- assertValidChannelID(channelID);
+ short channelIndex = byteBuffer.getShort();
+ assertValidChannelIndex(channelIndex);
boolean success = true;
try
{
byte[] handlerFactoryUTF8 = BufferUtil.getByteArray(byteBuffer);
String protocolID = BufferUtil.fromUTF8(handlerFactoryUTF8);
- ChannelImpl channel = ((AbstractTCPConnector)getConnector()).createChannel(channelID,
+ ChannelImpl channel = ((AbstractTCPConnector)getConnector()).createChannel(channelIndex,
protocolID);
if (channel != null)
{
@@ -121,26 +121,26 @@ public final class ControlChannelImpl extends ChannelImpl
success = false;
}
- sendStatus(OPCODE_REGISTRATION_ACK, channelID, success);
+ sendStatus(OPCODE_REGISTRATION_ACK, channelIndex, success);
break;
}
case OPCODE_REGISTRATION_ACK:
{
- short channelID = byteBuffer.getShort();
+ short channelIndex = byteBuffer.getShort();
boolean success = byteBuffer.get() == SUCCESS;
- registrations.put(channelID, success);
+ registrations.put(channelIndex, success);
break;
}
case OPCODE_DEREGISTRATION:
{
- short channelID = byteBuffer.getShort();
- assertValidChannelID(channelID);
+ short channelIndex = byteBuffer.getShort();
+ assertValidChannelIndex(channelIndex);
try
{
- ChannelImpl channel = ((AbstractTCPConnector)getConnector()).getChannel(channelID);
+ ChannelImpl channel = ((AbstractTCPConnector)getConnector()).getChannel(channelIndex);
if (channel != null)
{
channel.deactivate();
@@ -149,7 +149,7 @@ public final class ControlChannelImpl extends ChannelImpl
{
if (TRACER.isEnabled())
{
- TRACER.trace(toString() + ": Invalid channel id: " + channelID); //$NON-NLS-1$
+ TRACER.trace(toString() + ": Invalid channel id: " + channelIndex); //$NON-NLS-1$
}
}
}
@@ -172,12 +172,12 @@ public final class ControlChannelImpl extends ChannelImpl
}
}
- private void sendStatus(byte opcode, short channelID, boolean status)
+ private void sendStatus(byte opcode, short channelIndex, boolean status)
{
Buffer buffer = provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(CONTROL_CHANNEL_ID);
byteBuffer.put(opcode);
- byteBuffer.putShort(channelID);
+ byteBuffer.putShort(channelIndex);
byteBuffer.put(status ? SUCCESS : FAILURE);
handleBuffer(buffer);
}
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 04b5a67..b0ba67c 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
@@ -10,7 +10,6 @@
**************************************************************************/
package org.eclipse.internal.net4j.transport.tcp;
-import org.eclipse.net4j.Net4jFactory;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.transport.BufferProvider;
import org.eclipse.net4j.transport.ProtocolFactory;
@@ -19,6 +18,7 @@ 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;
import org.eclipse.net4j.util.lifecycle.AbstractLifecycle;
import org.eclipse.net4j.util.lifecycle.LifecycleListener;
import org.eclipse.net4j.util.lifecycle.LifecycleNotifier;
@@ -311,7 +311,7 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
if (selector == null)
{
- selector = Net4jFactory.createTCPSelector();
+ selector = Net4jUtil.createTCPSelector();
LifecycleUtil.activate(selector);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/package.html b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/package.html
index dcbc0f3..4090603 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/package.html
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/package.html
@@ -18,7 +18,7 @@
The main package of the Net4j API. Contains sub packages for the different layers
of Net4j as well as a collection of {@link org.eclipse.net4j.util utility} packages and a
-{@link org.eclipse.net4j.Net4jFactory factory} class for the creation various
+{@link org.eclipse.net4j.util.Net4jUtil factory} class for the creation various
instances of the transport layer interfaces.
<p>
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
index 1d1ec05..5c0252e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
@@ -209,7 +209,7 @@ public abstract class SignalProtocol extends AbstractProtocol
public Buffer provideBuffer()
{
Buffer buffer = delegate.provideBuffer();
- ByteBuffer byteBuffer = buffer.startPutting(getChannel().getChannelID());
+ ByteBuffer byteBuffer = buffer.startPutting(getChannel().getChannelIndex());
if (SignalProtocol.TRACER.isEnabled())
{
SignalProtocol.TRACER.trace("Providing buffer for correlation " + correlationID); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Buffer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Buffer.java
index 1b09554..4af1881 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Buffer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Buffer.java
@@ -38,7 +38,7 @@ import java.nio.channels.SocketChannel;
* // Obtain a fresh buffer
* Buffer buffer = bufferProvider.getBuffer();
*
- * // Start filling the buffer for channelID 4711
+ * // Start filling the buffer for channelIndex 4711
* ByteBuffer byteBuffer = buffer.startPutting(4711);
* byteBuffer.putDouble(15.47);
*
@@ -82,13 +82,13 @@ public interface Buffer
{
public BufferProvider getBufferProvider();
- public short getChannelID();
+ public short getChannelIndex();
public short getCapacity();
public ByteBuffer startGetting(SocketChannel socketChannel) throws IOException;
- public ByteBuffer startPutting(short channelID);
+ public ByteBuffer startPutting(short channelIndex);
public boolean write(SocketChannel socketChannel) throws IOException;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Channel.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Channel.java
index c57af77..f6212c3 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Channel.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Channel.java
@@ -10,6 +10,10 @@
**************************************************************************/
package org.eclipse.net4j.transport;
+import org.eclipse.net4j.util.registry.HashMapRegistry;
+import org.eclipse.net4j.util.registry.IRegistry;
+import org.eclipse.net4j.util.registry.IRegistryElement;
+
/**
* A bidirectional communications channel for the asynchronous exchange of
* {@link Buffer}s. A channel is lightweight and virtual in the sense that it
@@ -22,9 +26,11 @@ package org.eclipse.net4j.transport;
*
* @author Eike Stepper
*/
-public interface Channel extends BufferHandler
+public interface Channel extends BufferHandler, IRegistryElement<ChannelID>
{
- public short getChannelID();
+ public static final IRegistry<ChannelID, Channel> REGISTRY = new HashMapRegistry();
+
+ public short getChannelIndex();
public Connector getConnector();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ChannelID.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ChannelID.java
new file mode 100644
index 0000000..af7265d
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ChannelID.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 ChannelID
+{
+ public Connector getConnector();
+
+ public short getChannelIndex();
+}
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 bea5c53..aa3e7ee 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
@@ -10,7 +10,9 @@
**************************************************************************/
package org.eclipse.net4j.transport;
+import org.eclipse.net4j.util.registry.HashMapRegistry;
import org.eclipse.net4j.util.registry.IRegistry;
+import org.eclipse.net4j.util.registry.IRegistryElement;
/**
* One endpoint of a physical connection of arbitrary nature between two
@@ -26,8 +28,10 @@ import org.eclipse.net4j.util.registry.IRegistry;
*
* @author Eike Stepper
*/
-public interface Connector
+public interface Connector extends IRegistryElement<Integer>
{
+ public static final IRegistry<Integer, Connector> REGISTRY = new HashMapRegistry();
+
public Type getType();
public boolean isClient();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
index 5de5d85..9beebff 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
@@ -39,10 +39,10 @@ public class BufferOutputStream extends OutputStream
private Buffer currentBuffer;
- private short channelID;
+ private short channelIndex;
public BufferOutputStream(BufferHandler bufferHandler, BufferProvider bufferProvider,
- short channelID)
+ short channelIndex)
{
if (bufferHandler == null)
{
@@ -56,12 +56,12 @@ public class BufferOutputStream extends OutputStream
this.bufferHandler = bufferHandler;
this.bufferProvider = bufferProvider;
- this.channelID = channelID;
+ this.channelIndex = channelIndex;
}
- public BufferOutputStream(BufferHandler bufferHandler, short channelID)
+ public BufferOutputStream(BufferHandler bufferHandler, short channelIndex)
{
- this(bufferHandler, extractBufferProvider(bufferHandler), channelID);
+ this(bufferHandler, extractBufferProvider(bufferHandler), channelIndex);
}
@Override
@@ -130,7 +130,7 @@ public class BufferOutputStream extends OutputStream
if (currentBuffer == null)
{
currentBuffer = bufferProvider.provideBuffer();
- currentBuffer.startPutting(channelID);
+ currentBuffer.startPutting(channelIndex);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/ChannelOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/ChannelOutputStream.java
index 37ef3b7..785a10c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/ChannelOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/ChannelOutputStream.java
@@ -20,11 +20,11 @@ public class ChannelOutputStream extends BufferOutputStream
{
public ChannelOutputStream(Channel channel)
{
- super(channel, channel.getChannelID());
+ super(channel, channel.getChannelIndex());
}
public ChannelOutputStream(Channel channel, BufferProvider bufferProvider)
{
- super(channel, bufferProvider, channel.getChannelID());
+ super(channel, bufferProvider, channel.getChannelIndex());
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java
index 3bbed80..a911bc5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/Net4jUtil.java
@@ -8,11 +8,15 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j;
+package org.eclipse.net4j.util;
import org.eclipse.net4j.transport.BufferPool;
import org.eclipse.net4j.transport.BufferProvider;
+import org.eclipse.net4j.transport.Channel;
import org.eclipse.net4j.transport.Connector;
+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.TCPSelector;
@@ -25,12 +29,16 @@ import org.eclipse.internal.net4j.transport.tcp.ClientTCPConnectorImpl;
import org.eclipse.internal.net4j.transport.tcp.TCPAcceptorImpl;
import org.eclipse.internal.net4j.transport.tcp.TCPSelectorImpl;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
/**
* @author Eike Stepper
*/
-public final class Net4jFactory
+public final class Net4jUtil
{
- private Net4jFactory()
+ private Net4jUtil()
{
}
@@ -104,4 +112,48 @@ public final class Net4jFactory
{
return new TCPSelectorImpl();
}
+
+ public static Collection<Channel> getChannels(String protocolID, Set<Type> types)
+ {
+ if (types == null)
+ {
+ types = ProtocolFactory.SYMMETRIC;
+ }
+
+ Collection<Channel> channels = Channel.REGISTRY.getElements();
+ 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(String protocolID)
+ {
+ return getChannels(protocolID, null);
+ }
+
+ public static Collection<Channel> getChannels(Set<Type> types)
+ {
+ return getChannels(null, types);
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ObjectUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ObjectUtil.java
new file mode 100644
index 0000000..6ec7f67
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/ObjectUtil.java
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * 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.util;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ObjectUtil
+{
+ private ObjectUtil()
+ {
+ }
+
+ public static boolean equals(Object o1, Object o2)
+ {
+ if (o1 == null)
+ {
+ return o2 == null;
+ }
+
+ return o1.equals(o2);
+ }
+
+ public static int hashCode(Object o)
+ {
+ if (o == null)
+ {
+ return 0;
+ }
+
+ return o.hashCode();
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/StringUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/StringUtil.java
index e8d0c1b..4a5833f 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/StringUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/StringUtil.java
@@ -29,5 +29,4 @@ public final class StringUtil
return count;
}
-
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractCachingRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractCachingRegistry.java
index cd0f061..b9f8ea2 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractCachingRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractCachingRegistry.java
@@ -54,7 +54,6 @@ public abstract class AbstractCachingRegistry<ID, E extends IRegistryElement<ID>
else
{
fireElementDeregistering(oldElement);
- oldElement.dispose();
}
fireElementRegistered(element);
@@ -69,7 +68,6 @@ public abstract class AbstractCachingRegistry<ID, E extends IRegistryElement<ID>
if (element != null)
{
fireElementDeregistering(element);
- element.dispose();
if (delegatedElement != null)
{
@@ -124,7 +122,6 @@ public abstract class AbstractCachingRegistry<ID, E extends IRegistryElement<ID>
for (E element : getCache().values())
{
fireElementDeregistering(element);
- element.dispose();
}
getCache().clear();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractMappingRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractMappingRegistry.java
index e9c4fd9..f9b3df6 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractMappingRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractMappingRegistry.java
@@ -35,7 +35,6 @@ public abstract class AbstractMappingRegistry<ID, E extends IRegistryElement<ID>
if (oldElement != null)
{
fireElementDeregistering(oldElement);
- oldElement.dispose();
}
fireElementRegistered(element);
@@ -47,7 +46,6 @@ public abstract class AbstractMappingRegistry<ID, E extends IRegistryElement<ID>
if (element != null)
{
fireElementDeregistering(element);
- element.dispose();
}
}
@@ -73,11 +71,6 @@ public abstract class AbstractMappingRegistry<ID, E extends IRegistryElement<ID>
@Override
public synchronized void dispose()
{
- for (E element : getMap().values())
- {
- element.dispose();
- }
-
getMap().clear();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/IRegistryElement.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/IRegistryElement.java
index 2f80d44..33083a5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/IRegistryElement.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/IRegistryElement.java
@@ -17,8 +17,6 @@ public interface IRegistryElement<ID>
{
public ID getID();
- public void dispose();
-
/**
* @author Eike Stepper
*/