Class DefaultTransactionProvider

java.lang.Object
org.openspaces.core.transaction.DefaultTransactionProvider
All Implemented Interfaces:
SpaceTransactionProvider, Closeable, AutoCloseable, TransactionProvider

public class DefaultTransactionProvider extends Object implements TransactionProvider
Default transaction provider works in conjunction with JiniPlatformTransactionManager and one of its derived classes. Uses Spring support for transactional resource binding (using thread local) in order to get the current transaction. If no transaction is active, will return null (which means the operation will be executed under no transaction).

Also supports for Spring JTA transaction by automatically creating and binding GigaSpaces support for XA.

As a transaction context it uses the one passed to its constructor, and not the runtime transactional context provided to getCurrentTransaction(Object, com.j_spaces.core.IJSpace)

Author:
kimchy
See Also:
  • Constructor Details

    • DefaultTransactionProvider

      public DefaultTransactionProvider(IJSpace space, org.springframework.transaction.PlatformTransactionManager transactionManager)
    • DefaultTransactionProvider

      public DefaultTransactionProvider(IJSpace space, Object actualTransactionalContext, org.springframework.transaction.PlatformTransactionManager transactionManager)
      Creates a new transaction provider. Will use the provided transactional context in order to fetch the current running transaction.
      Parameters:
      actualTransactionalContext - The transactional context to fetch the transaction by
  • Method Details

    • getCurrentTransaction

      public Transaction getCurrentTransaction()
      Description copied from interface: SpaceTransactionProvider
      Returns the currently running transaction (usually managed externally/declarative).

      If no transaction is currently executing, null value will be returned. This usually means that the operation will be performed without a transaction.

      Specified by:
      getCurrentTransaction in interface SpaceTransactionProvider
      Returns:
      The transaction object to be used (can be null).
    • getCurrentTransaction

      public Transaction.Created getCurrentTransaction(Object transactionalContext, IJSpace space)
      Returns the current running transaction based on the constructor provided transactional context (Note that the passed transactional context is not used).

      Uses Spring support for transactional resource registration in order to fetch the current running transaction (or the JiniTransactionHolder. An example of Spring platform transaction managers that register it are ones derived form AbstractJiniTransactionManager.

      If no transaction is found bound the the transactional context (provided in the constructor), null is returned. This means that operations will execute without a transaction.

      Specified by:
      getCurrentTransaction in interface TransactionProvider
      Parameters:
      transactionalContext - Not Used. The transactional context used is the one provided in the constructor.
      space - The actual Space this operation will be performed on
      Returns:
      The current running transaction or null if no transaction is running
    • getTransactionManager

      public org.springframework.transaction.PlatformTransactionManager getTransactionManager()
    • getHolder

      public JiniTransactionHolder getHolder()
    • getCurrentTransactionIsolationLevel

      public IsolationLevelModifiers getCurrentTransactionIsolationLevel()
      Description copied from interface: SpaceTransactionProvider
      Returns the currently running transaction isolation level.
      Specified by:
      getCurrentTransactionIsolationLevel in interface SpaceTransactionProvider
      Returns:
      The transaction isolation level.
    • getCurrentTransactionIsolationLevel

      public int getCurrentTransactionIsolationLevel(Object transactionalContext)
      Description copied from interface: TransactionProvider
      Returns the currently running transaction isolation level (mapping to Spring TransactionDefinition.getIsolationLevel() values). A transactional context can be passed and optionally used in order to fetch the current running transaction.
      Specified by:
      getCurrentTransactionIsolationLevel in interface TransactionProvider
      Parameters:
      transactionalContext - Transactional context to (optionally) fetch the transaction by
      Returns:
      The transaction isolation level mapping to Spring TransactionDefinition.getIsolationLevel().
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: SpaceTransactionProvider
      Returns true if this transaction provider is enabled or not.
      Specified by:
      isEnabled in interface SpaceTransactionProvider
    • destroy

      public void destroy() throws RemoteException
      Throws:
      RemoteException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException