|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--com.interface21.transaction.support.DefaultTransactionDefinition
|
+--com.interface21.transaction.support.TransactionTemplate
Helper class that simplifies programmatic transaction demarcation (via the "execute" method) and exception handling.
The central method is "execute", supporting transactional code implementing the TransactionCallback interface. It handles the transaction lifecycle and possible exceptions such that neither the TransactionCallback implementation nor the calling code needs to explicitly handle transactions.
Typical usage: Allows for writing low-level application services that use (JNDI) resources but are not transaction-aware themselves. Instead, they can implicitly take part in (JTA) transactions handled by higher-level application services utilizing this class, making calls to the low-level services via an inner-class callback object.
Can be used within a service implementation via direct instantiation with a transaction manager reference, or get prepared in an application context and given to services as bean reference. Note: The transaction manager should always be configured as bean in the application context, in the first case given to the service directly, in the second case to the prepared template.
Supports setting the propagation behavior and the isolation level by name, for convenient configuration in context definitions.
TransactionCallback,
PlatformTransactionManager,
JtaTransactionManager| Field Summary | |
protected PlatformTransactionManager |
transactionManager
|
| Fields inherited from interface com.interface21.transaction.TransactionDefinition |
ISOLATION_CONSTANT_PREFIX, ISOLATION_DEFAULT, ISOLATION_READ_COMMITTED, ISOLATION_READ_UNCOMMITTED, ISOLATION_REPEATABLE_READ, ISOLATION_SERIALIZABLE, PROPAGATION_CONSTANT_PREFIX, PROPAGATION_MANDATORY, PROPAGATION_REQUIRED, PROPAGATION_SUPPORTS, TIMEOUT_DEFAULT |
| Constructor Summary | |
TransactionTemplate()
Create a new TransactionTemplate instance. |
|
TransactionTemplate(PlatformTransactionManager transactionManager)
Create a new TransactionTemplate instance. |
|
| Method Summary | |
java.lang.Object |
execute(TransactionCallback action)
Executes the action specified by the given callback object within a transaction. |
PlatformTransactionManager |
getTransactionManager()
Return the transaction manager to be used. |
void |
setIsolationLevelName(java.lang.String constantName)
Set the isolation level by the name of the respective constant in PlatformTransactionManager (e.g. |
void |
setPropagationBehaviorName(java.lang.String constantName)
Set the propagation behavior by the name of the respective constant in PlatformTransactionManager (e.g. |
void |
setTransactionManager(PlatformTransactionManager transactionManager)
Set the transaction manager to be used. |
| Methods inherited from class com.interface21.transaction.support.DefaultTransactionDefinition |
getIsolationLevel, getPropagationBehavior, getTimeout, setIsolationLevel, setPropagationBehavior, setTimeout |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected PlatformTransactionManager transactionManager
| Constructor Detail |
public TransactionTemplate()
setTransactionManager(com.interface21.transaction.PlatformTransactionManager)public TransactionTemplate(PlatformTransactionManager transactionManager)
transactionManager - transaction manager to be usedPlatformTransactionManager| Method Detail |
public void setTransactionManager(PlatformTransactionManager transactionManager)
public PlatformTransactionManager getTransactionManager()
public void setPropagationBehaviorName(java.lang.String constantName)
throws java.lang.IllegalArgumentException
constantName - name of the constantjava.lang.IllegalArgumentException - if an invalid constant was specifiedPlatformTransactionManager
public void setIsolationLevelName(java.lang.String constantName)
throws java.lang.IllegalArgumentException
constantName - name of the constantjava.lang.IllegalArgumentException - if an invalid constant was specifiedPlatformTransactionManager
public java.lang.Object execute(TransactionCallback action)
throws TransactionException,
java.lang.RuntimeException
action - callback object that specifies the transactional actionTransactionException - in case of initialization, rollback,
or system errorsjava.lang.RuntimeException - in case of application exceptions thrown by
the callback object
|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||