Class TransactionAwareProxyFactory<T>

java.lang.Object
org.springframework.batch.infrastructure.support.transaction.TransactionAwareProxyFactory<T>

@NullUnmarked @Deprecated(since="6.0", forRemoval=true) public class TransactionAwareProxyFactory<T> extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
since 6.0 with no replacement. Scheduled for removal in 6.2 or later.

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.

Generally not intended for multi-threaded use, but the append only version of collections gives isolation between threads operating on different keys in a map, provided they only append to the map. (Threads are limited to removing entries that were created in the same transaction.)

Author:
Dave Syer
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final T
    begin(T target)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Make a copy of the target that can be used inside a transaction to isolate changes from the original.
    protected void
    commit(T copy, T target)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Take the working copy state and commit it back to the original target.
    static <T> List<T>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static <K,V> ConcurrentMap<K,V>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static <T> Set<T>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static <T> List<T>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static <T> List<T>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static <K,V> Map<K,V>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static <K,V> Map<K,V>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static <T> Set<T>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static <T> Set<T>
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • begin

      protected final T begin(T target)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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(T copy, T target)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.
    • createTransactionalMap

      public static <K,V> Map<K,V> createTransactionalMap()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createTransactionalMap

      public static <K,V> Map<K,V> createTransactionalMap(Map<K,V> map)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createAppendOnlyTransactionalMap

      public static <K,V> ConcurrentMap<K,V> createAppendOnlyTransactionalMap()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createAppendOnlyTransactionalSet

      public static <T> Set<T> createAppendOnlyTransactionalSet()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createTransactionalSet

      public static <T> Set<T> createTransactionalSet()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createTransactionalSet

      public static <T> Set<T> createTransactionalSet(Set<T> set)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createAppendOnlyTransactionalList

      public static <T> List<T> createAppendOnlyTransactionalList()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createTransactionalList

      public static <T> List<T> createTransactionalList()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createTransactionalList

      public static <T> List<T> createTransactionalList(List<T> list)
      Deprecated, for removal: This API element is subject to removal in a future version.