org.springframework.batch.item.database
Class AbstractTransactionalResourceItemWriter

java.lang.Object
  extended by org.springframework.batch.item.database.AbstractTransactionalResourceItemWriter
All Implemented Interfaces:
ItemWriter
Direct Known Subclasses:
BatchSqlUpdateItemWriter, HibernateAwareItemWriter

public abstract class AbstractTransactionalResourceItemWriter
extends Object
implements ItemWriter

Stores items in transactional resource and flushes aggressively in case of failure. This is useful for batch update writers which need to identify the failed item after failed flush.

Author:
Dave Syer, Robert Kasanicky
See Also:
BatchSqlUpdateItemWriter, HibernateAwareItemWriter

Constructor Summary
AbstractTransactionalResourceItemWriter()
           
 
Method Summary
 void clear()
          Delegate to subclass and unbind transactional resources, effectively clearing the item buffer.
protected abstract  void doClear()
          Callback method of clear().
protected abstract  void doFlush()
          Callback method of flush().
protected abstract  void doWrite(Object output)
          Callback method of write(Object).
 void flush()
          Flushing delegated to subclass surrounded by binding and unbinding of transactional resources.
protected  Set getProcessed()
          Accessor for the list of processed items in this transaction.
protected abstract  String getResourceKey()
           
 void write(Object output)
          Delegate to subclass to actually do the writing, but flushes aggressively if the item was previously part of a failed chunk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTransactionalResourceItemWriter

public AbstractTransactionalResourceItemWriter()
Method Detail

flush

public void flush()
           throws FlushFailedException
Flushing delegated to subclass surrounded by binding and unbinding of transactional resources.

Specified by:
flush in interface ItemWriter
Throws:
FlushFailedException - in case of an error. If this exception is thrown the writer may be in an inconsistent state and manual intervention might be required to reconcile the data with persistent output.
See Also:
ItemWriter.flush()

write

public void write(Object output)
           throws Exception
Delegate to subclass to actually do the writing, but flushes aggressively if the item was previously part of a failed chunk.

Specified by:
write in interface ItemWriter
Throws:
Exception
See Also:
ItemWriter.write(Object)

clear

public void clear()
           throws ClearFailedException
Delegate to subclass and unbind transactional resources, effectively clearing the item buffer.

Specified by:
clear in interface ItemWriter
Throws:
ClearFailedException - in case of an error. If this exception is thrown the writer may be in an inconsistent state and manual intervention might be required to reconcile the data with persistent output.

doFlush

protected abstract void doFlush()
                         throws FlushFailedException
Callback method of flush().

Throws:
FlushFailedException

doClear

protected abstract void doClear()
                         throws ClearFailedException
Callback method of clear().

Throws:
ClearFailedException

doWrite

protected abstract void doWrite(Object output)
                         throws Exception
Callback method of write(Object).

Throws:
Exception

getResourceKey

protected abstract String getResourceKey()
Returns:
Key for items processed in the current transaction RepeatContext.

getProcessed

protected Set getProcessed()
Accessor for the list of processed items in this transaction.

Returns:
the processed


Copyright © 2009 SpringSource. All Rights Reserved.