com.adobe.idp.dsc.transaction
Interface TransactionDefinition

All Known Subinterfaces:
TransactionTemplate

public interface TransactionDefinition

Classes implementing this interface define transaction properties.

Note that isolation level, timeout, and read-only settings are applied unless a new transaction is started. As only TransactionDefinition.PROPAGATION_REQUIRED and TransactionDefinition.PROPAGATION_REQUIRES_NEW can actually cause a new transaction to be started, it usually does not make sense to specify those settings in all other cases. Furthermore, not all transaction managers support those advanced features and might throw corresponding exceptions when given non-default values.


Field Summary
static int PROPAGATION_MANDATORY
          Supports the current transaction, or throws an exception if none exists.
static int PROPAGATION_NEVER
          Executes non-transactionally, or throws an exception if a transaction exists.
static int PROPAGATION_NOT_SUPPORTED
          Executes non-transactionally, or suspends the current transaction if one exists.
static int PROPAGATION_REQUIRED
          Supports the current transaction, or creates a new one if none exists.
static int PROPAGATION_REQUIRES_NEW
          Creates a new transaction, or suspends the current transaction if one exists.
static int PROPAGATION_SUPPORTS
          Supports the current transaction, or executes non-transactionally if none exists.
static int TIMEOUT_DEFAULT
          Uses the default timeout of the underlying transaction system , or none if timeouts are not supported.
 
Method Summary
 java.lang.String getName()
          Retrieves the name of this transaction.
 int getPropagationType()
          Retrieves the propagation type.
 int getTimeout()
          Retrieves the transaction timeout.
 void setPropagationType(int aType)
          Sets the propagation type to use for this template
 void setTimeout(int aSeconds)
          Sets the transaction timeout.
 

Field Detail

PROPAGATION_REQUIRED

static final int PROPAGATION_REQUIRED
Supports the current transaction, or creates a new one if none exists. It is analogous to the EJB transaction attribute having the same name.

This is typically the default setting of a transaction definition.

See Also:
Constant Field Values

PROPAGATION_SUPPORTS

static final int PROPAGATION_SUPPORTS
Supports the current transaction, or executes non-transactionally if none exists. It is analogous to the EJB transaction attribute having the same name.

Note that for transaction managers with transaction synchronization, TransactionDefinition.PROPAGATION_SUPPORTS is slightly different from no transaction at all. It defines a transaction scope for which synchronization will apply. As a consequence, the same resources (JDBC Connection, Hibernate Session, and so forth) will be shared for the entire specified scope. This depends on the actual synchronization configuration of the transaction manager.

See Also:
Constant Field Values

PROPAGATION_MANDATORY

static final int PROPAGATION_MANDATORY
Supports the current transaction, or throws an exception if none exists. It is analogous to the EJB transaction attribute having the same name.

See Also:
Constant Field Values

PROPAGATION_REQUIRES_NEW

static final int PROPAGATION_REQUIRES_NEW
Creates a new transaction, or suspends the current transaction if one exists. It is analogous to the EJB transaction attribute having the same name.

Note that actual transaction suspension will not work without modification on all transaction managers, particularly JtaTransactionManager, which requires that javax.transaction.TransactionManager be made available it to it (which is server-specific in standard J2EE).

See Also:
Constant Field Values

PROPAGATION_NOT_SUPPORTED

static final int PROPAGATION_NOT_SUPPORTED
Executes non-transactionally, or suspends the current transaction if one exists. It is analogous to the EJB transaction attribute having the same name.

Note that actual transaction suspension will not work without modification on all transaction managers, particularly JtaTransactionManager, which requires that javax.transaction.TransactionManager be made available it to it (which is server-specific in standard J2EE).

See Also:
Constant Field Values

PROPAGATION_NEVER

static final int PROPAGATION_NEVER
Executes non-transactionally, or throws an exception if a transaction exists. It is analogous to the EJB transaction attribute having the same name.

See Also:
Constant Field Values

TIMEOUT_DEFAULT

static final int TIMEOUT_DEFAULT
Uses the default timeout of the underlying transaction system , or none if timeouts are not supported.

See Also:
Constant Field Values
Method Detail

setPropagationType

void setPropagationType(int aType)
Sets the propagation type to use for this template

Parameters:
aType - The propagation type to use.

getPropagationType

int getPropagationType()
Retrieves the propagation type.

Returns:
The propagation type.

setTimeout

void setTimeout(int aSeconds)
Sets the transaction timeout.

It is only useful in combination with TransactionDefinition.PROPAGATION_REQUIRED or TransactionDefinition.PROPAGATION_REQUIRES_NEW.

Note that a transaction provider that does not support timeouts will throw an exception when given any timeout other than TransactionDefinition.TIMEOUT_DEFAULT.

Parameters:
aSeconds - The numbers of seconds for the transaction timeout.

getTimeout

int getTimeout()
Retrieves the transaction timeout. It must return the number of seconds, or TransactionDefinition.TIMEOUT_DEFAULT.

It is only useful in combination with TransactionDefinition.PROPAGATION_REQUIRED or TransactionDefinition.PROPAGATION_REQUIRES_NEW.

Note that a transaction provider that does not support timeouts will throw an exception when given any timeout other than TransactionDefinition.TIMEOUT_DEFAULT.

Returns:
The transaction timeout.

getName

java.lang.String getName()
Retrieves the name of this transaction. It can be null. This will be used as the transaction name to be shown in a transaction monitor.

Returns:
The name of this transaction.