summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-27 03:05:44 (EDT)
committerEike Stepper2007-08-27 03:05:44 (EDT)
commit4b89ebddbf4932a6ca16a612fc52d07828f30c15 (patch)
treee3ed01f2c9ada903978c6110cece384c88d56482
parent12bed0ae41d0b663ba9dfb5d92db0d0ac31b952d (diff)
downloadcdo-4b89ebddbf4932a6ca16a612fc52d07828f30c15.zip
cdo-4b89ebddbf4932a6ca16a612fc52d07828f30c15.tar.gz
cdo-4b89ebddbf4932a6ca16a612fc52d07828f30c15.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java46
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java24
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java45
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java23
4 files changed, 127 insertions, 11 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java
new file mode 100644
index 0000000..41b2272
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.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;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class DelegatingStreamWrapper implements IStreamWrapper
+{
+ private IStreamWrapper delegate;
+
+ public DelegatingStreamWrapper(IStreamWrapper delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public IStreamWrapper getDelegate()
+ {
+ return delegate;
+ }
+
+ public InputStream wrapInputStream(InputStream in)
+ {
+ return doWrapInputStream(delegate.wrapInputStream(in));
+ }
+
+ public OutputStream wrapOutputStream(OutputStream out)
+ {
+ return doWrapOutputStream(delegate.wrapOutputStream(out));
+ }
+
+ protected abstract InputStream doWrapInputStream(InputStream in);
+
+ protected abstract OutputStream doWrapOutputStream(OutputStream out);
+}
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
new file mode 100644
index 0000000..9688fd6
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java
@@ -0,0 +1,24 @@
+/***************************************************************************
+ * 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;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IStreamWrapper
+{
+ public InputStream wrapInputStream(InputStream in);
+
+ public OutputStream wrapOutputStream(OutputStream out);
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java
new file mode 100644
index 0000000..74d3541
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * 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;
+
+/**
+ * @author Eike Stepper
+ */
+public class StreamWrapperChain extends DelegatingStreamWrapper
+{
+ private IStreamWrapper head;
+
+ public StreamWrapperChain(IStreamWrapper head, IStreamWrapper delegate)
+ {
+ super(delegate);
+ this.head = head;
+ }
+
+ public IStreamWrapper getHead()
+ {
+ return head;
+ }
+
+ @Override
+ protected InputStream doWrapInputStream(InputStream in)
+ {
+ return head.wrapInputStream(in);
+ }
+
+ @Override
+ protected OutputStream doWrapOutputStream(OutputStream out)
+ {
+ return head.wrapOutputStream(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 07d4235..f9d0f6c 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
@@ -15,6 +15,7 @@ import org.eclipse.net4j.IBufferProvider;
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.internal.net4j.Protocol;
import org.eclipse.internal.net4j.bundle.OM;
@@ -30,7 +31,7 @@ import java.util.concurrent.ExecutorService;
/**
* @author Eike Stepper
*/
-public abstract class SignalProtocol extends Protocol
+public abstract class SignalProtocol extends Protocol implements IStreamWrapper
{
public static final long NO_TIMEOUT = BufferInputStream.NO_TIMEOUT;
@@ -75,6 +76,16 @@ public abstract class SignalProtocol extends Protocol
return true;
}
+ public InputStream wrapInputStream(InputStream in)
+ {
+ return in;
+ }
+
+ public OutputStream wrapOutputStream(OutputStream out)
+ {
+ return out;
+ }
+
public void handleBuffer(IBuffer buffer)
{
ByteBuffer byteBuffer = buffer.getByteBuffer();
@@ -168,16 +179,6 @@ public abstract class SignalProtocol extends Protocol
signalActor.runSync();
}
- protected InputStream wrapInputStream(InputStream in)
- {
- return in;
- }
-
- protected OutputStream wrapOutputStream(OutputStream out)
- {
- return out;
- }
-
void stopSignal(Signal signal)
{
int correlationID = signal.getCorrelationID();