use of org.apache.axiom.attachments.utils.BAAOutputStream in project webservices-axiom by apache.
the class DetachableInputStream method detach.
/**
* Consume the input stream and close it.
* The bytes in the input stream are buffered.
* (Thus the original input stream can release its
* resources, but the consumer of the stream can
* still receive data).
* @throws IOException
*/
public void detach() throws IOException {
if (localStream == null && !isClosed) {
BAAOutputStream baaos = new BAAOutputStream();
try {
// It is possible that the underlying stream was closed
BufferUtils.inputStream2OutputStream(in, baaos);
super.close();
} catch (Throwable t) {
if (log.isDebugEnabled()) {
log.debug("detach caught exception. Processing continues:" + t);
log.debug(" " + stackToString(t));
}
} finally {
// GC the incoming stream
in = null;
}
localStream = new BAAInputStream(baaos.buffers(), baaos.length());
if (log.isDebugEnabled()) {
log.debug("The local stream built from the detached " + "stream has a length of:" + baaos.length());
}
count = count + baaos.length();
}
}
use of org.apache.axiom.attachments.utils.BAAOutputStream in project webservices-axiom by apache.
the class ParserInputStreamDataSource method copy.
/**
* Return a InputStreamDataSource backed by a ByteArrayInputStream
*/
@Override
public OMDataSourceExt copy() {
if (log.isDebugEnabled()) {
log.debug("Enter ParserInputStreamDataSource.copy()");
}
try {
BAAOutputStream baaos = new BAAOutputStream();
BufferUtils.inputStream2OutputStream(data.readParserInputStream(), baaos);
BAAInputStream baais = new BAAInputStream(baaos.buffers(), baaos.length());
if (log.isDebugEnabled()) {
log.debug("Exit ParserInputStreamDataSource.copy()");
}
return new ParserInputStreamDataSource(baais, data.encoding, data.behavior);
} catch (Throwable t) {
if (log.isDebugEnabled()) {
log.debug("Error ParserInputStreamDataSource.copy(): ", t);
}
throw new OMException(t);
}
}
Aggregations