summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-27 03:30:15 (EDT)
committerEike Stepper2006-10-27 03:30:15 (EDT)
commitd964ce1952d15f4e917be4cc1efe4bab269d6b16 (patch)
tree092c1d090f2ad9ae065b9a43cf5e5a0fe1896eef
parent6b79de84a9a3b528cf3b125e232ae0611d4672dd (diff)
downloadcdo-d964ce1952d15f4e917be4cc1efe4bab269d6b16.zip
cdo-d964ce1952d15f4e917be4cc1efe4bab269d6b16.tar.gz
cdo-d964ce1952d15f4e917be4cc1efe4bab269d6b16.tar.bz2
Initial collection/map size = 0
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyPlatform.java2
-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/internal/net4j/transport/tcp/ControlChannelImpl.java37
-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/internal/net4j/util/AbstractCachingMap.java23
-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/ProtocolFactory.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/SynchronizingCorrelator.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractCachingRegistry.java9
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashCacheRegistry.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashMapRegistry.java2
14 files changed, 66 insertions, 33 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java
index 04372b8..ce6022f 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMBundle.java
@@ -45,7 +45,7 @@ public abstract class AbstractOMBundle implements OMBundle
private boolean debuggingInitialized;
- private Map<String, OMTracerImpl> tracers = new ConcurrentHashMap();
+ private Map<String, OMTracerImpl> tracers = new ConcurrentHashMap(0);
private OMLogger logger;
@@ -53,9 +53,9 @@ public abstract class AbstractOMBundle implements OMBundle
public ResourceBundle untranslatedResourceBundle;
- public Map<String, String> strings = new HashMap();
+ public Map<String, String> strings = new HashMap(0);
- public Map<String, String> untranslatedStrings = new HashMap();
+ public Map<String, String> untranslatedStrings = new HashMap(0);
public boolean shouldTranslate = true;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java
index 62f40f2..f692808 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/AbstractOMPlatform.java
@@ -33,7 +33,7 @@ public abstract class AbstractOMPlatform implements OMPlatform
private static ContextTracer __TRACER__;
- private Map<String, AbstractOMBundle> bundles = new ConcurrentHashMap();
+ private Map<String, AbstractOMBundle> bundles = new ConcurrentHashMap(0);
private Queue<OMLogHandler> logHandlers = new ConcurrentLinkedQueue();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyPlatform.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyPlatform.java
index 87df18e..f44add1 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyPlatform.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/LegacyPlatform.java
@@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class LegacyPlatform extends AbstractOMPlatform
{
- private Map<String, String> debugOptions = new ConcurrentHashMap();
+ private Map<String, String> debugOptions = new ConcurrentHashMap(0);
public LegacyPlatform()
{
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 dec095a..46853d7 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
@@ -312,7 +312,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
public Channel[] getChannels()
{
- final List<Channel> result = new ArrayList<Channel>();
+ final List<Channel> result = new ArrayList(channels.size());
synchronized (channels)
{
for (final ChannelImpl channel : channels)
@@ -397,7 +397,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
protected List<Queue<Buffer>> getChannelBufferQueues()
{
- final List<Queue<Buffer>> result = new ArrayList();
+ final List<Queue<Buffer>> result = new ArrayList(channels.size());
synchronized (channels)
{
for (final ChannelImpl channel : channels)
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 0deb676..63b2e26 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
@@ -3,6 +3,7 @@ package org.eclipse.internal.net4j.transport.tcp;
import org.eclipse.net4j.transport.Buffer;
import org.eclipse.net4j.util.concurrent.Synchronizer;
import org.eclipse.net4j.util.concurrent.SynchronizingCorrelator;
+import org.eclipse.net4j.util.om.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.transport.BufferUtil;
@@ -29,6 +30,9 @@ public final class ControlChannelImpl extends ChannelImpl
public static final byte FAILURE = 0;
+ private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_CHANNEL,
+ ControlChannelImpl.class);
+
private SynchronizingCorrelator<Short, Boolean> registrations = new SynchronizingCorrelator();
public ControlChannelImpl(AbstractTCPConnector connector)
@@ -120,7 +124,32 @@ public final class ControlChannelImpl extends ChannelImpl
}
case OPCODE_DEREGISTRATION:
- throw new UnsupportedOperationException();
+ {
+ short channelID = byteBuffer.getShort();
+ assertValidChannelID(channelID);
+
+ try
+ {
+ ChannelImpl channel = ((AbstractTCPConnector)getConnector()).getChannel(channelID);
+ if (channel != null)
+ {
+ channel.deactivate();
+ }
+ else
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(toString() + ": Invalid channel id: " + channelID); //$NON-NLS-1$
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Net4j.LOG.error(ex);
+ }
+
+ break;
+ }
default:
Net4j.LOG.error("Invalid opcode: " + opcode); //$NON-NLS-1$
@@ -133,12 +162,6 @@ public final class ControlChannelImpl extends ChannelImpl
}
}
- // private Buffer getBuffer()
- // {
- // return
- // ((AbstractTCPConnector)getConnector()).getBufferProvider().provideBuffer();
- // }
-
private void sendStatus(byte opcode, short channelID, boolean status)
{
Buffer buffer = provideBuffer();
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 c93c9b5..04b5a67 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
@@ -67,7 +67,7 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
private SelectionKey selectionKey;
- private Set<TCPConnector> acceptedConnectors = new HashSet();
+ private Set<TCPConnector> acceptedConnectors = new HashSet(0);
/**
* An optional executor to be used by the {@link Channel}s to process their
@@ -167,7 +167,7 @@ public class TCPAcceptorImpl extends AbstractLifecycle implements TCPAcceptor, B
ArrayList<TCPConnector> result;
synchronized (acceptedConnectors)
{
- result = new ArrayList<TCPConnector>(acceptedConnectors);
+ result = new ArrayList(acceptedConnectors);
}
return result.toArray(new TCPConnector[result.size()]);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java
index bb69be2..c384bb6 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/AbstractCachingMap.java
@@ -202,24 +202,31 @@ public abstract class AbstractCachingMap<K, V> extends AbstractDelegatingMap<K,
protected Set<Entry<K, V>> mergedEntrySet()
{
- final Map<K, V> merged = new HashMap<K, V>();
- merged.putAll(getDelegate());
- merged.putAll(getCache());
+ final Map<K, V> delegate = getDelegate();
+ final Map<K, V> cache = getCache();
+ final Map<K, V> merged = new HashMap(delegate.size() + cache.size());
+
+ merged.putAll(delegate);
+ merged.putAll(cache);
return merged.entrySet();
}
protected Set<K> mergedKeySet()
{
- final Set<K> merged = new HashSet<K>();
- merged.addAll(getDelegate().keySet());
- merged.addAll(getCache().keySet());
+ final Set<K> delegateKeys = getDelegate().keySet();
+ final Set<K> cacheKeys = getCache().keySet();
+ final Set<K> merged = new HashSet(delegateKeys.size() + cacheKeys.size());
+
+ merged.addAll(delegateKeys);
+ merged.addAll(cacheKeys);
return merged;
}
protected Collection<V> mergedValues()
{
- final List<V> result = new ArrayList<V>();
- for (K key : keySet())
+ final Set<K> keys = keySet();
+ final List<V> result = new ArrayList(keys.size());
+ for (K key : keys)
{
result.add(get(key));
}
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 2afc01f..b3f2bfa 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
@@ -43,7 +43,7 @@ public abstract class SignalProtocol extends AbstractProtocol
private ExecutorService executorService;
- private Map<Integer, Signal> signals = new ConcurrentHashMap();
+ private Map<Integer, Signal> signals = new ConcurrentHashMap(0);
private int nextCorrelationID = MIN_CORRELATION_ID;
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 86f6c38..fe16d61 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
@@ -17,7 +17,7 @@ public interface ProtocolFactory extends IRegistryElement<String>
public static final Set<Type> FOR_SERVERS = Collections.singleton(Type.SERVER);
- public static final Set<Type> SYMMETRIC = Collections.unmodifiableSet(new HashSet<Type>(Arrays
+ public static final Set<Type> SYMMETRIC = Collections.unmodifiableSet(new HashSet(Arrays
.asList(new Type[] { Type.CLIENT, Type.SERVER })));
public Set<Type> getConnectorTypes();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/SynchronizingCorrelator.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/SynchronizingCorrelator.java
index d43f462..7668f88 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/SynchronizingCorrelator.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/concurrent/SynchronizingCorrelator.java
@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentMap;
public class SynchronizingCorrelator<CORRELATION, RESULT> implements
Correlator<CORRELATION, Synchronizer<RESULT>>
{
- private ConcurrentMap<CORRELATION, Synchronizer<RESULT>> map = new ConcurrentHashMap();
+ private ConcurrentMap<CORRELATION, Synchronizer<RESULT>> map = new ConcurrentHashMap(0);
public boolean isCorrelated(CORRELATION correlation)
{
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 c7b116f..cd0f061 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
@@ -109,9 +109,12 @@ public abstract class AbstractCachingRegistry<ID, E extends IRegistryElement<ID>
@Override
public Set<ID> getElementIDs()
{
- Set<ID> ids = new HashSet();
- ids.addAll(super.getElementIDs());
- ids.addAll(getCache().keySet());
+ final Set<ID> delegateIDs = super.getElementIDs();
+ final Set<ID> cacheIDs = getCache().keySet();
+ final Set<ID> ids = new HashSet(delegateIDs.size() + cacheIDs.size());
+
+ ids.addAll(delegateIDs);
+ ids.addAll(cacheIDs);
return ids;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
index 809fc09..f67d10c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/AbstractRegistry.java
@@ -93,7 +93,7 @@ public abstract class AbstractRegistry<ID, E extends IRegistryElement<ID>> imple
public final synchronized Collection<E> getElements(boolean resolve)
{
Set<ID> elementKeys = getElementIDs();
- List<E> elements = new ArrayList<E>(elementKeys.size());
+ List<E> elements = new ArrayList(elementKeys.size());
for (ID id : elementKeys)
{
elements.add(lookup(id, resolve));
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashCacheRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashCacheRegistry.java
index 29f80d4..fb0c2e0 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashCacheRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashCacheRegistry.java
@@ -40,6 +40,6 @@ public class HashCacheRegistry<ID, E extends IRegistryElement<ID>> extends
protected Map<ID, E> createCache()
{
- return new HashMap();
+ return new HashMap(0);
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashMapRegistry.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashMapRegistry.java
index 83b75fd..e73fa9a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashMapRegistry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/registry/HashMapRegistry.java
@@ -40,6 +40,6 @@ public class HashMapRegistry<ID, E extends IRegistryElement<ID>> extends
protected Map<ID, E> createMap()
{
- return new HashMap();
+ return new HashMap(0);
}
}