Package com.emc.documentum.rest.dfc

# Interface ContextSessionManager

public interface ContextSessionManager
An interface to provide the functions to get the context DFC session. A context DFC session is used in one or multiple transactional operations. Implementation beans for this interface could be autowired in callers. Below is the right usage of methods in `ContextSessionManager`.

      @Autowired
      ContextSessionManager contextSessionManager;

      try {
         // enable using context DFC session
         contextSessionManager.enableContextSession();
         // do whatever DFC operations using RepositorySession
         // ...
         // complete using context DFC session
         contextSessionManager.completeContextSession();
      } catch(DfException e) {
         // abort and clear context DFC session
         contextSessionManager.abortContextSession();
         // error handling
         // ...
      }

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `ContextSessionManager.SessionCallable<V>`
  Callable operation with automatically assigning the session

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `abortContextSession()`
  Abort the context DFC session, indicating to rollback intermediate work done by this session if it is in transaction.
  `void`
  `completeContextSession()`
  Complete the context DFC session, indicating to commit intermediate work done by this session if it is in transaction.
  `void`
  `enableContextSession(boolean makeTransactional)`
  Enable using context wide DFC session, indicating that the session got from `RepositorySession` will be marked as private to this security context, and it will not be released until `completeContextSession` or `abortContextSession` is called.
  `<T> T`
  `executeWithinTheContextTran(ContextSessionManager.SessionCallable<T> operation)`
  Execute the operation within the current context transaction If the context transaction is enabled before, then the operation will be executed within the current context.
  `<T> T`
  `executeWithinTheContextTran(Callable<T> operation)`
  Deprecated.
  `executeWithinTheContextTran(SessionCallable)`
  `com.documentum.fc.client.IDfSession`
  `getContextSession()`
  FOR INTERNAL USE.
  `boolean`
  `isContextSessionEnabled()`
  Check whether using context wide DFC session is enabled.
  `boolean`
  `isContextSessionTransactional()`
  Check whether using context DFC session is marked as transactional
  `void`
  `setContextSession(com.documentum.fc.client.IDfSession session)`
  FOR INTERNAL USE.

- ## Method Details

  - ### enableContextSession

    void enableContextSession(boolean makeTransactional)
    Enable using context wide DFC session, indicating that the session got from `RepositorySession` will be marked as private to this security context, and it will not be released until `completeContextSession` or `abortContextSession` is called.
    Parameters:
      `makeTransactional` - mark the context DFC session as transactional, indicating that the intermediate work done by this session won't be committed until `completeContextSession` is called.
    See Also:
      - `RepositorySession`
      - `completeContextSession()`
      - `abortContextSession()`

  - ### isContextSessionEnabled

    boolean isContextSessionEnabled()
    Check whether using context wide DFC session is enabled.
    Returns:
      `true` if the context session is enabled; `false` for otherwise.

  - ### isContextSessionTransactional

    boolean isContextSessionTransactional()
    Check whether using context DFC session is marked as transactional
    Returns:
      TRUE indicates using context session is transactional; FALSE for otherwise.

  - ### completeContextSession

    void completeContextSession() throws com.documentum.fc.common.DfException
    Complete the context DFC session, indicating to commit intermediate work done by this session if it is in transaction. This session will be released after completion.
    Throws:
      `com.documentum.fc.common.DfException` - the exception during the operation

  - ### abortContextSession

    void abortContextSession()
    Abort the context DFC session, indicating to rollback intermediate work done by this session if it is in transaction. This session will be released after abortion.

  - ### getContextSession

    com.documentum.fc.client.IDfSession getContextSession()
    FOR INTERNAL USE. Get the context DFC session being used; it may return null if context session is not initialized yet. Do not call this method in controllers.
    Returns:
      the context DFC session being used

  - ### setContextSession

    void setContextSession(com.documentum.fc.client.IDfSession session)
    FOR INTERNAL USE. Set the context DFC session. Do not call this method in controllers.
    Parameters:
      `session` - the DFC session to be set as context wide usage.

  - ### executeWithinTheContextTran

    @Deprecated <T> T executeWithinTheContextTran(Callable<T> operation) throws com.documentum.fc.common.DfException
    Deprecated.
    `executeWithinTheContextTran(SessionCallable)`
    Execute the operation within the current context transaction If the context transaction is enabled before, then the operation will be executed within the current context. The context will not start or commit the transaction. The transaction is controlled by the owner who starts the context transaction, e.g. an operation in the batch. Otherwise, the transaction will be started and committed/aborted when executing the operation.
    Type Parameters:
      `T` - the operation result
    Parameters:
      `operation` - the operation to be executed
    Returns:
      the executed result
    Throws:
      `com.documentum.fc.common.DfException` - exception during the operation

  - ### executeWithinTheContextTran

    <T> T executeWithinTheContextTran(ContextSessionManager.SessionCallable<T> operation) throws com.documentum.fc.common.DfException
    Execute the operation within the current context transaction If the context transaction is enabled before, then the operation will be executed within the current context. The context will not start or commit the transaction. The transaction is controlled by the owner who starts the context transaction, e.g. an operation in the batch. Otherwise, the transaction will be started and committed/aborted when executing the operation.
    Type Parameters:
      `T` - the operation result
    Parameters:
      `operation` - the operation to be executed
    Returns:
      the executed result
    Throws:
      `com.documentum.fc.common.DfException` - exception during the operation