Interface LocalTransactionProvider

All Superinterfaces:
TransactionProvider
All Known Implementing Classes:
JBossLocalTransactionProvider

public interface LocalTransactionProvider extends TransactionProvider
A local transaction provider. Such a provider must implement all methods on this interface in order for local transactions to be supported.
Author:
David M. Lloyd
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    An empty provider which does not support new transactions.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    commitLocal(jakarta.transaction.Transaction transaction)
    Locally commit the given provider transaction.
    jakarta.transaction.Transaction
    createNewTransaction(int timeout)
    Create and start a new local transaction, which is not associated with any particular thread.
    void
    dropLocal(jakarta.transaction.Transaction transaction)
    Drop a local transaction from memory.
    void
    dropRemote(jakarta.transaction.Transaction transaction)
    The transaction is expected to work with outflowed resources - it contains a remote subordinate enlistment.
    getKey(jakarta.transaction.Transaction transaction)
    Get a key which has the same equals and hashCode behavior as the given transaction.
    default String
    Attempt to derive a node name from an XID.
    Get the unique node name of this provider.
    default <T> T
    getProviderInterface(jakarta.transaction.Transaction transaction, Class<T> providerInterfaceType)
    Attempt to acquire a provider interface instance from the given provider transaction.
    getResource(jakarta.transaction.Transaction transaction, Object key)
    Get a resource associated with the given transaction.
    boolean
    getRollbackOnly(jakarta.transaction.Transaction transaction)
    Determine if the given transaction is rollback-only.
    int
    getTimeout(jakarta.transaction.Transaction transaction)
    Get the configured timeout of the given transaction (not the remaining time).
    jakarta.transaction.TransactionManager
    Get the transaction manager.
    Get the XA importer.
    Return the XAResource registry associated with transaction.
    getXid(jakarta.transaction.Transaction transaction)
    Get the transaction ID of the given transaction.
    boolean
    isImported(jakarta.transaction.Transaction transaction)
    Determine whether the given transaction was imported or originated locally.
    void
    putResource(jakarta.transaction.Transaction transaction, Object key, Object value)
    Put a resource on to the given transaction.
    putResourceIfAbsent(jakarta.transaction.Transaction transaction, Object key, Object value)
    Put a resource on to the given transaction if the resource does not already exist.
    void
    registerInterposedSynchronization(jakarta.transaction.Transaction transaction, jakarta.transaction.Synchronization sync)
    Register an interposed synchronization on the given transaction.
    void
    rollbackLocal(jakarta.transaction.Transaction transaction)
    Locally roll back the given provider transaction.
  • Field Details

  • Method Details

    • getTransactionManager

      @NotNull jakarta.transaction.TransactionManager getTransactionManager()
      Get the transaction manager.
      Returns:
      the transaction manager (must not be null)
    • getXAImporter

      @NotNull XAImporter getXAImporter()
      Get the XA importer.
      Returns:
      the XA importer (must not be null)
    • createNewTransaction

      @NotNull jakarta.transaction.Transaction createNewTransaction(int timeout) throws jakarta.transaction.SystemException, SecurityException
      Create and start a new local transaction, which is not associated with any particular thread.
      Parameters:
      timeout - the timeout to use for the new transaction
      Returns:
      the new transaction (must not be null)
      Throws:
      jakarta.transaction.SystemException - if the creation of the transaction failed for some reason
      SecurityException - if the caller is not authorized to create a transaction
    • isImported

      boolean isImported(@NotNull jakarta.transaction.Transaction transaction) throws IllegalArgumentException
      Determine whether the given transaction was imported or originated locally.
      Parameters:
      transaction - the transaction to test (not null)
      Returns:
      true if the transaction was imported, or false if it was created locally
      Throws:
      IllegalArgumentException - if the transaction does not belong to this provider
    • registerInterposedSynchronization

      void registerInterposedSynchronization(@NotNull jakarta.transaction.Transaction transaction, @NotNull jakarta.transaction.Synchronization sync) throws IllegalArgumentException
      Register an interposed synchronization on the given transaction.
      Parameters:
      transaction - the transaction (not null)
      sync - the synchronization (not null)
      Throws:
      IllegalArgumentException - if the transaction does not belong to this provider
    • getResource

      Object getResource(@NotNull jakarta.transaction.Transaction transaction, @NotNull Object key)
      Get a resource associated with the given transaction.
      Parameters:
      transaction - the transaction (not null)
      key - the key to look up (not null)
      Returns:
      the resource, or null if none is set
      Throws:
      IllegalArgumentException - if the transaction does not belong to this provider
    • putResource

      void putResource(@NotNull jakarta.transaction.Transaction transaction, @NotNull Object key, Object value) throws IllegalArgumentException
      Put a resource on to the given transaction.
      Parameters:
      transaction - the transaction (not null)
      key - the key to store under (not null)
      value - the value to store
      Throws:
      IllegalArgumentException - if the transaction does not belong to this provider
    • putResourceIfAbsent

      Object putResourceIfAbsent(@NotNull jakarta.transaction.Transaction transaction, @NotNull Object key, Object value) throws IllegalArgumentException
      Put a resource on to the given transaction if the resource does not already exist. Providers which do not support this operation must emulate it.
      Parameters:
      transaction - the transaction (must not be null)
      key - the key to store under (not null)
      value - the value to store
      Returns:
      the existing value, or null if none is set
      Throws:
      IllegalArgumentException - if the transaction does not belong to this provider
    • getRollbackOnly

      boolean getRollbackOnly(@NotNull jakarta.transaction.Transaction transaction) throws IllegalArgumentException
      Determine if the given transaction is rollback-only.
      Parameters:
      transaction - the transaction (not null)
      Returns:
      true if the transaction is rollback-only, false otherwise
      Throws:
      IllegalArgumentException - if the transaction does not belong to this provider
    • getKey

      @NotNull Object getKey(@NotNull jakarta.transaction.Transaction transaction) throws IllegalArgumentException
      Get a key which has the same equals and hashCode behavior as the given transaction.
      Parameters:
      transaction - the transaction (not null)
      Returns:
      the key object (must not be null)
      Throws:
      IllegalArgumentException - if the transaction does not belong to this provider
    • commitLocal

      void commitLocal(@NotNull jakarta.transaction.Transaction transaction) throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, IllegalStateException, jakarta.transaction.SystemException
      Locally commit the given provider transaction. A given provider transaction will only be committed by this method or SubordinateTransactionControl.commit(boolean).
      Parameters:
      transaction - the transaction (not null)
      Throws:
      jakarta.transaction.RollbackException - if the local commit operation throws this exception
      jakarta.transaction.HeuristicMixedException - if the local commit operation throws this exception
      jakarta.transaction.HeuristicRollbackException - if the local commit operation throws this exception
      SecurityException - if the local commit operation throws this exception
      IllegalStateException - if the local commit operation throws this exception
      jakarta.transaction.SystemException - if the local commit operation throws this exception
    • rollbackLocal

      void rollbackLocal(@NotNull jakarta.transaction.Transaction transaction) throws IllegalStateException, jakarta.transaction.SystemException
      Locally roll back the given provider transaction. A given provider transaction will only be rolled back by this method or SubordinateTransactionControl.rollback().
      Parameters:
      transaction - the transaction (not null)
      Throws:
      IllegalStateException - if the local commit operation throws this exception
      jakarta.transaction.SystemException - if the local commit operation throws this exception
    • dropLocal

      void dropLocal(@NotNull jakarta.transaction.Transaction transaction)
      Drop a local transaction from memory. The transaction is locally-initiated and contains no remote subordinate enlistments, guaranteeing that the transaction can never reappear on this node.
      Parameters:
      transaction - the transaction to drop (not null)
    • dropRemote

      void dropRemote(@NotNull jakarta.transaction.Transaction transaction)
      The transaction is expected to work with outflowed resources - it contains a remote subordinate enlistment. We can't use the dropLocal(Transaction) directly as the the transaction may reapear on this node during recovery. But this method gives a chance to the provider to reassign the removal timeout or some other work that needs to be done in case the in-flight transaction finished.
      Parameters:
      transaction - the transaction with ouflowed resources to announce of being finished (not null)
    • getTimeout

      int getTimeout(@NotNull jakarta.transaction.Transaction transaction)
      Get the configured timeout of the given transaction (not the remaining time).
      Parameters:
      transaction - the transaction (not null)
      Returns:
      the number of seconds remaining
    • getXid

      @NotNull Xid getXid(@NotNull jakarta.transaction.Transaction transaction)
      Get the transaction ID of the given transaction.
      Parameters:
      transaction - the transaction (not null)
      Returns:
      the transaction ID (must not be null)
    • getNodeName

      @NotNull String getNodeName()
      Get the unique node name of this provider.
      Returns:
      the node name (must not be null)
    • getNameFromXid

      default String getNameFromXid(@NotNull Xid xid)
      Attempt to derive a node name from an XID. If the XID is not in a recognized format, null is returned.
      Parameters:
      xid - the XID (not null)
      Returns:
      the originating node name
    • getProviderInterface

      default <T> T getProviderInterface(jakarta.transaction.Transaction transaction, Class<T> providerInterfaceType)
      Attempt to acquire a provider interface instance from the given provider transaction.
      Type Parameters:
      T - the provider interface type
      Parameters:
      transaction - the provider transaction (not null)
      providerInterfaceType - the provider interface type class (not null)
      Returns:
      the provider interface instance, or null if none matches
    • getXAResourceRegistry

      default XAResourceRegistry getXAResourceRegistry(LocalTransaction transaction) throws jakarta.transaction.SystemException
      Return the XAResource registry associated with transaction. If there is no such registry yet, one is created.
      Parameters:
      transaction - the transaction
      Returns:
      the registry associated with transaction. Can return null if this provider requires no XAResource registry
      Throws:
      jakarta.transaction.SystemException