summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-27 03:38:23 (EDT)
committerEike Stepper2007-08-27 03:38:23 (EDT)
commit7ddc82241577e96440eabcb8d491b247f6ee61a6 (patch)
tree2058ae7dd36cb1823a8032783ad478e3539ad260
parent4b89ebddbf4932a6ca16a612fc52d07828f30c15 (diff)
downloadcdo-7ddc82241577e96440eabcb8d491b247f6ee61a6.zip
cdo-7ddc82241577e96440eabcb8d491b247f6ee61a6.tar.gz
cdo-7ddc82241577e96440eabcb8d491b247f6ee61a6.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/plugin.xml4
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ZIPStreamWrapper.java46
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java35
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StreamWrapperInjector.java75
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ZIPStreamWrapperInjector.java26
5 files changed, 186 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
index 21d957b..85d5f78 100644
--- a/plugins/org.eclipse.emf.cdo.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
@@ -3,6 +3,10 @@
<plugin>
+ <extension point="org.eclipse.net4j.util.elementProcessors">
+ <elementProcessor class="org.eclipse.emf.cdo.protocol.util.CDOZIPStreamWrapperInjector"/>
+ </extension>
+
<extension
point="org.eclipse.ui.views">
<category
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ZIPStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ZIPStreamWrapper.java
new file mode 100644
index 0000000..435bab1
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ZIPStreamWrapper.java
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * 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.util.io;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class ZIPStreamWrapper implements IStreamWrapper
+{
+ public ZIPStreamWrapper()
+ {
+ }
+
+ public InputStream wrapInputStream(InputStream in)
+ {
+ if (in instanceof ZipInputStream)
+ {
+ return in;
+ }
+
+ return new ZipInputStream(in);
+ }
+
+ public OutputStream wrapOutputStream(OutputStream out)
+ {
+ if (out instanceof ZipOutputStream)
+ {
+ return out;
+ }
+
+ return new ZipOutputStream(out);
+ }
+}
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 f9d0f6c..3c55721 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
@@ -16,6 +16,7 @@ import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.stream.BufferInputStream;
import org.eclipse.net4j.stream.ChannelOutputStream;
import org.eclipse.net4j.util.io.IStreamWrapper;
+import org.eclipse.net4j.util.io.StreamWrapperChain;
import org.eclipse.internal.net4j.Protocol;
import org.eclipse.internal.net4j.bundle.OM;
@@ -43,6 +44,8 @@ public abstract class SignalProtocol extends Protocol implements IStreamWrapper
private static final ContextTracer STREAM_TRACER = new ContextTracer(OM.DEBUG_BUFFER_STREAM, SignalOutputStream.class);
+ private IStreamWrapper streamWrapper;
+
private Map<Integer, Signal> signals = new ConcurrentHashMap(0);
private int nextCorrelationID = MIN_CORRELATION_ID;
@@ -51,6 +54,28 @@ public abstract class SignalProtocol extends Protocol implements IStreamWrapper
{
}
+ public IStreamWrapper getStreamWrapper()
+ {
+ return streamWrapper;
+ }
+
+ public void setStreamWrapper(IStreamWrapper streamWrapper)
+ {
+ this.streamWrapper = streamWrapper;
+ }
+
+ public void addStreamWrapper(IStreamWrapper streamWrapper)
+ {
+ if (this.streamWrapper == null)
+ {
+ this.streamWrapper = streamWrapper;
+ }
+ else
+ {
+ this.streamWrapper = new StreamWrapperChain(streamWrapper, this.streamWrapper);
+ }
+ }
+
public ExecutorService getExecutorService()
{
return getChannel().getConnector().getReceiveExecutor();
@@ -78,11 +103,21 @@ public abstract class SignalProtocol extends Protocol implements IStreamWrapper
public InputStream wrapInputStream(InputStream in)
{
+ if (streamWrapper != null)
+ {
+ in = streamWrapper.wrapInputStream(in);
+ }
+
return in;
}
public OutputStream wrapOutputStream(OutputStream out)
{
+ if (streamWrapper != null)
+ {
+ out = streamWrapper.wrapOutputStream(out);
+ }
+
return out;
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StreamWrapperInjector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StreamWrapperInjector.java
new file mode 100644
index 0000000..ab2b436
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/StreamWrapperInjector.java
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * 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.signal;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.container.IElementProcessor;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IStreamWrapper;
+
+/**
+ * @author Eike Stepper
+ */
+public class StreamWrapperInjector implements IElementProcessor
+{
+ private String protocolID;
+
+ private IStreamWrapper streamWrapper;
+
+ public StreamWrapperInjector(String protocolID, IStreamWrapper streamWrapper)
+ {
+ this.protocolID = protocolID;
+ this.streamWrapper = streamWrapper;
+ }
+
+ public String getProtocolID()
+ {
+ return protocolID;
+ }
+
+ public IStreamWrapper getStreamWrapper()
+ {
+ return streamWrapper;
+ }
+
+ public Object process(IManagedContainer container, String productGroup, String factoryType, String description,
+ Object element)
+ {
+ if (element instanceof SignalProtocol)
+ {
+ SignalProtocol signalProtocol = (SignalProtocol)element;
+ if (shouldInject(container, productGroup, factoryType, description, signalProtocol))
+ {
+ element = inject(container, productGroup, factoryType, description, signalProtocol);
+ }
+ }
+
+ return element;
+ }
+
+ protected boolean shouldInject(IManagedContainer container, String productGroup, String factoryType,
+ String description, SignalProtocol signalProtocol)
+ {
+ if (signalProtocol.getStreamWrapper() == streamWrapper)
+ {
+ return false;
+ }
+
+ return ObjectUtil.equals(signalProtocol.getType(), protocolID);
+ }
+
+ protected Object inject(IManagedContainer container, String productGroup, String factoryType, String description,
+ SignalProtocol signalProtocol)
+ {
+ signalProtocol.addStreamWrapper(streamWrapper);
+ return signalProtocol;
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ZIPStreamWrapperInjector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ZIPStreamWrapperInjector.java
new file mode 100644
index 0000000..c0390bf
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/ZIPStreamWrapperInjector.java
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * 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.signal;
+
+import org.eclipse.net4j.util.io.ZIPStreamWrapper;
+
+/**
+ * @author Eike Stepper
+ */
+public class ZIPStreamWrapperInjector extends StreamWrapperInjector
+{
+ public static final ZIPStreamWrapper STREAM_WRAPPER = new ZIPStreamWrapper();
+
+ public ZIPStreamWrapperInjector(String protocolID)
+ {
+ super(protocolID, STREAM_WRAPPER);
+ }
+}