summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-12-22 03:45:10 (EST)
committerEike Stepper2006-12-22 03:45:10 (EST)
commit01c999b937b030fc5b405f204881f45a4dc597f1 (patch)
treed93c6c24d55a30f85d70a3a760345b087d83dbc3
parent628b660a146fea7df9679e9e217aeeed301a6bf1 (diff)
downloadcdo-01c999b937b030fc5b405f204881f45a4dc597f1.zip
cdo-01c999b937b030fc5b405f204881f45a4dc597f1.tar.gz
cdo-01c999b937b030fc5b405f204881f45a4dc597f1.tar.bz2
Added delegating registries.
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractDelegatingRegistry.java25
2 files changed, 17 insertions, 12 deletions
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 458e693..acdc13c 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
@@ -23,6 +23,7 @@ import org.eclipse.net4j.util.lifecycle.LifecycleListener;
import org.eclipse.net4j.util.lifecycle.LifecycleNotifier;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.registry.HashMapDelegatingRegistry;
import org.eclipse.net4j.util.registry.IRegistry;
import org.eclipse.internal.net4j.bundle.Net4j;
@@ -571,7 +572,6 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
if (protocolFactoryRegistry == null)
{
- // TODO Replace global registry with local delegating registry
switch (getType())
{
case CLIENT:
@@ -581,6 +581,8 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
protocolFactoryRegistry = ProtocolFactory.SERVER_REGISTRY;
break;
}
+
+ protocolFactoryRegistry = new HashMapDelegatingRegistry(protocolFactoryRegistry);
}
if (receiveExecutor == null && TRACER.isEnabled())
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractDelegatingRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractDelegatingRegistry.java
index b4a7b3f..4ec2d43 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractDelegatingRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractDelegatingRegistry.java
@@ -47,9 +47,9 @@ public abstract class AbstractDelegatingRegistry<K, V> extends AbstractRegistry<
public V get(Object key)
{
V result = getMap().get(key);
- if (result == null)
+ if (result == null && delegate != null)
{
- result = getDelegate().get(key);
+ result = delegate.get(key);
}
return result;
@@ -76,7 +76,7 @@ public abstract class AbstractDelegatingRegistry<K, V> extends AbstractRegistry<
@Override
protected V register(K key, V value)
{
- V delegated = getDelegate().get(key);
+ V delegated = delegate != null ? delegate.get(key) : null;
V old = getMap().put(key, value);
if (old == null)
{
@@ -100,7 +100,7 @@ public abstract class AbstractDelegatingRegistry<K, V> extends AbstractRegistry<
@Override
protected V deregister(Object key)
{
- V delegated = getDelegate().get(key);
+ V delegated = delegate != null ? delegate.get(key) : null;
V old = getMap().remove(key);
if (old != null)
{
@@ -118,7 +118,11 @@ public abstract class AbstractDelegatingRegistry<K, V> extends AbstractRegistry<
protected Set<Entry<K, V>> mergedEntrySet()
{
final Map<K, V> merged = new HashMap<K, V>();
- merged.putAll(getDelegate());
+ if (delegate != null)
+ {
+ merged.putAll(delegate);
+ }
+
merged.putAll(getMap());
return merged.entrySet();
}
@@ -126,7 +130,11 @@ public abstract class AbstractDelegatingRegistry<K, V> extends AbstractRegistry<
protected Set<K> mergedKeySet()
{
final Set<K> merged = new HashSet<K>();
- merged.addAll(getDelegate().keySet());
+ if (delegate != null)
+ {
+ merged.addAll(delegate.keySet());
+ }
+
merged.addAll(getMap().keySet());
return merged;
}
@@ -141,9 +149,4 @@ public abstract class AbstractDelegatingRegistry<K, V> extends AbstractRegistry<
return result;
}
-
- protected IRegistry<K, V> getDelegate()
- {
- return delegate;
- }
}