Class AbstractTransactionService

java.lang.Object
org.exoplatform.services.transaction.impl.AbstractTransactionService
All Implemented Interfaces:
TransactionService
Direct Known Subclasses:
JBossTransactionService, TransactionsEssentialsTransactionService

public abstract class AbstractTransactionService extends Object implements TransactionService
This abstract class implements the main logic of all the methods expected for a TransactionService. If you intend to use a TransactionManager in standalone mode (not manager by your Application Server), you can set the transaction timeout thanks to the value-param called timeout the value of this parameter is expressed in seconds.
Version:
$Id$
Author:
Nicolas Filotto
  • Field Details

    • defaultTimeout

      protected final int defaultTimeout
      The default timeout
    • forceTimeout

      protected final boolean forceTimeout
      Indicates if the timeout has to be enforced
  • Constructor Details

    • AbstractTransactionService

      public AbstractTransactionService()
    • AbstractTransactionService

      public AbstractTransactionService(org.exoplatform.container.xml.InitParams params)
  • Method Details

    • delistResource

      public boolean delistResource(XAResource xares) throws javax.transaction.RollbackException, javax.transaction.SystemException
      Delists XA resource from transaction manager.
      Specified by:
      delistResource in interface TransactionService
      Parameters:
      xares - XAResource
      Returns:
      true if the resource was delisted successfully; otherwise false.
      Throws:
      javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      javax.transaction.RollbackException
    • enlistResource

      public boolean enlistResource(XAResource xares) throws javax.transaction.RollbackException, javax.transaction.SystemException
      Enlists XA resource in transaction manager.
      Specified by:
      enlistResource in interface TransactionService
      Parameters:
      xares - XAResource
      Returns:
      true if the resource was enlisted successfully; otherwise false.
      Throws:
      javax.transaction.RollbackException - Thrown to indicate that the transaction has been marked for rollback only.
      javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.
    • getDefaultTimeout

      public int getDefaultTimeout()
      Specified by:
      getDefaultTimeout in interface TransactionService
      Returns:
      default timeout in seconds
    • getTransactionManager

      public final javax.transaction.TransactionManager getTransactionManager()
      Specified by:
      getTransactionManager in interface TransactionService
      Returns:
      TransactionManager
    • isTMInitialized

      protected boolean isTMInitialized()
      Indicates whether or not the TransactionManager has been initialized
    • findTransactionManager

      protected abstract javax.transaction.TransactionManager findTransactionManager() throws Exception
      This method will try to find the current TransactionManager
      Returns:
      the current TransactionManager
      Throws:
      Exception - if an error occurs while looking for the TransactionManager
    • getUserTransaction

      public final javax.transaction.UserTransaction getUserTransaction()
      Specified by:
      getUserTransaction in interface TransactionService
      Returns:
      UserTransaction
    • findUserTransaction

      protected javax.transaction.UserTransaction findUserTransaction() throws Exception
      This method will try to find the current UserTransaction, by default it will simply wraps a TransactionManager
      Returns:
      the current UserTransaction
      Throws:
      Exception - if an error occurs while looking for the UserTransaction
    • setTransactionTimeout

      public void setTransactionTimeout(int seconds) throws javax.transaction.SystemException
      Sets timeout in seconds,
      Specified by:
      setTransactionTimeout in interface TransactionService
      Parameters:
      seconds - int
      Throws:
      javax.transaction.SystemException