summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-27 04:29:10 (EDT)
committerEike Stepper2007-08-27 04:29:10 (EDT)
commit6a9f20cea006fd5da0fe4d0b3b6f6d9e4e8f130e (patch)
tree20a9920bc2c7a135eabde170d9f79efcfdf81cfc
parent7ddc82241577e96440eabcb8d491b247f6ee61a6 (diff)
downloadcdo-6a9f20cea006fd5da0fe4d0b3b6f6d9e4e8f130e.zip
cdo-6a9f20cea006fd5da0fe4d0b3b6f6d9e4e8f130e.tar.gz
cdo-6a9f20cea006fd5da0fe4d0b3b6f6d9e4e8f130e.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java46
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java53
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptor.java18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java11
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocolProvider.java21
6 files changed, 135 insertions, 32 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java
index e6e5459..7c6920b 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Acceptor.java
@@ -18,6 +18,7 @@ import org.eclipse.net4j.internal.util.container.LifecycleEventConverter;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.container.IContainerEvent;
+import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IContainerDelta.Kind;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.factory.IFactory;
@@ -28,6 +29,7 @@ import org.eclipse.net4j.util.registry.IRegistry;
import org.eclipse.internal.net4j.bundle.OM;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@@ -40,7 +42,9 @@ public abstract class Acceptor extends Container<IConnector> implements IAccepto
private IBufferProvider bufferProvider;
- private IRegistry<IFactoryKey, IFactory> factoryRegistry;
+ private IRegistry<IFactoryKey, IFactory> protocolFactoryRegistry;
+
+ private List<IElementProcessor> protocolPostProcessors;
private ExecutorService receiveExecutor;
@@ -57,17 +61,6 @@ public abstract class Acceptor extends Container<IConnector> implements IAccepto
}
};
- // private transient IListener lifecycleEventConverter = new
- // LifecycleEventConverter(this)
- // {
- // @Override
- // protected void removed(ILifecycleEvent e)
- // {
- // removeConnector((IConnector)e.getLifecycle());
- // super.removed(e);
- // }
- // };
-
private Set<IConnector> acceptedConnectors = new HashSet(0);
public Acceptor()
@@ -94,14 +87,24 @@ public abstract class Acceptor extends Container<IConnector> implements IAccepto
this.receiveExecutor = receiveExecutor;
}
- public IRegistry<IFactoryKey, IFactory> getFactoryRegistry()
+ public IRegistry<IFactoryKey, IFactory> getProtocolFactoryRegistry()
+ {
+ return protocolFactoryRegistry;
+ }
+
+ public void setProtocolFactoryRegistry(IRegistry<IFactoryKey, IFactory> protocolFactoryRegistry)
+ {
+ this.protocolFactoryRegistry = protocolFactoryRegistry;
+ }
+
+ public List<IElementProcessor> getProtocolPostProcessors()
{
- return factoryRegistry;
+ return protocolPostProcessors;
}
- public void setFactoryRegistry(IRegistry<IFactoryKey, IFactory> factoryRegistry)
+ public void setProtocolPostProcessors(List<IElementProcessor> protocolPostProcessors)
{
- this.factoryRegistry = factoryRegistry;
+ this.protocolPostProcessors = protocolPostProcessors;
}
public IConnector[] getAcceptedConnectors()
@@ -129,7 +132,8 @@ public abstract class Acceptor extends Container<IConnector> implements IAccepto
{
connector.setBufferProvider(bufferProvider);
connector.setReceiveExecutor(receiveExecutor);
- connector.setFactoryRegistry(factoryRegistry);
+ connector.setProtocolFactoryRegistry(protocolFactoryRegistry);
+ connector.setProtocolPostProcessors(protocolPostProcessors);
connector.activate();
connector.addListener(lifecycleEventConverter);
@@ -176,12 +180,18 @@ public abstract class Acceptor extends Container<IConnector> implements IAccepto
throw new IllegalStateException("bufferProvider == null"); //$NON-NLS-1$
}
- if (factoryRegistry == null && TRACER.isEnabled())
+ if (protocolFactoryRegistry == null && TRACER.isEnabled())
{
// Just a reminder during development
TRACER.trace("factoryRegistry == null"); //$NON-NLS-1$
}
+ if (protocolPostProcessors == null && TRACER.isEnabled())
+ {
+ // Just a reminder during development
+ TRACER.trace("protocolPostProcessors == null"); //$NON-NLS-1$
+ }
+
if (receiveExecutor == null && TRACER.isEnabled())
{
// Just a reminder during development
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
index 68829ee..944c66f 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Connector.java
@@ -30,6 +30,7 @@ import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.concurrent.RWLock;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.container.IContainerEvent;
+import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IContainerDelta.Kind;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.event.INotifier;
@@ -60,7 +61,9 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
private IConnectorCredentials credentials;
- private IRegistry<IFactoryKey, IFactory> factoryRegistry;
+ private IRegistry<IFactoryKey, IFactory> protocolFactoryRegistry;
+
+ private List<IElementProcessor> protocolPostProcessors;
private IBufferProvider bufferProvider;
@@ -111,14 +114,24 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
this.receiveExecutor = receiveExecutor;
}
- public IRegistry<IFactoryKey, IFactory> getFactoryRegistry()
+ public IRegistry<IFactoryKey, IFactory> getProtocolFactoryRegistry()
+ {
+ return protocolFactoryRegistry;
+ }
+
+ public void setProtocolFactoryRegistry(IRegistry<IFactoryKey, IFactory> protocolFactoryRegistry)
{
- return factoryRegistry;
+ this.protocolFactoryRegistry = protocolFactoryRegistry;
}
- public void setFactoryRegistry(IRegistry<IFactoryKey, IFactory> factoryRegistry)
+ public List<IElementProcessor> getProtocolPostProcessors()
{
- this.factoryRegistry = factoryRegistry;
+ return protocolPostProcessors;
+ }
+
+ public void setProtocolPostProcessors(List<IElementProcessor> protocolPostProcessors)
+ {
+ this.protocolPostProcessors = protocolPostProcessors;
}
public IBufferProvider getBufferProvider()
@@ -550,15 +563,23 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
}
}
+ /**
+ * TODO Use IProtocolProvider and make the protocols real container elements,
+ * so that the post processors can reach them. The protocol description can be
+ * used to store unique protocol IDs so that always new protocols are created
+ * in the container.
+ */
protected IProtocol createProtocol(String type)
{
- if (StringUtil.isEmpty(type) || factoryRegistry == null)
+ IRegistry<IFactoryKey, IFactory> registry = getProtocolFactoryRegistry();
+ if (StringUtil.isEmpty(type) || registry == null)
{
return null;
}
+ // Get protocol factory
IFactoryKey key = createProtocolFactoryKey(type);
- IFactory<IProtocol> factory = factoryRegistry.get(key);
+ IFactory<IProtocol> factory = registry.get(key);
if (factory == null)
{
if (TRACER.isEnabled())
@@ -569,7 +590,21 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
return null;
}
- return factory.create(null);
+ // Create protocol
+ String description = null;
+ IProtocol protocol = factory.create(description);
+
+ // Post process protocol
+ List<IElementProcessor> processors = getProtocolPostProcessors();
+ if (processors != null)
+ {
+ for (IElementProcessor processor : processors)
+ {
+ protocol = (IProtocol)processor.process(null, key.getProductGroup(), key.getType(), description, protocol);
+ }
+ }
+
+ return protocol;
}
protected IFactoryKey createProtocolFactoryKey(String type)
@@ -594,7 +629,7 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
throw new IllegalStateException("bufferProvider == null"); //$NON-NLS-1$
}
- if (factoryRegistry == null && TRACER.isEnabled())
+ if (protocolFactoryRegistry == null && TRACER.isEnabled())
{
// Just a reminder during development
TRACER.trace("No factoryRegistry!"); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java
index d7d30c4..84f81e5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jTransportInjector.java
@@ -26,9 +26,14 @@ public class Net4jTransportInjector implements IElementProcessor
acceptor.setReceiveExecutor(getExecutorService(container));
}
- if (acceptor.getFactoryRegistry() == null)
+ if (acceptor.getProtocolFactoryRegistry() == null)
{
- acceptor.setFactoryRegistry(container.getFactoryRegistry());
+ acceptor.setProtocolFactoryRegistry(container.getFactoryRegistry());
+ }
+
+ if (acceptor.getProtocolPostProcessors() == null)
+ {
+ acceptor.setProtocolPostProcessors(container.getPostProcessors());
}
}
else if (element instanceof Connector)
@@ -44,9 +49,14 @@ public class Net4jTransportInjector implements IElementProcessor
connector.setReceiveExecutor(getExecutorService(container));
}
- if (connector.getFactoryRegistry() == null)
+ if (connector.getProtocolFactoryRegistry() == null)
+ {
+ connector.setProtocolFactoryRegistry(container.getFactoryRegistry());
+ }
+
+ if (connector.getProtocolPostProcessors() == null)
{
- connector.setFactoryRegistry(container.getFactoryRegistry());
+ connector.setProtocolPostProcessors(container.getPostProcessors());
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptor.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptor.java
index 473cc1b..ca89fbc 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IAcceptor.java
@@ -11,9 +11,15 @@
package org.eclipse.net4j;
import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.container.IElementProcessor;
+import org.eclipse.net4j.util.factory.IFactory;
+import org.eclipse.net4j.util.factory.IFactoryKey;
+import org.eclipse.net4j.util.registry.IRegistry;
import org.eclipse.internal.net4j.Acceptor;
+import java.util.List;
+
/**
* Accepts incoming connection requests from
* {@link ConnectorLocation#CLIENT client} {@link IConnector connectors} and
@@ -52,6 +58,18 @@ import org.eclipse.internal.net4j.Acceptor;
public interface IAcceptor extends IContainer<IConnector>
{
/**
+ * Returns the factory registry used by this acceptor to prepare newly
+ * accepted connectors.
+ */
+ public IRegistry<IFactoryKey, IFactory> getProtocolFactoryRegistry();
+
+ /**
+ * Returns the post processors used by this acceptor to prepare newly accepted
+ * connectors.
+ */
+ public List<IElementProcessor> getProtocolPostProcessors();
+
+ /**
* Returns an array of the connectors that have been accepted by this acceptor
* and not been closed since.
*/
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java
index 3d86eb8..f0ef342 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IConnector.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j;
import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.factory.IFactory;
import org.eclipse.net4j.util.factory.IFactoryKey;
@@ -20,6 +21,8 @@ import org.eclipse.net4j.util.registry.IRegistry;
import org.eclipse.internal.net4j.Channel;
import org.eclipse.internal.net4j.Connector;
+import java.util.List;
+
/**
* One endpoint of a physical connection of arbitrary nature between two
* communicating parties. A {@link IConnector} encapsulates the process of
@@ -100,7 +103,13 @@ public interface IConnector extends IContainer<IChannel>
* Automatic protocol creation only happens if {@link #isServer()} returns
* <code>true</code>.
*/
- public IRegistry<IFactoryKey, IFactory> getFactoryRegistry();
+ public IRegistry<IFactoryKey, IFactory> getProtocolFactoryRegistry();
+
+ /**
+ * Returns the post processors used by this connector to modify protocols
+ * created for new channels.
+ */
+ public List<IElementProcessor> getProtocolPostProcessors();
/**
* Returns the current state of this onnector.
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocolProvider.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocolProvider.java
new file mode 100644
index 0000000..fa20f6d
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/IProtocolProvider.java
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IProtocolProvider
+{
+ public IProtocol getClientProtocol(String type, IChannel channel);
+
+ public IProtocol getServerProtocol(String type, IChannel channel);
+}