Package org.springframework.batch.core.scope.context

# 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 Summary

  Constructors
  Constructor
  Description
  `SynchronizationManagerSupport()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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.
  `protected abstract void`
  `close(C context)`
  `protected abstract C`
  `createNewContext(E execution)`
  `C`
  `getContext()`
  Getter for the current context if there is one, otherwise returns `null`.
  `Stack<E>`
  `getCurrent()`
  `void`
  `increment()`
  `C`
  `register(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.
  `void`
  `release()`
  A convenient "deep" close operation.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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)