You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by tl...@apache.org on 2006/08/30 12:47:24 UTC
svn commit: r438454 - in
/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport:
AbstractCachedOutputStream.java ChainInitiationObserver.java
Author: tli
Date: Wed Aug 30 03:47:23 2006
New Revision: 438454
URL: http://svn.apache.org/viewvc?rev=438454&view=rev
Log:
Fix bug by add Chain into message, fix bug of getInputStream() of AbstractCachedOutputStream
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java?rev=438454&r1=438453&r2=438454&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java Wed Aug 30 03:47:23 2006
@@ -32,25 +32,28 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
-
public abstract class AbstractCachedOutputStream extends OutputStream {
- protected OutputStream currentStream;
+ protected OutputStream currentStream;
+
private long threshold = 8 * 1024;
+
private int totalLength;
+
private boolean inmem;
+
private File tempFile;
+
private File outputDir;
-
public AbstractCachedOutputStream(PipedInputStream stream) throws IOException {
- currentStream = new PipedOutputStream(stream);
- inmem = true;
+ currentStream = new PipedOutputStream(stream);
+ inmem = true;
}
public AbstractCachedOutputStream() {
- currentStream = new ByteArrayOutputStream();
- inmem = true;
+ currentStream = new ByteArrayOutputStream();
+ inmem = true;
}
/**
@@ -69,7 +72,7 @@
*/
protected abstract void doClose() throws IOException;
- public void close() throws IOException {
+ public void close() throws IOException {
currentStream.close();
doClose();
}
@@ -84,11 +87,12 @@
* AttachmentSerializer Or Copy the cached output stream to the "real"
* output stream, i.e. onto the wire.
*
- * @param realOS the real output stream
+ * @param realOS
+ * the real output stream
* @throws IOException
*/
public void resetOut(OutputStream out, boolean copyOldContent) throws IOException {
- ByteArrayOutputStream bout = (ByteArrayOutputStream)currentStream;
+ ByteArrayOutputStream bout = (ByteArrayOutputStream) currentStream;
if (copyOldContent && bout.size() > 0) {
bout.writeTo(out);
}
@@ -108,11 +112,10 @@
public String toString() {
return currentStream.toString();
- }
-
+ }
+
protected abstract void onWrite() throws IOException;
-
-
+
public void write(byte[] b, int off, int len) throws IOException {
onWrite();
this.totalLength += len;
@@ -140,9 +143,8 @@
currentStream.write(b);
}
-
private void createFileOutputStream() throws IOException {
- byte[] bytes = ((ByteArrayOutputStream)currentStream).toByteArray();
+ byte[] bytes = ((ByteArrayOutputStream) currentStream).toByteArray();
if (outputDir == null) {
tempFile = File.createTempFile("att", "tmp");
} else {
@@ -159,7 +161,13 @@
public InputStream getInputStream() throws IOException {
if (inmem) {
- return new ByteArrayInputStream(((ByteArrayOutputStream)currentStream).toByteArray());
+ if (currentStream instanceof ByteArrayOutputStream) {
+ return new ByteArrayInputStream(((ByteArrayOutputStream)currentStream).toByteArray());
+ } else if (currentStream instanceof PipedOutputStream) {
+ return new PipedInputStream((PipedOutputStream)currentStream);
+ } else {
+ return null;
+ }
} else {
try {
return new FileInputStream(tempFile);
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java?rev=438454&r1=438453&r2=438454&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java Wed Aug 30 03:47:23 2006
@@ -54,11 +54,13 @@
// setup chain
PhaseInterceptorChain chain = new PhaseInterceptorChain(bus.getExtension(PhaseManager.class)
.getInPhases());
+
+ message.setInterceptorChain(chain);
chain.add(bus.getInInterceptors());
chain.add(endpoint.getInInterceptors());
chain.add(endpoint.getBinding().getInInterceptors());
chain.add(endpoint.getService().getInInterceptors());
- chain.setFaultInterceptor(endpoint.getFaultInterceptor());
+ chain.setFaultInterceptor(endpoint.getFaultInterceptor());
chain.doIntercept(message);
}