Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.portal.common.transaction
Class Transactions

    java.lang.Object
      org.jboss.portal.common.transaction.Transactions

    public class Transactions

extends java.lang.Object

Utility class for managing transactions.

Version:
  $Revision: 5451 $
Author:
  Julien Viet

Nested Class Summary
`static interface` | `Transactions.Runnable`
`static class` | `Transactions.Type`

Field Summary
`static Transactions.Type` | `TYPE_MANDATORY`
`static Transactions.Type` | `TYPE_NEVER`
`static Transactions.Type` | `TYPE_NOT_SUPPORTED`
`static Transactions.Type` | `TYPE_REQUIRED`
`static Transactions.Type` | `TYPE_REQUIRES_NEW`
`static Transactions.Type` | `TYPE_SUPPORTS`

Constructor Summary
`Transactions()`

Method Summary
`static java.lang.Object` | `apply(Transactions.Type type, javax.transaction.TransactionManager tm, Transactions.Runnable runnable)` Apply the transaction type around the unit of work.
`static void` | `applyAfter(Transactions.Type type, javax.transaction.TransactionManager tm, javax.transaction.Transaction oldTx)` Apply the transaction type after the unit of work has been done.
`static javax.transaction.Transaction` | `applyBefore(Transactions.Type type, javax.transaction.TransactionManager tm)` Apply the transaction type before the unit of work.
`static void` | `begin(javax.transaction.TransactionManager tm)` Begin a new transaction.
`static java.lang.String` | `decodeStatus(int status)` Decode the status name.
`static boolean` | `end(javax.transaction.TransactionManager tm)` Terminate the active transaction for this thread.
`static java.lang.Object` | `mandatory(javax.transaction.TransactionManager tm, Transactions.Runnable runnable)`
`static java.lang.Object` | `never(javax.transaction.TransactionManager tm, Transactions.Runnable runnable)`
`static java.lang.Object` | `notSupported(javax.transaction.TransactionManager tm, Transactions.Runnable runnable)`
`static java.lang.Object` | `required(javax.transaction.TransactionManager tm, Transactions.Runnable runnable)`
`static java.lang.Object` | `requiresNew(javax.transaction.TransactionManager tm, Transactions.Runnable runnable)`
`static void` | `resume(javax.transaction.TransactionManager tm, javax.transaction.Transaction tx)` Associate the thread with a transaction
`static void` | `safeEnd(javax.transaction.TransactionManager tm)`
`void` | `safeSetRollbackOnly(javax.transaction.TransactionManager tm)`
`static void` | `setRollbackOnly(javax.transaction.TransactionManager tm)` Mark the active transaction for this thread as rollback only
`static java.lang.Object` | `supports(javax.transaction.TransactionManager tm, Transactions.Runnable runnable)`
`static javax.transaction.Transaction` | `suspend(javax.transaction.TransactionManager tm)` Disassociate the current thread with the active transaction.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TYPE_NOT_SUPPORTED

    public static final Transactions.Type TYPE_NOT_SUPPORTED

### TYPE_SUPPORTS

    public static final Transactions.Type TYPE_SUPPORTS

### TYPE_REQUIRED

    public static final Transactions.Type TYPE_REQUIRED

### TYPE_REQUIRES_NEW

    public static final Transactions.Type TYPE_REQUIRES_NEW

### TYPE_MANDATORY

    public static final Transactions.Type TYPE_MANDATORY

### TYPE_NEVER

    public static final Transactions.Type TYPE_NEVER

Constructor Detail

### Transactions

    public Transactions()

Method Detail

### decodeStatus

    public static java.lang.String decodeStatus(int status)

  Decode the status name.

  Parameters:
    `status` - the status value
  Returns:
    the translated status name or null if it is not valid

### applyBefore

    public static javax.transaction.Transaction applyBefore(Transactions.Type type,
                                                            javax.transaction.TransactionManager tm)
                                                     throws TransactionException,
                                                            java.lang.IllegalArgumentException

  Apply the transaction type before the unit of work.

  Parameters:
    `type` - the transaction type
    `tm` - the transaction manager
  Returns:
    the new transaction if one has been started.
  Throws:
    `TransactionException`
    `java.lang.IllegalArgumentException` - if the type or the transaction manager is null

### applyAfter

    public static void applyAfter(Transactions.Type type,
                                  javax.transaction.TransactionManager tm,
                                  javax.transaction.Transaction oldTx)
                           throws TransactionException,
                                  java.lang.IllegalArgumentException

  Apply the transaction type after the unit of work has been done.

  Parameters:
    `type` - the transaction type
    `tm` - the transaction manager
    `oldTx` - the old transaction if it is not null
  Throws:
    `TransactionException`
    `java.lang.IllegalArgumentException` - if the type of the transaction manager is null

