net.sourceforge.hivetranse.transaction
Enum TransactionDemarcation

java.lang.Object
  extended by java.lang.Enum<TransactionDemarcation>
      extended by net.sourceforge.hivetranse.transaction.TransactionDemarcation
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<TransactionDemarcation>

public enum TransactionDemarcation
extends java.lang.Enum<TransactionDemarcation>

Defines the transaction demarcation for an executable scope (method of a service). This class is not intended for use by application developers, but is used by the Transaction Interceptors (read from their configuration) to notify the TransactionService of scope enter or leave.

The existing demarcations are copied from EJB declarative demarcation for Container-Managed Transactions.

Author:
Jean-Francois Poilpret

Enum Constant Summary
Mandatory
          Indicates that the scope requires that a transaction already exists, ie, if no transaction exists, an exception will be thrown at scope entry.
Never
          Indicates that the scope refuses to work if a transaction already exists, ie, if one transaction exists, an exception will be thrown at scope entry.
NotSupported
          Indicates that the scope does not support transaction, ie, if one transaction currently exists, it is suspended until the end of that scope.
Required
          Indicates that the scope requires a transaction, ie, if one transaction currently exists, it is used, else a new transaction is created.
RequiresNew
          Indicates that the scope requires a new transaction, ie, if there is one current transaction or not, anyway, a new transaction will be created specifically for this scope.
Supports
          Indicates that the scope supports a transaction, ie, if one transaction currently exists, it may be used, if none exists, this will not be a problem for the code in this scope.
 
Method Summary
static TransactionDemarcation valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static TransactionDemarcation[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NotSupported

public static final TransactionDemarcation NotSupported
Indicates that the scope does not support transaction, ie, if one transaction currently exists, it is suspended until the end of that scope.


Required

public static final TransactionDemarcation Required
Indicates that the scope requires a transaction, ie, if one transaction currently exists, it is used, else a new transaction is created.


Supports

public static final TransactionDemarcation Supports
Indicates that the scope supports a transaction, ie, if one transaction currently exists, it may be used, if none exists, this will not be a problem for the code in this scope.

This demarcation should be avoided, because we wonder how a piece of code can one time live without transaction, and other time live with one.


RequiresNew

public static final TransactionDemarcation RequiresNew
Indicates that the scope requires a new transaction, ie, if there is one current transaction or not, anyway, a new transaction will be created specifically for this scope.

Please note that the behavior here is different from the EJB world, where an exception would be thrown if there is no current transaction.


Mandatory

public static final TransactionDemarcation Mandatory
Indicates that the scope requires that a transaction already exists, ie, if no transaction exists, an exception will be thrown at scope entry.


Never

public static final TransactionDemarcation Never
Indicates that the scope refuses to work if a transaction already exists, ie, if one transaction exists, an exception will be thrown at scope entry.

Method Detail

values

public static final TransactionDemarcation[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(TransactionDemarcation c : TransactionDemarcation.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static TransactionDemarcation valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name