You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/09/27 23:45:07 UTC
svn commit: r1391228 - in /cxf/trunk/api/src/main/java/org/apache/cxf:
helpers/IOUtils.java interceptor/LoggingInInterceptor.java
io/CachedOutputStream.java io/CachedWriter.java io/CachedWriterCallback.java
Author: dkulp
Date: Thu Sep 27 21:45:06 2012
New Revision: 1391228
URL: http://svn.apache.org/viewvc?rev=1391228&view=rev
Log:
[CXF-4397] Add a CachedWriter that will work like the CachedOutputStream. Update logging In interceptor to use it.
Added:
cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java
- copied, changed from r1391102, cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriterCallback.java
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/helpers/IOUtils.java
cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/helpers/IOUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/helpers/IOUtils.java?rev=1391228&r1=1391227&r2=1391228&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/helpers/IOUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/helpers/IOUtils.java Thu Sep 27 21:45:06 2012
@@ -125,6 +125,24 @@ public final class IOUtils {
input.close();
}
}
+
+ public static void copyAndCloseInput(final Reader input,
+ final Writer output) throws IOException {
+ try {
+ copy(input, output, DEFAULT_BUFFER_SIZE);
+ } finally {
+ input.close();
+ }
+ }
+
+ public static void copyAndCloseInput(final Reader input,
+ final Writer output, int bufferSize) throws IOException {
+ try {
+ copy(input, output, bufferSize);
+ } finally {
+ input.close();
+ }
+ }
public static int copy(final InputStream input, final OutputStream output,
int bufferSize) throws IOException {
@@ -156,9 +174,6 @@ public final class IOUtils {
int n = 0;
n = input.read(buffer);
while (-1 != n) {
- if (n == 0) {
- throw new IOException("0 bytes read in violation of InputStream.read(byte[])");
- }
output.write(buffer, 0, n);
n = input.read(buffer);
}
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=1391228&r1=1391227&r2=1391228&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Thu Sep 27 21:45:06 2012
@@ -18,7 +18,6 @@
*/
package org.apache.cxf.interceptor;
-import java.io.BufferedReader;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Reader;
@@ -28,6 +27,7 @@ import org.apache.cxf.common.injection.N
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.io.CachedWriter;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.Phase;
@@ -136,10 +136,8 @@ public class LoggingInInterceptor extend
bos.setThreshold(threshold);
}
try {
- IOUtils.copy(is, bos);
-
+ IOUtils.copyAndCloseInput(is, bos);
bos.flush();
- is.close();
message.setContent(InputStream.class, bos.getInputStream());
if (bos.getTempFile() != null) {
@@ -160,17 +158,22 @@ public class LoggingInInterceptor extend
Reader reader = message.getContent(Reader.class);
if (reader != null) {
try {
- BufferedReader r = new BufferedReader(reader, limit);
- r.mark(limit);
- char b[] = new char[limit];
- int i = r.read(b);
- buffer.getPayload().append(b, 0, i);
- r.reset();
- message.setContent(Reader.class, r);
+ CachedWriter writer = new CachedWriter();
+ IOUtils.copyAndCloseInput(reader, writer);
+ message.setContent(Reader.class, writer.getReader());
+
+ if (writer.getTempFile() != null) {
+ //large thing on disk...
+ buffer.getMessage().append("\nMessage (saved to tmp file):\n");
+ buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
+ }
+ if (writer.size() > limit) {
+ buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
+ }
+ writer.writeCacheTo(buffer.getPayload(), limit);
} catch (Exception e) {
throw new Fault(e);
}
-
}
}
log(logger, formatLoggingMessage(buffer));
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1391228&r1=1391227&r2=1391228&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Thu Sep 27 21:45:06 2012
@@ -210,7 +210,7 @@ public class CachedOutputStream extends
*/
public void resetOut(OutputStream out, boolean copyOldContent) throws IOException {
if (out == null) {
- out = new ByteArrayOutputStream();
+ out = new LoadingByteArrayOutputStream();
}
if (currentStream instanceof CachedOutputStream) {
@@ -298,7 +298,10 @@ public class CachedOutputStream extends
long count = 0;
if (inmem) {
- if (currentStream instanceof ByteArrayOutputStream) {
+ if (currentStream instanceof LoadingByteArrayOutputStream) {
+ LoadingByteArrayOutputStream lout = (LoadingByteArrayOutputStream)currentStream;
+ out.append(IOUtils.newStringFromBytes(lout.getRawBytes(), charsetName, 0, (int)limit));
+ } else if (currentStream instanceof ByteArrayOutputStream) {
byte bytes[] = ((ByteArrayOutputStream)currentStream).toByteArray();
out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, (int)limit));
} else {
@@ -333,7 +336,10 @@ public class CachedOutputStream extends
public void writeCacheTo(StringBuilder out, String charsetName) throws IOException {
flush();
if (inmem) {
- if (currentStream instanceof ByteArrayOutputStream) {
+ if (currentStream instanceof LoadingByteArrayOutputStream) {
+ LoadingByteArrayOutputStream lout = (LoadingByteArrayOutputStream)currentStream;
+ out.append(IOUtils.newStringFromBytes(lout.getRawBytes(), charsetName, 0, lout.size()));
+ } else if (currentStream instanceof ByteArrayOutputStream) {
byte[] bytes = ((ByteArrayOutputStream)currentStream).toByteArray();
out.append(IOUtils.newStringFromBytes(bytes, charsetName));
} else {
@@ -428,8 +434,9 @@ public class CachedOutputStream extends
tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false);
}
- currentStream = new BufferedOutputStream(new FileOutputStream(tempFile));
+ currentStream = new FileOutputStream(tempFile);
bout.writeTo(currentStream);
+ currentStream = new BufferedOutputStream(currentStream);
inmem = false;
streamList.add(currentStream);
} catch (Exception ex) {
Copied: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java (from r1391102, cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java?p2=cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java&p1=cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java&r1=1391102&r2=1391228&rev=1391228&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java Thu Sep 27 21:45:06 2012
@@ -19,18 +19,17 @@
package org.apache.cxf.io;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -38,15 +37,14 @@ import java.util.List;
import org.apache.cxf.common.util.SystemPropertyAction;
import org.apache.cxf.helpers.FileUtils;
import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
-public class CachedOutputStream extends OutputStream {
+public class CachedWriter extends Writer {
private static final File DEFAULT_TEMP_DIR;
private static int defaultThreshold;
private static long defaultMaxSize;
static {
- String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.io.CachedOutputStream.OutputDirectory");
+ String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.io.CachedWriter.OutputDirectory");
if (s != null) {
File f = new File(s);
if (f.exists() && f.isDirectory()) {
@@ -63,7 +61,7 @@ public class CachedOutputStream extends
}
protected boolean outputLocked;
- protected OutputStream currentStream;
+ protected Writer currentStream;
private long threshold = defaultThreshold;
private long maxSize = defaultMaxSize;
@@ -77,24 +75,29 @@ public class CachedOutputStream extends
private File outputDir = DEFAULT_TEMP_DIR;
private boolean allowDeleteOfFile = true;
- private List<CachedOutputStreamCallback> callbacks;
+ private List<CachedWriterCallback> callbacks;
private List<Object> streamList = new ArrayList<Object>();
- public CachedOutputStream(PipedInputStream stream) throws IOException {
- currentStream = new PipedOutputStream(stream);
- inmem = true;
+
+ static class LoadingCharArrayWriter extends CharArrayWriter {
+ public LoadingCharArrayWriter() {
+ super(1024);
+ }
+ public char[] rawCharArray() {
+ return super.buf;
+ }
}
+
- public CachedOutputStream() {
- currentStream = new LoadingByteArrayOutputStream(2048);
+ public CachedWriter() {
+ currentStream = new LoadingCharArrayWriter();
inmem = true;
}
- public CachedOutputStream(long threshold) {
+ public CachedWriter(long threshold) {
+ this();
this.threshold = threshold;
- currentStream = new LoadingByteArrayOutputStream(2048);
- inmem = true;
}
public void holdTempFile() {
@@ -104,20 +107,20 @@ public class CachedOutputStream extends
allowDeleteOfFile = true;
}
- public void registerCallback(CachedOutputStreamCallback cb) {
+ public void registerCallback(CachedWriterCallback cb) {
if (null == callbacks) {
- callbacks = new ArrayList<CachedOutputStreamCallback>();
+ callbacks = new ArrayList<CachedWriterCallback>();
}
callbacks.add(cb);
}
- public void deregisterCallback(CachedOutputStreamCallback cb) {
+ public void deregisterCallback(CachedWriterCallback cb) {
if (null != callbacks) {
callbacks.remove(cb);
}
}
- public List<CachedOutputStreamCallback> getCallbacks() {
+ public List<CachedWriterCallback> getCallbacks() {
return callbacks == null ? null : Collections.unmodifiableList(callbacks);
}
@@ -132,7 +135,7 @@ public class CachedOutputStream extends
public void flush() throws IOException {
currentStream.flush();
if (null != callbacks) {
- for (CachedOutputStreamCallback cb : callbacks) {
+ for (CachedWriterCallback cb : callbacks) {
cb.onFlush(this);
}
}
@@ -165,7 +168,7 @@ public class CachedOutputStream extends
currentStream.flush();
outputLocked = true;
if (null != callbacks) {
- for (CachedOutputStreamCallback cb : callbacks) {
+ for (CachedWriterCallback cb : callbacks) {
cb.onClose(this);
}
}
@@ -177,7 +180,7 @@ public class CachedOutputStream extends
currentStream.flush();
outputLocked = true;
if (null != callbacks) {
- for (CachedOutputStreamCallback cb : callbacks) {
+ for (CachedWriterCallback cb : callbacks) {
cb.onClose(this);
}
}
@@ -191,8 +194,8 @@ public class CachedOutputStream extends
if (obj == this) {
return true;
}
- if (obj instanceof CachedOutputStream) {
- return currentStream.equals(((CachedOutputStream)obj).currentStream);
+ if (obj instanceof CachedWriter) {
+ return currentStream.equals(((CachedWriter)obj).currentStream);
}
return currentStream.equals(obj);
}
@@ -208,25 +211,22 @@ public class CachedOutputStream extends
* @param copyOldContent flag indicating if the old content should be copied
* @throws IOException
*/
- public void resetOut(OutputStream out, boolean copyOldContent) throws IOException {
+ public void resetOut(Writer out, boolean copyOldContent) throws IOException {
if (out == null) {
- out = new ByteArrayOutputStream();
+ out = new LoadingCharArrayWriter();
}
- if (currentStream instanceof CachedOutputStream) {
- CachedOutputStream ac = (CachedOutputStream) currentStream;
- InputStream in = ac.getInputStream();
+ if (currentStream instanceof CachedWriter) {
+ CachedWriter ac = (CachedWriter) currentStream;
+ Reader in = ac.getReader();
IOUtils.copyAndCloseInput(in, out);
} else {
if (inmem) {
- if (currentStream instanceof ByteArrayOutputStream) {
- ByteArrayOutputStream byteOut = (ByteArrayOutputStream) currentStream;
+ if (currentStream instanceof LoadingCharArrayWriter) {
+ LoadingCharArrayWriter byteOut = (LoadingCharArrayWriter) currentStream;
if (copyOldContent && byteOut.size() > 0) {
byteOut.writeTo(out);
}
- } else if (currentStream instanceof PipedOutputStream) {
- PipedOutputStream pipeOut = (PipedOutputStream) currentStream;
- IOUtils.copyAndCloseInput(new PipedInputStream(pipeOut), out);
} else {
throw new IOException("Unknown format of currentStream");
}
@@ -235,7 +235,7 @@ public class CachedOutputStream extends
currentStream.close();
if (copyOldContent) {
FileInputStream fin = new FileInputStream(tempFile);
- IOUtils.copyAndCloseInput(fin, out);
+ IOUtils.copyAndCloseInput(new InputStreamReader(fin, "UTF-8"), out);
}
streamList.remove(currentStream);
deleteTempFile();
@@ -246,74 +246,81 @@ public class CachedOutputStream extends
outputLocked = false;
}
- public static void copyStream(InputStream in, OutputStream out, int bufferSize) throws IOException {
- IOUtils.copyAndCloseInput(in, out, bufferSize);
- }
public long size() {
return totalLength;
}
- public byte[] getBytes() throws IOException {
+ public char[] getChars() throws IOException {
flush();
if (inmem) {
- if (currentStream instanceof ByteArrayOutputStream) {
- return ((ByteArrayOutputStream)currentStream).toByteArray();
+ if (currentStream instanceof LoadingCharArrayWriter) {
+ return ((LoadingCharArrayWriter)currentStream).toCharArray();
} else {
throw new IOException("Unknown format of currentStream");
}
} else {
// read the file
- FileInputStream fin = new FileInputStream(tempFile);
- return IOUtils.readBytesFromStream(fin);
+ Reader fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
+ CharArrayWriter out = new CharArrayWriter((int)tempFile.length());
+ char bytes[] = new char[1024];
+ int x = fin.read(bytes);
+ while (x != -1) {
+ out.write(bytes, 0, x);
+ x = fin.read(bytes);
+ }
+ fin.close();
+ return out.toCharArray();
}
}
- public void writeCacheTo(OutputStream out) throws IOException {
+ public void writeCacheTo(Writer out) throws IOException {
flush();
if (inmem) {
- if (currentStream instanceof ByteArrayOutputStream) {
- ((ByteArrayOutputStream)currentStream).writeTo(out);
+ if (currentStream instanceof LoadingCharArrayWriter) {
+ ((LoadingCharArrayWriter)currentStream).writeTo(out);
} else {
throw new IOException("Unknown format of currentStream");
}
} else {
// read the file
- FileInputStream fin = new FileInputStream(tempFile);
- IOUtils.copyAndCloseInput(fin, out);
+ Reader fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
+ char bytes[] = new char[1024];
+ int x = fin.read(bytes);
+ while (x != -1) {
+ out.write(bytes, 0, x);
+ x = fin.read(bytes);
+ }
+ fin.close();
}
}
public void writeCacheTo(StringBuilder out, long limit) throws IOException {
- writeCacheTo(out, "UTF-8", limit);
- }
-
- public void writeCacheTo(StringBuilder out, String charsetName, long limit) throws IOException {
flush();
if (totalLength < limit
|| limit == -1) {
- writeCacheTo(out, charsetName);
+ writeCacheTo(out);
return;
}
long count = 0;
if (inmem) {
- if (currentStream instanceof ByteArrayOutputStream) {
- byte bytes[] = ((ByteArrayOutputStream)currentStream).toByteArray();
- out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, (int)limit));
+ if (currentStream instanceof LoadingCharArrayWriter) {
+ LoadingCharArrayWriter s = (LoadingCharArrayWriter)currentStream;
+ out.append(s.rawCharArray(), 0, (int)limit);
} else {
throw new IOException("Unknown format of currentStream");
}
} else {
// read the file
- FileInputStream fin = new FileInputStream(tempFile);
- byte bytes[] = new byte[1024];
+ Reader fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
+ char bytes[] = new char[1024];
long x = fin.read(bytes);
while (x != -1) {
if ((count + x) > limit) {
x = limit - count;
}
- out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, (int)x));
+ out.append(bytes, 0, (int)x);
count += x;
if (count >= limit) {
@@ -327,28 +334,25 @@ public class CachedOutputStream extends
}
public void writeCacheTo(StringBuilder out) throws IOException {
- writeCacheTo(out, "UTF-8");
- }
-
- public void writeCacheTo(StringBuilder out, String charsetName) throws IOException {
flush();
if (inmem) {
- if (currentStream instanceof ByteArrayOutputStream) {
- byte[] bytes = ((ByteArrayOutputStream)currentStream).toByteArray();
- out.append(IOUtils.newStringFromBytes(bytes, charsetName));
+ if (currentStream instanceof LoadingCharArrayWriter) {
+ LoadingCharArrayWriter lcaw = (LoadingCharArrayWriter)currentStream;
+ out.append(lcaw.rawCharArray(), 0, lcaw.size());
} else {
throw new IOException("Unknown format of currentStream");
}
} else {
// read the file
FileInputStream fin = new FileInputStream(tempFile);
- byte bytes[] = new byte[1024];
- int x = fin.read(bytes);
+ Reader r = new InputStreamReader(fin, "UTF-8");
+ char chars[] = new char[1024];
+ int x = r.read(chars);
while (x != -1) {
- out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, x));
- x = fin.read(bytes);
+ out.append(chars, 0, x);
+ x = r.read(chars);
}
- fin.close();
+ r.close();
}
}
@@ -356,7 +360,7 @@ public class CachedOutputStream extends
/**
* @return the underlying output stream
*/
- public OutputStream getOut() {
+ public Writer getOut() {
return currentStream;
}
@@ -366,7 +370,7 @@ public class CachedOutputStream extends
public String toString() {
StringBuilder builder = new StringBuilder().append("[")
- .append(CachedOutputStream.class.getName())
+ .append(CachedWriter.class.getName())
.append(" Content: ");
try {
writeCacheTo(builder);
@@ -384,35 +388,18 @@ public class CachedOutputStream extends
if (maxSize > 0 && totalLength > maxSize) {
throw new CacheSizeExceededException();
}
- if (inmem && totalLength > threshold && currentStream instanceof ByteArrayOutputStream) {
+ if (inmem && totalLength > threshold && currentStream instanceof LoadingCharArrayWriter) {
createFileOutputStream();
}
}
- public void write(byte[] b, int off, int len) throws IOException {
+
+ public void write(char[] cbuf, int off, int len) throws IOException {
if (!outputLocked) {
onWrite();
this.totalLength += len;
enforceLimits();
- currentStream.write(b, off, len);
- }
- }
-
- public void write(byte[] b) throws IOException {
- if (!outputLocked) {
- onWrite();
- this.totalLength += b.length;
- enforceLimits();
- currentStream.write(b);
- }
- }
-
- public void write(int b) throws IOException {
- if (!outputLocked) {
- onWrite();
- this.totalLength++;
- enforceLimits();
- currentStream.write(b);
+ currentStream.write(cbuf, off, len);
}
}
@@ -420,15 +407,15 @@ public class CachedOutputStream extends
if (tempFileFailed) {
return;
}
- ByteArrayOutputStream bout = (ByteArrayOutputStream)currentStream;
+ LoadingCharArrayWriter bout = (LoadingCharArrayWriter)currentStream;
try {
if (outputDir == null) {
tempFile = FileUtils.createTempFile("cos", "tmp");
} else {
tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false);
}
-
- currentStream = new BufferedOutputStream(new FileOutputStream(tempFile));
+ FileOutputStream fout = new FileOutputStream(tempFile);
+ currentStream = new OutputStreamWriter(fout, "UTF-8");
bout.writeTo(currentStream);
inmem = false;
streamList.add(currentStream);
@@ -449,15 +436,12 @@ public class CachedOutputStream extends
return tempFile != null && tempFile.exists() ? tempFile : null;
}
- public InputStream getInputStream() throws IOException {
+ public Reader getReader() throws IOException {
flush();
if (inmem) {
- if (currentStream instanceof LoadingByteArrayOutputStream) {
- return ((LoadingByteArrayOutputStream) currentStream).createInputStream();
- } else if (currentStream instanceof ByteArrayOutputStream) {
- return new ByteArrayInputStream(((ByteArrayOutputStream) currentStream).toByteArray());
- } else if (currentStream instanceof PipedOutputStream) {
- return new PipedInputStream((PipedOutputStream) currentStream);
+ if (currentStream instanceof LoadingCharArrayWriter) {
+ LoadingCharArrayWriter lcaw = (LoadingCharArrayWriter)currentStream;
+ return new CharArrayReader(lcaw.rawCharArray(), 0, lcaw.size());
} else {
return null;
}
@@ -473,8 +457,9 @@ public class CachedOutputStream extends
closed = true;
}
};
- streamList.add(fileInputStream);
- return fileInputStream;
+ Reader r = new InputStreamReader(fileInputStream, "UTF-8");
+ streamList.add(r);
+ return r;
} catch (FileNotFoundException e) {
throw new IOException("Cached file was deleted, " + e.toString());
}
@@ -500,7 +485,7 @@ public class CachedOutputStream extends
}
}
deleteTempFile();
- currentStream = new LoadingByteArrayOutputStream(1024);
+ currentStream = new LoadingCharArrayWriter();
inmem = true;
}
}
@@ -518,7 +503,7 @@ public class CachedOutputStream extends
public static void setDefaultMaxSize(long l) {
if (l == -1) {
- String s = System.getProperty("org.apache.cxf.io.CachedOutputStream.MaxSize",
+ String s = System.getProperty("org.apache.cxf.io.CachedWriter.MaxSize",
"-1");
l = Long.parseLong(s);
}
@@ -526,7 +511,7 @@ public class CachedOutputStream extends
}
public static void setDefaultThreshold(int i) {
if (i == -1) {
- String s = SystemPropertyAction.getProperty("org.apache.cxf.io.CachedOutputStream.Threshold",
+ String s = SystemPropertyAction.getProperty("org.apache.cxf.io.CachedWriter.Threshold",
"-1");
i = Integer.parseInt(s);
if (i <= 0) {
@@ -536,4 +521,5 @@ public class CachedOutputStream extends
defaultThreshold = i;
}
+
}
Added: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriterCallback.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriterCallback.java?rev=1391228&view=auto
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriterCallback.java (added)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriterCallback.java Thu Sep 27 21:45:06 2012
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.io;
+
+public interface CachedWriterCallback {
+
+ void onClose(CachedWriter os);
+ void onFlush(CachedWriter os);
+
+}