### apply

    public static java.lang.Object apply(Transactions.Type type,
                                         javax.transaction.TransactionManager tm,
                                         Transactions.Runnable runnable)
                                  throws NestedException,
                                         TransactionException,
                                         java.lang.IllegalArgumentException

  Apply the transaction type around the unit of work.

  Parameters:
    `type` - the transaction type
    `tm` - the transaction manager
    `runnable` - the unit of work
  Returns:
    the object returned by the runnable object
  Throws:
    `NestedException` - wraps any exception throws by the runnable object
    `TransactionException`
    `java.lang.IllegalArgumentException` - if any method argument is null

### notSupported

    public static java.lang.Object notSupported(javax.transaction.TransactionManager tm,
                                                Transactions.Runnable runnable)
                                         throws NestedException,
                                                TransactionException

  Throws:
    `NestedException`
    `TransactionException`

### never

    public static java.lang.Object never(javax.transaction.TransactionManager tm,
                                         Transactions.Runnable runnable)
                                  throws NestedException,
                                         TransactionException

  Throws:
    `NestedException`
    `TransactionException`

### mandatory

    public static java.lang.Object mandatory(javax.transaction.TransactionManager tm,
                                             Transactions.Runnable runnable)
                                      throws NestedException,
                                             TransactionException

  Throws:
    `NestedException`
    `TransactionException`

### supports

    public static java.lang.Object supports(javax.transaction.TransactionManager tm,
                                            Transactions.Runnable runnable)
                                     throws NestedException,
                                            TransactionException

  Throws:
    `NestedException`
    `TransactionException`

### required

    public static java.lang.Object required(javax.transaction.TransactionManager tm,
                                            Transactions.Runnable runnable)
                                     throws NestedException,
                                            TransactionException

  Throws:
    `NestedException`
    `TransactionException`

### requiresNew

    public static java.lang.Object requiresNew(javax.transaction.TransactionManager tm,
                                               Transactions.Runnable runnable)
                                        throws NestedException,
                                               TransactionException

  Throws:
    `NestedException`
    `TransactionException`

### begin

    public static void begin(javax.transaction.TransactionManager tm)
                      throws java.lang.IllegalArgumentException,
                             TransactionException

  Begin a new transaction.

  Parameters:
    `tm` - the transaction manager
  Throws:
    `java.lang.IllegalArgumentException` - if the tm is null
    `TransactionException`

### setRollbackOnly

    public static void setRollbackOnly(javax.transaction.TransactionManager tm)
                                throws java.lang.IllegalArgumentException,
                                       TransactionException

  Mark the active transaction for this thread as rollback only

  Parameters:
    `tm` - the transaction manager
  Throws:
    `java.lang.IllegalArgumentException` - if the tm is null
    `TransactionException`
  See Also:
    `setRollbackOnly(javax.transaction.Transaction)`

### safeSetRollbackOnly

    public void safeSetRollbackOnly(javax.transaction.TransactionManager tm)

### safeEnd

    public static void safeEnd(javax.transaction.TransactionManager tm)

### end

    public static boolean end(javax.transaction.TransactionManager tm)
                       throws java.lang.IllegalArgumentException,
                              TransactionException

  Terminate the active transaction for this thread. If the transaction is marked for rollback then it is rollbacked otherwise it is commited.

  Parameters:
    `tm` - the transaction manager
  Returns:
    true if commit happened, false otherwise
  Throws:
    `java.lang.IllegalArgumentException` - if the tm is null
    `TransactionException`

### resume

    public static void resume(javax.transaction.TransactionManager tm,
                              javax.transaction.Transaction tx)
                       throws java.lang.IllegalArgumentException,
                              TransactionException

  Associate the thread with a transaction

  Parameters:
    `tm` - the transaction manager
    `tx` - the transaction to associate with the this thread
  Throws:
    `java.lang.IllegalArgumentException` - if any argument is null
    `TransactionException`

### suspend

    public static javax.transaction.Transaction suspend(javax.transaction.TransactionManager tm)
                                                 throws java.lang.IllegalArgumentException,
                                                        TransactionException

  Disassociate the current thread with the active transaction.

  Parameters:
    `tm` - the transaction manager
  Returns:
    the transaction previously associated with this thread
  Throws:
    `java.lang.IllegalArgumentException` - if the transaction manager is null
    `TransactionException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008. All Rights Reserved.