Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2016-02-05 07:18:49 -0500
committerEike Stepper2016-02-05 07:49:26 -0500
commit3161838c989d7ebfc009eded4ac95698bb2a70a4 (patch)
treef5a8b11dcac8216a7f1e4f8a60f17cded0f5ab39
parentf11f14a3b2711978ad96d835dd69b2384721bb37 (diff)
downloadcdo-3161838c989d7ebfc009eded4ac95698bb2a70a4.tar.gz
cdo-3161838c989d7ebfc009eded4ac95698bb2a70a4.tar.xz
cdo-3161838c989d7ebfc009eded4ac95698bb2a70a4.zip
[482686] Have IStreamWrapper configurable through cdo-server.xml
For example: <acceptor type="tcp" listenAddr="0.0.0.0" port="2036"> <streamWrapper type="gzip" protocol="cdo" description="bufferSize=256,compressionLevel=3"/> </acceptor> <streamWrapper type="gzip"/> Change-Id: I7e04ad92b081a454ab90b4ace5dc328f3fd12bfe Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=482686 Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr> Signed-off-by: Eike Stepper <stepper@esc-net.de>
-rw-r--r--plugins/org.eclipse.net4j.http.server/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java3
-rw-r--r--plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java2
-rw-r--r--plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMServerConnector.java13
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPServerConnector.java3
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java2
-rw-r--r--plugins/org.eclipse.net4j.util/.settings/.api_filters8
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java111
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java18
-rw-r--r--plugins/org.eclipse.net4j/.settings/.api_filters17
-rw-r--r--plugins/org.eclipse.net4j/plugin.xml18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java91
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java22
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/wrapping/StreamWrapperInjector.java7
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java26
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java5
19 files changed, 301 insertions, 72 deletions
diff --git a/plugins/org.eclipse.net4j.http.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.http.server/META-INF/MANIFEST.MF
index 32dcfe26ff..d31f7da64d 100644
--- a/plugins/org.eclipse.net4j.http.server/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.http.server/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.net4j.http.server;singleton:=true
-Bundle-Version: 4.0.400.qualifier
+Bundle-Version: 4.0.500.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";resoluti
org.eclipse.equinox.http.registry;bundle-version="[1.0.0,2.0.0)"
Import-Package: javax.servlet;version="[2.3.0,4.0.0)",
javax.servlet.http;version="[2.3.0,4.0.0)"
-Export-Package: org.eclipse.net4j.http.internal.server;version="4.0.400";x-friends:="org.eclipse.net4j.http.tests,org.eclipse.net4j.defs",
- org.eclipse.net4j.http.internal.server.bundle;version="4.0.400";x-internal:=true,
- org.eclipse.net4j.http.internal.server.messages;version="4.0.400";x-internal:=true,
- org.eclipse.net4j.http.server;version="4.0.400"
+Export-Package: org.eclipse.net4j.http.internal.server;version="4.0.500";x-friends:="org.eclipse.net4j.http.tests,org.eclipse.net4j.defs",
+ org.eclipse.net4j.http.internal.server.bundle;version="4.0.500";x-internal:=true,
+ org.eclipse.net4j.http.internal.server.messages;version="4.0.500";x-internal:=true,
+ org.eclipse.net4j.http.server;version="4.0.500"
diff --git a/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java b/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java
index fcc32f7e26..0a98acdfd8 100644
--- a/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java
+++ b/plugins/org.eclipse.net4j.http.server/src/org/eclipse/net4j/http/internal/server/HTTPServerConnector.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.http.internal.server;
import org.eclipse.net4j.channel.ChannelException;
+import org.eclipse.net4j.connector.IServerConnector;
import org.eclipse.net4j.http.internal.common.HTTPConnector;
import org.eclipse.net4j.protocol.IProtocol;
import org.eclipse.net4j.util.WrappedException;
@@ -20,7 +21,7 @@ import java.text.MessageFormat;
/**
* @author Eike Stepper
*/
-public class HTTPServerConnector extends HTTPConnector
+public class HTTPServerConnector extends HTTPConnector implements IServerConnector
{
private HTTPAcceptor acceptor;
diff --git a/plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF
index 320b6f9ae8..7a38afe8ef 100644
--- a/plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.net4j.jvm;singleton:=true
-Bundle-Version: 4.1.300.qualifier
+Bundle-Version: 4.1.400.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,7 +12,7 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
org.eclipse.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
Import-Package: org.osgi.framework;version="[1.3.0,2.0.0)";resolution:=optional
-Export-Package: org.eclipse.net4j.internal.jvm;version="4.1.300";x-friends:="org.eclipse.net4j.defs,org.eclipse.net4j.tests,org.eclipse.net4j.ui",
- org.eclipse.net4j.internal.jvm.bundle;version="4.1.300";x-internal:=true,
- org.eclipse.net4j.internal.jvm.messages;version="4.1.300";x-internal:=true,
- org.eclipse.net4j.jvm;version="4.1.300"
+Export-Package: org.eclipse.net4j.internal.jvm;version="4.1.400";x-friends:="org.eclipse.net4j.defs,org.eclipse.net4j.tests,org.eclipse.net4j.ui",
+ org.eclipse.net4j.internal.jvm.bundle;version="4.1.400";x-internal:=true,
+ org.eclipse.net4j.internal.jvm.messages;version="4.1.400";x-internal:=true,
+ org.eclipse.net4j.jvm;version="4.1.400"
diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java
index b5b2b20de9..2c08814ddb 100644
--- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java
+++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMAcceptor.java
@@ -40,7 +40,7 @@ public class JVMAcceptor extends Acceptor implements IJVMAcceptor
public JVMServerConnector handleAccept(JVMClientConnector client)
{
- JVMServerConnector connector = new JVMServerConnector(client);
+ JVMServerConnector connector = new JVMServerConnector(this, client);
connector.setName(client.getName());
connector.setConfig(getConfig());
connector.activate();
diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMServerConnector.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMServerConnector.java
index 54251a9f76..6115948ff5 100644
--- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMServerConnector.java
+++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMServerConnector.java
@@ -10,18 +10,27 @@
*/
package org.eclipse.net4j.internal.jvm;
+import org.eclipse.net4j.connector.IServerConnector;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
/**
* @author Eike Stepper
*/
-public class JVMServerConnector extends JVMConnector
+public class JVMServerConnector extends JVMConnector implements IServerConnector
{
- public JVMServerConnector(JVMClientConnector clientPeer)
+ private final JVMAcceptor acceptor;
+
+ public JVMServerConnector(JVMAcceptor acceptor, JVMClientConnector clientPeer)
{
+ this.acceptor = acceptor;
setPeer(clientPeer);
}
+ public JVMAcceptor getAcceptor()
+ {
+ return acceptor;
+ }
+
@Override
public Location getLocation()
{
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPServerConnector.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPServerConnector.java
index 862549d09f..ca8312f57c 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPServerConnector.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPServerConnector.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.net4j.internal.tcp;
+import org.eclipse.net4j.connector.IServerConnector;
import org.eclipse.net4j.internal.tcp.bundle.OM;
import org.eclipse.net4j.tcp.ITCPSelector;
@@ -19,7 +20,7 @@ import java.text.MessageFormat;
/**
* @author Eike Stepper
*/
-public class TCPServerConnector extends TCPConnector
+public class TCPServerConnector extends TCPConnector implements IServerConnector
{
private TCPAcceptor acceptor;
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java
index 5eebf60224..2e3a91090c 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java
@@ -90,7 +90,7 @@ public class Bugzilla_241463_Test extends AbstractTransportTest
@Override
public JVMServerConnector handleAccept(JVMClientConnector client)
{
- JVMServerConnector connector = new JVMServerConnector(client)
+ JVMServerConnector connector = new JVMServerConnector(this, client)
{
@Override
public InternalChannel inverseOpenChannel(short channelID, String protocolID, int protocolVersion)
diff --git a/plugins/org.eclipse.net4j.util/.settings/.api_filters b/plugins/org.eclipse.net4j.util/.settings/.api_filters
index 717e5483be..aff0f5752c 100644
--- a/plugins/org.eclipse.net4j.util/.settings/.api_filters
+++ b/plugins/org.eclipse.net4j.util/.settings/.api_filters
@@ -77,6 +77,14 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java" type="org.eclipse.net4j.util.io.GZIPStreamWrapper">
+ <filter id="338792546">
+ <message_arguments>
+ <message_argument value="org.eclipse.net4j.util.io.GZIPStreamWrapper"/>
+ <message_argument value="main(String[])"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/net4j/util/lifecycle/ILifecycle.java" type="org.eclipse.net4j.util.lifecycle.ILifecycle">
<filter id="403984517">
<message_arguments>
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
index 65cc8b40c5..282a01573d 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
@@ -10,23 +10,47 @@
*/
package org.eclipse.net4j.util.io;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.factory.ProductCreationException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
+import java.util.zip.Deflater;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
/**
* @author Eike Stepper
+ * @since 3.6
*/
public class GZIPStreamWrapper implements IStreamWrapper
{
+ /**
+ * @since 3.6
+ */
+ public static final int DEFAULT_BUFFER_SIZE = 512;
+
+ /**
+ * @since 3.6
+ */
+ public static final int DEFAULT_COMPRESSION_LEVEL = Deflater.BEST_SPEED;
+
+ private final int bufferSize;
+
+ private final int compressionLevel;
+
public GZIPStreamWrapper()
{
+ this(DEFAULT_BUFFER_SIZE, DEFAULT_COMPRESSION_LEVEL);
+ }
+
+ /**
+ * @since 3.6
+ */
+ public GZIPStreamWrapper(int bufferSize, int compressionLevel)
+ {
+ this.bufferSize = bufferSize;
+ this.compressionLevel = compressionLevel;
}
public GZIPInputStream wrapInputStream(InputStream in) throws IOException
@@ -36,7 +60,7 @@ public class GZIPStreamWrapper implements IStreamWrapper
return (GZIPInputStream)in;
}
- return new GZIPInputStream(in);
+ return new GZIPInputStream(in, bufferSize);
}
public GZIPOutputStream wrapOutputStream(OutputStream out) throws IOException
@@ -46,7 +70,12 @@ public class GZIPStreamWrapper implements IStreamWrapper
return (GZIPOutputStream)out;
}
- return new GZIPOutputStream(out);
+ return new GZIPOutputStream(out, bufferSize)
+ {
+ {
+ def.setLevel(compressionLevel);
+ }
+ };
}
public void finishInputStream(InputStream in) throws IOException
@@ -59,43 +88,59 @@ public class GZIPStreamWrapper implements IStreamWrapper
}
/**
- * TODO Move or remove me
+ * @author Esteban Dugueperoux
+ * @since 3.6
*/
- public static void main(String[] args) throws Exception
+ public static class Factory extends IStreamWrapper.Factory
{
- final PipedOutputStream pos = new PipedOutputStream();
- @SuppressWarnings("resource")
- final PipedInputStream pis = new PipedInputStream(pos);
+ public static final String TYPE = "gzip"; //$NON-NLS-1$
- final GZIPOutputStream gos = new GZIPOutputStream(pos);
- final byte[] out = "eike".getBytes(); //$NON-NLS-1$
+ public Factory()
+ {
+ super(TYPE);
+ }
- Thread thread = new Thread()
+ @Override
+ public IStreamWrapper create(String description) throws ProductCreationException
{
- @Override
- public void run()
- {
- try
- {
- GZIPInputStream gis = new GZIPInputStream(pis);
+ int bufferSize = GZIPStreamWrapper.DEFAULT_BUFFER_SIZE;
+ int compressionLevel = GZIPStreamWrapper.DEFAULT_COMPRESSION_LEVEL;
- byte[] in = new byte[out.length];
- gis.read(in);
- gis.close();
- }
- catch (IOException ex)
+ String[] properties = description.split(",");
+ for (String property : properties)
+ {
+ String[] tokens = property.split("=");
+ if (tokens.length == 2)
{
- throw new IORuntimeException(ex);
+ String propertyName = tokens[0];
+ String propertyValue = tokens[1];
+
+ if ("bufferSize".equals(propertyName))
+ {
+ try
+ {
+ bufferSize = Integer.valueOf(propertyValue);
+ }
+ catch (NumberFormatException ex)
+ {
+ throw new ProductCreationException(ex);
+ }
+ }
+ else if ("compressionLevel".equals(propertyName))
+ {
+ try
+ {
+ compressionLevel = Integer.valueOf(propertyValue);
+ }
+ catch (NumberFormatException ex)
+ {
+ throw new ProductCreationException(ex);
+ }
+ }
}
}
- };
- thread.start();
- ConcurrencyUtil.sleep(1000);
-
- gos.write(out);
- gos.close();
-
- ConcurrencyUtil.sleep(2000);
+ return new GZIPStreamWrapper(bufferSize, compressionLevel);
+ }
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java
index a43985fc47..d92b4eca9d 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java
@@ -10,6 +10,8 @@
*/
package org.eclipse.net4j.util.io;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -26,4 +28,20 @@ public interface IStreamWrapper
public void finishInputStream(InputStream in) throws IOException;
public void finishOutputStream(OutputStream out) throws IOException;
+
+ /**
+ * @author Esteban Dugueperoux
+ * @since 3.6
+ */
+ public static abstract class Factory extends org.eclipse.net4j.util.factory.Factory
+ {
+ public static final String PRODUCT_GROUP = "org.eclipse.net4j.streamWrappers"; //$NON-NLS-1$
+
+ public Factory(String type)
+ {
+ super(PRODUCT_GROUP, type);
+ }
+
+ public abstract IStreamWrapper create(String description) throws ProductCreationException;
+ }
}
diff --git a/plugins/org.eclipse.net4j/.settings/.api_filters b/plugins/org.eclipse.net4j/.settings/.api_filters
new file mode 100644
index 0000000000..fa64efe5e5
--- /dev/null
+++ b/plugins/org.eclipse.net4j/.settings/.api_filters
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.net4j" version="2">
+ <resource path="src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java" type="org.eclipse.spi.net4j.InternalChannelMultiplexer">
+ <filter id="403767336">
+ <message_arguments>
+ <message_argument value="org.eclipse.spi.net4j.InternalChannelMultiplexer"/>
+ <message_argument value="CONTEXT_CHANNEL"/>
+ </message_arguments>
+ </filter>
+ <filter id="403767336">
+ <message_arguments>
+ <message_argument value="org.eclipse.spi.net4j.InternalChannelMultiplexer"/>
+ <message_argument value="CONTEXT_MULTIPLEXER"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/plugins/org.eclipse.net4j/plugin.xml b/plugins/org.eclipse.net4j/plugin.xml
index 61bb4391b4..0d30d94fd1 100644
--- a/plugins/org.eclipse.net4j/plugin.xml
+++ b/plugins/org.eclipse.net4j/plugin.xml
@@ -13,26 +13,24 @@
<plugin>
- <extension
- point="org.eclipse.net4j.util.factories">
+ <extension point="org.eclipse.net4j.util.factories">
<factory
class="org.eclipse.internal.net4j.buffer.BufferProviderFactory"
productGroup="org.eclipse.net4j.bufferProviders"
type="default"/>
<factory
+ class="org.eclipse.net4j.util.io.GZIPStreamWrapper$Factory"
+ productGroup="org.eclipse.net4j.streamWrappers"
+ type="gzip"/>
+ <factory
class="org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol$Server$Factory"
productGroup="org.eclipse.net4j.serverProtocols"
type="heartbeat"/>
</extension>
- <extension
- point="org.eclipse.net4j.util.elementProcessors">
- <elementProcessor
- class="org.eclipse.net4j.TransportInjector">
- </elementProcessor>
- <elementProcessor
- class="org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol$Server$TimerInjector">
- </elementProcessor>
+ <extension point="org.eclipse.net4j.util.elementProcessors">
+ <elementProcessor class="org.eclipse.net4j.TransportInjector"/>
+ <elementProcessor class="org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol$Server$TimerInjector"/>
</extension>
</plugin>
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java
index a46853a619..3728709bd2 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/ContainerProtocolProvider.java
@@ -50,7 +50,8 @@ public abstract class ContainerProtocolProvider implements IProtocolProvider
public IProtocol<?> getProtocol(String type)
{
- return (IProtocol<?>)container.getElement(productGroup, type, "protocol-" + counter.increment(), false); //$NON-NLS-1$
+ String description = "protocol-" + counter.increment();
+ return (IProtocol<?>)container.getElement(productGroup, type, description, false);
}
/**
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java
index 923c9b03d3..2523632b1c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java
@@ -22,6 +22,7 @@ import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.concurrent.ExecutorServiceFactory;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.GZIPStreamWrapper;
import org.eclipse.net4j.util.lifecycle.ILifecycle;
import org.eclipse.internal.net4j.TransportConfig;
@@ -53,8 +54,9 @@ public final class Net4jUtil
{
ContainerUtil.prepareContainer(container);
container.registerFactory(new BufferProviderFactory());
- container.addPostProcessor(new TransportInjector());
+ container.registerFactory(new GZIPStreamWrapper.Factory());
container.registerFactory(new HeartBeatProtocol.Server.Factory());
+ container.addPostProcessor(new TransportInjector());
container.addPostProcessor(new HeartBeatProtocol.Server.TimerInjector());
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java
index c99a4adcf2..b52704c611 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/TransportConfigurator.java
@@ -11,7 +11,13 @@
package org.eclipse.net4j;
import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.channel.IChannelMultiplexer;
+import org.eclipse.net4j.connector.IServerConnector;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.wrapping.StreamWrapperInjector;
+import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IStreamWrapper;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.security.INegotiator;
import org.eclipse.net4j.util.security.NegotiatorFactory;
@@ -21,6 +27,7 @@ import org.eclipse.internal.net4j.bundle.OM;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.spi.net4j.Acceptor;
import org.eclipse.spi.net4j.AcceptorFactory;
+import org.eclipse.spi.net4j.InternalChannelMultiplexer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -71,6 +78,7 @@ public class TransportConfigurator
List<IAcceptor> acceptors = new ArrayList<IAcceptor>();
Document document = getDocument(configFile);
+
NodeList acceptorConfigs = document.getElementsByTagName("acceptor"); //$NON-NLS-1$
for (int i = 0; i < acceptorConfigs.getLength(); i++)
{
@@ -79,6 +87,16 @@ public class TransportConfigurator
acceptors.add(acceptor);
}
+ NodeList streamWrapperConfigs = document.getElementsByTagName("streamWrapper"); //$NON-NLS-1$
+ for (int i = 0; i < streamWrapperConfigs.getLength(); i++)
+ {
+ Element streamWrapperConfig = (Element)streamWrapperConfigs.item(i);
+ if (getLevel(streamWrapperConfig) == 2)
+ {
+ configureStreamWrapper(streamWrapperConfig, null);
+ }
+ }
+
return acceptors.toArray(new IAcceptor[acceptors.size()]);
}
@@ -104,6 +122,16 @@ public class TransportConfigurator
acceptor.getConfig().setNegotiator(negotiator);
}
+ NodeList streamWrapperConfigs = acceptorConfig.getElementsByTagName("streamWrapper"); //$NON-NLS-1$
+ for (int i = 0; i < streamWrapperConfigs.getLength(); i++)
+ {
+ Element streamWrapperConfig = (Element)streamWrapperConfigs.item(i);
+ if (getLevel(streamWrapperConfig) == 3)
+ {
+ configureStreamWrapper(streamWrapperConfig, acceptor);
+ }
+ }
+
OM.LOG.info("Net4j acceptor starting: " + type + "://" + description);
acceptor.activate();
return acceptor;
@@ -116,6 +144,24 @@ public class TransportConfigurator
return (INegotiator)container.getElement(NegotiatorFactory.PRODUCT_GROUP, type, description);
}
+ /**
+ * @since 4.5
+ */
+ protected void configureStreamWrapper(Element streamWrapperConfig, Acceptor acceptor)
+ {
+ String type = streamWrapperConfig.getAttribute("type");//$NON-NLS-1$
+ String description = streamWrapperConfig.getAttribute("description"); //$NON-NLS-1$
+ String protocolName = streamWrapperConfig.getAttribute("protocol");//$NON-NLS-1$
+
+ IStreamWrapper streamWrapper = (IStreamWrapper)container.getElement(IStreamWrapper.Factory.PRODUCT_GROUP, type,
+ description);
+ if (streamWrapper != null)
+ {
+ IElementProcessor injector = new AcceptorStreamWrapperInjector(protocolName, acceptor, streamWrapper);
+ container.addPostProcessor(injector);
+ }
+ }
+
protected Document getDocument(File configFile) throws ParserConfigurationException, SAXException, IOException
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -165,4 +211,49 @@ public class TransportConfigurator
}
}
}
+
+ private static int getLevel(Node node)
+ {
+ Node parentNode = node.getParentNode();
+ return parentNode != null ? getLevel(parentNode) + 1 : 0;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class AcceptorStreamWrapperInjector extends StreamWrapperInjector
+ {
+ private final IAcceptor acceptor;
+
+ public AcceptorStreamWrapperInjector(String protocolID, IAcceptor acceptor, IStreamWrapper streamWrapper)
+ {
+ super(protocolID, streamWrapper);
+ this.acceptor = acceptor;
+ }
+
+ @Override
+ protected boolean shouldInject(IManagedContainer container, String productGroup, String factoryType,
+ String description, SignalProtocol<?> signalProtocol)
+ {
+ if (super.shouldInject(container, productGroup, factoryType, description, signalProtocol))
+ {
+ if (acceptor == null)
+ {
+ return true;
+ }
+
+ IChannelMultiplexer multiplexer = InternalChannelMultiplexer.CONTEXT_MULTIPLEXER.get();
+ if (multiplexer instanceof IServerConnector)
+ {
+ IServerConnector serverConnector = (IServerConnector)multiplexer;
+ if (serverConnector.getAcceptor() == acceptor)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java
new file mode 100644
index 0000000000..66792c8e8d
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/connector/IServerConnector.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2016 Eike Stepper (Berlin, Germany) and others.
+ * 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.connector;
+
+import org.eclipse.net4j.acceptor.IAcceptor;
+
+/**
+ * @author Eike Stepper
+ * @since 4.5
+ */
+public interface IServerConnector extends IConnector
+{
+ public IAcceptor getAcceptor();
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/wrapping/StreamWrapperInjector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/wrapping/StreamWrapperInjector.java
index 6cc23de30a..fe5a0b8d37 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/wrapping/StreamWrapperInjector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/wrapping/StreamWrapperInjector.java
@@ -12,6 +12,7 @@ package org.eclipse.net4j.signal.wrapping;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.io.IStreamWrapper;
@@ -24,9 +25,9 @@ import org.eclipse.net4j.util.io.IStreamWrapper;
*/
public class StreamWrapperInjector implements IElementProcessor
{
- private String protocolID;
+ private final IStreamWrapper streamWrapper;
- private IStreamWrapper streamWrapper;
+ private final String protocolID;
public StreamWrapperInjector(String protocolID, IStreamWrapper streamWrapper)
{
@@ -67,7 +68,7 @@ public class StreamWrapperInjector implements IElementProcessor
return false;
}
- return ObjectUtil.equals(signalProtocol.getType(), protocolID);
+ return StringUtil.isEmpty(protocolID) || ObjectUtil.equals(signalProtocol.getType(), protocolID);
}
protected Object inject(IManagedContainer container, String productGroup, String factoryType, String description,
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java
index 0558cdbfd5..2e879a345a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/ChannelMultiplexer.java
@@ -47,7 +47,7 @@ import java.util.concurrent.ConcurrentMap;
* @author Eike Stepper
* @since 2.0
*/
-public abstract class ChannelMultiplexer extends Container<IChannel>implements InternalChannelMultiplexer
+public abstract class ChannelMultiplexer extends Container<IChannel> implements InternalChannelMultiplexer
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_CONNECTOR, ChannelMultiplexer.class);
@@ -193,14 +193,24 @@ public abstract class ChannelMultiplexer extends Container<IChannel>implements I
*/
public InternalChannel inverseOpenChannel(short channelID, String protocolID, int protocolVersion)
{
- IProtocol<?> protocol = createProtocol(protocolID, null);
- ProtocolVersionException.checkVersion(protocol, protocolVersion);
+ CONTEXT_MULTIPLEXER.set(this);
- InternalChannel channel = createChannel();
- initChannel(channel, protocol);
- channel.setID(channelID);
- addChannel(channel);
- return channel;
+ try
+ {
+ IProtocol<?> protocol = createProtocol(protocolID, null);
+ ProtocolVersionException.checkVersion(protocol, protocolVersion);
+
+ InternalChannel channel = createChannel();
+ initChannel(channel, protocol);
+ channel.setID(channelID);
+
+ addChannel(channel);
+ return channel;
+ }
+ finally
+ {
+ CONTEXT_MULTIPLEXER.remove();
+ }
}
public void closeChannel(InternalChannel channel) throws ChannelException
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java
index d93fd2df5b..4cdc6b1aa1 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/spi/net4j/InternalChannelMultiplexer.java
@@ -24,6 +24,11 @@ import org.eclipse.net4j.channel.IChannelMultiplexer;
public interface InternalChannelMultiplexer extends IChannelMultiplexer, IBufferProvider, ITransportConfigAware
{
/**
+ * @since 4.5
+ */
+ public static final ThreadLocal<InternalChannelMultiplexer> CONTEXT_MULTIPLEXER = new ThreadLocal<InternalChannelMultiplexer>();
+
+ /**
* @since 4.0
*/
public static final short RESERVED_CHANNEL = 0;

Back to the top