org.modeshape.jcr.txn

## Class NoClientTransactions

- java.lang.Object
- - org.modeshape.jcr.txn.Transactions
  - - org.modeshape.jcr.txn.NoClientTransactions

-     public final class NoClientTransactions
      extends Transactions

  An implementation of `Transactions` that does not even check whether there is a current transaction and instead always attempts to create a transaction within the `SessionCache.save()` calls. This is more efficient when the repository can be set up to never use container-managed or user-managed transactions.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `NoClientTransactions.NoClientTransaction`

    - ### Nested classes/interfaces inherited from class org.modeshape.jcr.txn.Transactions

      `Transactions.BaseTransaction, Transactions.SimpleTransaction, Transactions.TraceableSimpleTransaction, Transactions.Transaction, Transactions.TransactionFunction`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static ThreadLocal<NoClientTransactions.NoClientTransaction>` | `ACTIVE_TRANSACTION` During ws cache initialization (either when the repo starts up of a new ws is created), there can be a case of semantically nested simple transactions, so we need effective make sure that only 1 instance of an active transaction can exist at any given time.

    - ### Fields inherited from class org.modeshape.jcr.txn.Transactions

      `logger, txnMgr`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NoClientTransactions(TransactionManager txnMgr)` Creates a new instance passing in the given monitor factory and transaction manager

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Transactions.Transaction` | `begin()` Starts a new transaction if one does not already exist, and associate it with the calling thread.

    - ### Methods inherited from class org.modeshape.jcr.txn.Transactions

      `currentTransactionId, getTransactionManager, isCurrentlyInTransaction, resume, suspend, updateCache`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ACTIVE_TRANSACTION

          protected static final ThreadLocal<NoClientTransactions.NoClientTransaction> ACTIVE_TRANSACTION

      During ws cache initialization (either when the repo starts up of a new ws is created), there can be a case of semantically nested simple transactions, so we need effective make sure that only 1 instance of an active transaction can exist at any given time. We cannot use multiple instance because completion functions are instance-dependent

  - ### Constructor Detail

    - #### NoClientTransactions

          public NoClientTransactions(TransactionManager txnMgr)

      Creates a new instance passing in the given monitor factory and transaction manager
      Parameters:
        `txnMgr` - a `TransactionManager` instance; never null

  - ### Method Detail

    - #### begin

          public Transactions.Transaction begin()
                                         throws NotSupportedException,
                                                SystemException

      Description copied from class: `Transactions`
      Starts a new transaction if one does not already exist, and associate it with the calling thread.
      Specified by:
        `begin` in class `Transactions`
      Returns:
        the ModeShape transaction
      Throws:
        `NotSupportedException` - If the calling thread is already associated with a transaction, and nested transactions are not supported.
        `SystemException` - If the transaction service fails in an unexpected way.

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.