summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-06-02 05:54:00 (EDT)
committerEike Stepper2007-06-02 05:54:00 (EDT)
commite504170bf40e36d60eff6351e70ad0939acbc9f8 (patch)
treed20d31467a4904719cdf4d80a5ed6d81fee4c116
parent0bc4977c1ddeb8e7419104f24690f98efdce879d (diff)
downloadcdo-e504170bf40e36d60eff6351e70ad0939acbc9f8.zip
cdo-e504170bf40e36d60eff6351e70ad0939acbc9f8.tar.gz
cdo-e504170bf40e36d60eff6351e70ad0939acbc9f8.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java10
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEvent.java10
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java48
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/SingleDeltaContainerEvent.java5
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEvent.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java35
7 files changed, 97 insertions, 15 deletions
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java
index 3598215..99f861f 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPSelectorInjector.java
@@ -29,12 +29,18 @@ public class TCPSelectorInjector implements IElementProcessor
if (element instanceof TCPAcceptor)
{
TCPAcceptor acceptor = (TCPAcceptor)element;
- acceptor.setSelector(getSelector(container));
+ if (acceptor.getSelector() == null)
+ {
+ acceptor.setSelector(getSelector(container));
+ }
}
else if (element instanceof TCPConnector)
{
TCPConnector connector = (TCPConnector)element;
- connector.setSelector(getSelector(container));
+ if (connector.getSelector() == null)
+ {
+ connector.setSelector(getSelector(container));
+ }
}
return element;
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEvent.java
index 8d94cab..1066016 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEvent.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEvent.java
@@ -47,6 +47,11 @@ public class ContainerEvent<E> extends Event implements IContainerEvent<E>
return (IContainer<E>)getSource();
}
+ public boolean isEmpty()
+ {
+ return deltas.isEmpty();
+ }
+
public IContainerDelta<E>[] getDeltas()
{
return deltas.toArray(new IContainerDelta[deltas.size()]);
@@ -72,11 +77,6 @@ public class ContainerEvent<E> extends Event implements IContainerEvent<E>
return getDelta().getKind();
}
- public boolean isEmpty()
- {
- return deltas.isEmpty();
- }
-
public void addDelta(E element, Kind kind)
{
addDelta(new ContainerDelta(element, kind));
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java
index ae270df..fd564be 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java
@@ -17,9 +17,11 @@ import org.eclipse.net4j.internal.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.internal.util.registry.HashMapRegistry;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.IContainerEvent;
import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.event.EventUtil;
+import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.factory.IFactory;
import org.eclipse.net4j.util.factory.IFactoryKey;
@@ -102,6 +104,34 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
return postProcessors;
}
+ public synchronized void addPostProcessor(IElementProcessor postProcessor, boolean processExistingElements)
+ {
+ if (processExistingElements)
+ {
+ ContainerEvent event = new ContainerEvent(this);
+ for (Entry<ElementKey, Object> entry : elementRegistry.entrySet())
+ {
+ ElementKey key = entry.getKey();
+ Object element = entry.getValue();
+
+ String productGroup = key.getProductGroup();
+ String factoryType = key.getFactoryType();
+ String description = key.getDescription();
+ Object newElement = postProcessor.process(this, productGroup, factoryType, description, element);
+ if (newElement != element)
+ {
+ elementRegistry.put(key, newElement);
+ event.addDelta(element, IContainerDelta.Kind.REMOVED);
+ event.addDelta(newElement, IContainerDelta.Kind.ADDED);
+ }
+ }
+
+ fireEvent(event);
+ }
+
+ getPostProcessors().add(postProcessor);
+ }
+
public void addPostProcessor(IElementProcessor postProcessor)
{
getPostProcessors().add(postProcessor);
@@ -157,8 +187,7 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
public String[] getElementKey(Object element)
{
- Set<Entry<ElementKey, Object>> entries = elementRegistry.entrySet();
- for (Entry<ElementKey, Object> entry : entries)
+ for (Entry<ElementKey, Object> entry : elementRegistry.entrySet())
{
if (entry.getValue() == element)
{
@@ -325,6 +354,21 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
}
@Override
+ public void fireEvent(IEvent event)
+ {
+ if (event instanceof IContainerEvent)
+ {
+ IContainerEvent containerEvent = (IContainerEvent)event;
+ if (containerEvent.isEmpty())
+ {
+ return;
+ }
+ }
+
+ super.fireEvent(event);
+ }
+
+ @Override
public String toString()
{
return "ManagedContainer";
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/SingleDeltaContainerEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/SingleDeltaContainerEvent.java
index 10ffc6a..25e9a3b 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/SingleDeltaContainerEvent.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/SingleDeltaContainerEvent.java
@@ -38,6 +38,11 @@ public class SingleDeltaContainerEvent<E> extends Event implements IContainerEve
return (IContainer<E>)getSource();
}
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
public IContainerDelta<E>[] getDeltas()
{
return deltas;
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEvent.java
index 00db4fe..f04d504 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEvent.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEvent.java
@@ -20,6 +20,8 @@ public interface IContainerEvent<E> extends IEvent
{
public IContainer<E> getContainer();
+ public boolean isEmpty();
+
public IContainerDelta<E>[] getDeltas();
public IContainerDelta<E> getDelta() throws IllegalStateException;
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
index e8f99a7..68a6c0f 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
@@ -32,6 +32,8 @@ public interface IManagedContainer extends IContainer
public List<IElementProcessor> getPostProcessors();
+ public void addPostProcessor(IElementProcessor postProcessor, boolean processExistingElements);
+
public void addPostProcessor(IElementProcessor postProcessor);
public void removePostProcessor(IElementProcessor postProcessor);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java
index 18595f1..204a62c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/TransportContainer.java
@@ -93,16 +93,39 @@ public class TransportContainer extends ManagedContainer implements ITransportCo
if (element instanceof Acceptor)
{
Acceptor acceptor = (Acceptor)element;
- acceptor.setBufferProvider(getBufferProvider());
- acceptor.setReceiveExecutor(getExecutorService());
- acceptor.setFactoryRegistry(getFactoryRegistry());
+ if (acceptor.getBufferProvider() == null)
+ {
+ acceptor.setBufferProvider(getBufferProvider());
+ }
+
+ if (acceptor.getReceiveExecutor() == null)
+ {
+ acceptor.setReceiveExecutor(getExecutorService());
+ }
+
+ if (acceptor.getFactoryRegistry() == null)
+ {
+ acceptor.setFactoryRegistry(getFactoryRegistry());
+ }
}
+
else if (element instanceof Connector)
{
Connector connector = (Connector)element;
- connector.setBufferProvider(getBufferProvider());
- connector.setReceiveExecutor(getExecutorService());
- connector.setFactoryRegistry(getFactoryRegistry());
+ if (connector.getBufferProvider() == null)
+ {
+ connector.setBufferProvider(getBufferProvider());
+ }
+
+ if (connector.getReceiveExecutor() == null)
+ {
+ connector.setReceiveExecutor(getExecutorService());
+ }
+
+ if (connector.getFactoryRegistry() == null)
+ {
+ connector.setFactoryRegistry(getFactoryRegistry());
+ }
}
return element;