Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-12-21 02:39:07 -0500
committerEike Stepper2006-12-21 02:39:07 -0500
commitb653a01faf4d197e42cf7ebf5b3336420257af79 (patch)
tree967c88f4d58e3ad07daca35d40e2e1a51c76dd0f /plugins/org.eclipse.net4j
parentfc4d86d41f6e5cec358eabd54c2c8aff6e2fc1cd (diff)
downloadcdo-b653a01faf4d197e42cf7ebf5b3336420257af79.tar.gz
cdo-b653a01faf4d197e42cf7ebf5b3336420257af79.tar.xz
cdo-b653a01faf4d197e42cf7ebf5b3336420257af79.zip
Added global protocol factory registries.
Diffstat (limited to 'plugins/org.eclipse.net4j')
-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
5 files changed, 67 insertions, 5 deletions
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 794bf7cd88..0000000000
--- 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 5e33e3c3fd..458e693303 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 0000000000..e14ddc8922
--- /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 0000000000..cd2e621143
--- /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 ece19acfb0..6838e6c776 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();

Back to the top