summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-12-21 02:39:07 (EST)
committerEike Stepper2006-12-21 02:39:07 (EST)
commitb653a01faf4d197e42cf7ebf5b3336420257af79 (patch)
tree967c88f4d58e3ad07daca35d40e2e1a51c76dd0f
parentfc4d86d41f6e5cec358eabd54c2c8aff6e2fc1cd (diff)
downloadcdo-b653a01faf4d197e42cf7ebf5b3336420257af79.zip
cdo-b653a01faf4d197e42cf7ebf5b3336420257af79.tar.gz
cdo-b653a01faf4d197e42cf7ebf5b3336420257af79.tar.bz2
Added global protocol factory registries.
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java4
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java4
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java2
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java2
-rw-r--r--plugins/org.eclipse.net4j/.settings/org.eclipse.pde.core.prefs3
-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.java24
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java24
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java7
9 files changed, 73 insertions, 11 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 1bc496c..6033dcc 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
@@ -116,7 +116,7 @@ public class SignalTest extends AbstractOMTest
ExecutorService threadPool = Executors.newCachedThreadPool();
IRegistry<String, ProtocolFactory> registry = new HashMapRegistry();
TestSignalProtocol.Factory factory = new TestSignalProtocol.Factory();
- registry.put(factory.getID(), factory);
+ registry.put(factory.getProtocolID(), factory);
acceptor.setReceiveExecutor(threadPool);
acceptor.setProtocolFactoryRegistry(registry);
@@ -138,7 +138,7 @@ public class SignalTest extends AbstractOMTest
ExecutorService threadPool = Executors.newCachedThreadPool();
IRegistry<String, ProtocolFactory> registry = new HashMapRegistry();
TestSignalProtocol.Factory factory = new TestSignalProtocol.Factory();
- registry.put(factory.getID(), factory);
+ registry.put(factory.getProtocolID(), factory);
acceptor.setReceiveExecutor(threadPool);
acceptor.setProtocolFactoryRegistry(registry);
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 bdabba0..426ed62 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
@@ -158,7 +158,7 @@ public class TCPTransportTest extends AbstractOMTest
IRegistry<String, ProtocolFactory> protocolFactoryRegistry = new HashMapRegistry();
TestProtocolFactory factory = new TestProtocolFactory(counter);
- protocolFactoryRegistry.put(factory.getID(), factory);
+ protocolFactoryRegistry.put(factory.getProtocolID(), factory);
acceptor.setProtocolFactoryRegistry(protocolFactoryRegistry);
acceptor.activate();
@@ -240,7 +240,7 @@ public class TCPTransportTest extends AbstractOMTest
IRegistry<String, ProtocolFactory> protocolFactoryRegistry = new HashMapRegistry();
TestProtocolFactory factory = new TestProtocolFactory(counter);
- protocolFactoryRegistry.put(factory.getID(), factory);
+ protocolFactoryRegistry.put(factory.getProtocolID(), factory);
acceptor.setProtocolFactoryRegistry(protocolFactoryRegistry);
acceptor.setReceiveExecutor(Executors.newCachedThreadPool());
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 c1b5993..198cb64 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
@@ -36,7 +36,7 @@ public class TestProtocolFactory extends AbstractProtocolFactory implements Prot
this.counter = counter;
}
- public String getID()
+ public String getProtocolID()
{
return PROTOCOL_ID;
}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
index 18303e7..01e1ff1 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
@@ -65,7 +65,7 @@ public class TestSignalProtocol extends SignalProtocol
*/
public static class Factory extends AbstractProtocolFactory
{
- public String getID()
+ public String getProtocolID()
{
return PROTOCOL_ID;
}
diff --git a/plugins/org.eclipse.net4j/.settings/org.eclipse.pde.core.prefs b/plugins/org.eclipse.net4j/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644
index 794bf7c..0000000
--- a/plugins/org.eclipse.net4j/.settings/org.eclipse.pde.core.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sun Oct 15 23:11:17 CEST 2006
-eclipse.preferences.version=1
-pluginProject.extensions=false
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 5e33e3c..458e693 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
@@ -569,13 +569,23 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
throw new IllegalStateException("bufferProvider == null"); //$NON-NLS-1$
}
- if (protocolFactoryRegistry == null && TRACER.isEnabled())
+ if (protocolFactoryRegistry == null)
{
- TRACER.trace("No protocol factory registry!"); //$NON-NLS-1$
+ // TODO Replace global registry with local delegating registry
+ switch (getType())
+ {
+ case CLIENT:
+ protocolFactoryRegistry = ProtocolFactory.CLIENT_REGISTRY;
+ break;
+ case SERVER:
+ protocolFactoryRegistry = ProtocolFactory.SERVER_REGISTRY;
+ break;
+ }
}
if (receiveExecutor == null && TRACER.isEnabled())
{
+ // Just a reminder during development
TRACER.trace("No receive executor!"); //$NON-NLS-1$
}
}
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
new file mode 100644
index 0000000..e14ddc8
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ClientProtocolFactoryRegistry.java
@@ -0,0 +1,24 @@
+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>
+{
+ @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
new file mode 100644
index 0000000..cd2e621
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/ServerProtocolFactoryRegistry.java
@@ -0,0 +1,24 @@
+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>
+{
+ @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/net4j/transport/ProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
index ece19ac..6838e6c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.transport;
import org.eclipse.net4j.transport.Connector.Type;
+import org.eclipse.net4j.util.registry.IRegistry;
import java.util.Arrays;
import java.util.Collections;
@@ -22,6 +23,10 @@ import java.util.Set;
*/
public interface ProtocolFactory
{
+ public static final IRegistry<String, ProtocolFactory> CLIENT_REGISTRY = new org.eclipse.internal.net4j.transport.ClientProtocolFactoryRegistry();
+
+ public static final IRegistry<String, ProtocolFactory> SERVER_REGISTRY = new org.eclipse.internal.net4j.transport.ServerProtocolFactoryRegistry();
+
public static final Set<Type> FOR_CLIENTS = Collections.singleton(Type.CLIENT);
public static final Set<Type> FOR_SERVERS = Collections.singleton(Type.SERVER);
@@ -29,6 +34,8 @@ public interface ProtocolFactory
public static final Set<Type> SYMMETRIC = Collections.unmodifiableSet(new HashSet(Arrays
.asList(new Type[] { Type.CLIENT, Type.SERVER })));
+ public String getProtocolID();
+
public Set<Type> getConnectorTypes();
public boolean isForClients();