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 java.lang.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 and Description
    `SynchronizationManagerSupport()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and 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, BatchPropertyContext propertyContext)`
    `C` | `getContext()` Getter for the current context if there is one, otherwise returns `null`.
    `java.util.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.
    `C` | `register(E execution, BatchPropertyContext propertyContext)` 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 Detail

    - #### SynchronizationManagerSupport

          public SynchronizationManagerSupport()

  - ### Method Detail

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

    - #### register

          @Nullable
          public C register(@Nullable
                                      E execution,
                                      @Nullable
                                      BatchPropertyContext propertyContext)

      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
        `propertyContext` - instance of `BatchPropertyContext` to be registered with this thread.
      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 java.util.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,
                                                @Nullable
                                                BatchPropertyContext propertyContext)