org.springframework.batch.support.transaction
Class TransactionAwareProxyFactory
java.lang.Object
org.springframework.batch.support.transaction.TransactionAwareProxyFactory
public class TransactionAwareProxyFactory
- extends Object
Factory for transaction aware objects (like lists, sets, maps). If a
transaction is active when a method is called on an instance created by the
factory, it makes a copy of the target object and carries out all operations
on the copy. Only when the transaction commits is the target re-initialised
with the copy.
Works well with collections and maps for testing transactional behaviour
without needing a database. The base implementation handles lists, sets and
maps. Subclasses can implement begin(Object)
and
commit(Object, Object)
to provide support for other resources.
- Author:
- Dave Syer
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TransactionAwareProxyFactory
public TransactionAwareProxyFactory(Object target)
begin
protected final Object begin(Object target)
- Make a copy of the target that can be used inside a transaction to
isolate changes from the original. Also called from the factory
constructor to isolate the target from the original value passed in.
- Parameters:
target
- the target object (List, Set or Map)
- Returns:
- an independent copy
commit
protected void commit(Object copy,
Object target)
- Take the working copy state and commit it back to the original target.
The target then reflects all the changes applied to the copy during a
transaction.
- Parameters:
copy
- the working copy.target
- the original target of the factory.
createInstance
public Object createInstance()
createTransactionalMap
public static Map createTransactionalMap()
createTransactionalSet
public static Set createTransactionalSet()
createTransactionalList
public static List createTransactionalList()
Copyright © 2009 SpringSource. All Rights Reserved.