org.springframework.batch.support.transaction
Class TransactionAwareBufferedWriter
java.lang.Object
java.io.Writer
org.springframework.batch.support.transaction.TransactionAwareBufferedWriter
- All Implemented Interfaces:
- Closeable, Flushable, Appendable
public class TransactionAwareBufferedWriter
- extends Writer
Wrapper for a Writer
that delays actually writing to or closing the
buffer if a transaction is active. If a transaction is detected on the call
to Writer.write(String)
the parameter is buffered and passed on to the
underlying writer only when the transaction is committed.
- Author:
- Dave Syer
Method Summary |
void |
close()
|
void |
flush()
|
long |
getBufferSize()
Convenience method for clients to determine if there is any unflushed
data. |
void |
write(char[] cbuf,
int off,
int len)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TransactionAwareBufferedWriter
public TransactionAwareBufferedWriter(Writer writer,
Runnable closeCallback)
- Create a new instance with the underlying writer provided, and a callback
to execute on close. The callback should clean up related resources like
output streams or channels.
- Parameters:
writer
- actually writes to outputcloseCallback
- callback to execute on close
getBufferSize
public long getBufferSize()
- Convenience method for clients to determine if there is any unflushed
data.
- Returns:
- the current size of unflushed buffered data
close
public void close()
throws IOException
- Specified by:
close
in interface Closeable
- Specified by:
close
in class Writer
- Throws:
IOException
flush
public void flush()
throws IOException
- Specified by:
flush
in interface Flushable
- Specified by:
flush
in class Writer
- Throws:
IOException
write
public void write(char[] cbuf,
int off,
int len)
throws IOException
- Specified by:
write
in class Writer
- Throws:
IOException
Copyright © 2013 SpringSource. All Rights Reserved.