Class SynchronizationManagerSupport<E,C>

java.lang.Object
org.springframework.batch.core.scope.context.SynchronizationManagerSupport<E,C>

public abstract class SynchronizationManagerSupport<E,C> extends Object
Central convenience class for framework use in managing the scope context.
Since:
3.0
Author:
Dave Syer, Jimmy Praet, Mahmoud Ben Hassine
  • Constructor Details

    • SynchronizationManagerSupport

      public SynchronizationManagerSupport()
  • Method Details

    • getContext

      @Nullable public C getContext()
      Getter for the current context if there is one, otherwise returns null.
      Returns:
      the current context or null if there is none (if one has not been registered for this thread).
    • register

      @Nullable public C register(@Nullable E execution)
      Register a context with the current thread - always put a matching close() call in a finally block to ensure that the correct context is available in the enclosing block.
      Parameters:
      execution - the execution to register
      Returns:
      a new context or the current one if it has the same execution
    • close

      public void close()
      Method for unregistering the current context - should always and only be used by in conjunction with a matching register(Object) to ensure that getContext() always returns the correct value. Does not call close on the context - that is left up to the caller because he has a reference to the context (having registered it) and only he has knowledge of when the execution actually ended.
    • increment

      public void increment()
    • getCurrent

      public Stack<E> getCurrent()
    • release

      public void release()
      A convenient "deep" close operation. Call this instead of close() if the execution for the current context is ending. Delegates to close(Object) and then ensures that close() is also called in a finally block.
    • close

      protected abstract void close(C context)
    • createNewContext

      protected abstract C createNewContext(E execution)