org.springframework.transaction.interceptor
Class DelegatingTransactionAttribute

java.lang.Object
  extended by org.springframework.transaction.interceptor.DelegatingTransactionAttribute
All Implemented Interfaces:
TransactionAttribute, TransactionDefinition

public abstract class DelegatingTransactionAttribute
extends Object
implements TransactionAttribute

TransactionAttribute implementation that delegates all calls to a given target TransactionAttribute. Abstract because it is meant to be to be subclasses, overriding specific methods that should not simply delegate to the target.

Since:
1.2
Author:
Juergen Hoeller

Field Summary
 
Fields inherited from interface org.springframework.transaction.TransactionDefinition
ISOLATION_CONSTANT_PREFIX, ISOLATION_DEFAULT, ISOLATION_READ_COMMITTED, ISOLATION_READ_UNCOMMITTED, ISOLATION_REPEATABLE_READ, ISOLATION_SERIALIZABLE, PROPAGATION_CONSTANT_PREFIX, PROPAGATION_MANDATORY, PROPAGATION_NESTED, PROPAGATION_NEVER, PROPAGATION_NOT_SUPPORTED, PROPAGATION_REQUIRED, PROPAGATION_REQUIRES_NEW, PROPAGATION_SUPPORTS, TIMEOUT_DEFAULT
 
Constructor Summary
DelegatingTransactionAttribute(TransactionAttribute targetAttribute)
          Create a DelegatingTransactionAttribute for the given target attribute.
 
Method Summary
 boolean equals(Object obj)
           
 int getIsolationLevel()
          Return the isolation level.
 String getName()
          Return the name of this transaction.
 int getPropagationBehavior()
          Return the propagation behavior.
 int getTimeout()
          Return the transaction timeout.
 int hashCode()
           
 boolean isReadOnly()
          Return whether to optimize as read-only transaction.
 boolean rollbackOn(Throwable ex)
          Should we roll back on the given exception?
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DelegatingTransactionAttribute

public DelegatingTransactionAttribute(TransactionAttribute targetAttribute)
Create a DelegatingTransactionAttribute for the given target attribute.

Method Detail

getPropagationBehavior

public int getPropagationBehavior()
Description copied from interface: TransactionDefinition
Return the propagation behavior. Must return one of the PROPAGATION constants.

Specified by:
getPropagationBehavior in interface TransactionDefinition
See Also:
TransactionDefinition.PROPAGATION_REQUIRED, TransactionSynchronizationManager.isActualTransactionActive()

getIsolationLevel

public int getIsolationLevel()
Description copied from interface: TransactionDefinition
Return the isolation level. Must return one of the ISOLATION constants.

Only makes sense in combination with PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW.

Note that a transaction manager that does not support custom isolation levels will throw an exception when given any other level than ISOLATION_DEFAULT.

Specified by:
getIsolationLevel in interface TransactionDefinition
See Also:
TransactionDefinition.ISOLATION_DEFAULT

getTimeout

public int getTimeout()
Description copied from interface: TransactionDefinition
Return the transaction timeout. Must return a number of seconds, or TIMEOUT_DEFAULT.

Only makes sense in combination with PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW.

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

Specified by:
getTimeout in interface TransactionDefinition
See Also:
TransactionDefinition.TIMEOUT_DEFAULT

isReadOnly

public boolean isReadOnly()
Description copied from interface: TransactionDefinition
Return whether to optimize as read-only transaction. This just serves as a hint for the actual transaction subsystem, it will not necessarily cause failure of write access attempts.

Intended to be used in combination with PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW. Beyond optimizing such actual transactions accordingly, a transaction manager might also pass the read-only flag to transaction synchronizations, even outside an actual transaction.

A transaction manager that cannot interpret the read-only hint will not throw an exception when given readOnly=true.

Specified by:
isReadOnly in interface TransactionDefinition
See Also:
TransactionSynchronization.beforeCommit(boolean), TransactionSynchronizationManager.isCurrentTransactionReadOnly()

getName

public String getName()
Description copied from interface: TransactionDefinition
Return the name of this transaction. Can be null. This will be used as transaction name to be shown in a transaction monitor, if applicable (for example, WebLogic's).

In case of Spring's declarative transactions, the exposed name will be the fully-qualified class name + "." + method name (by default).

Specified by:
getName in interface TransactionDefinition
See Also:
TransactionAspectSupport, TransactionSynchronizationManager.getCurrentTransactionName()

rollbackOn

public boolean rollbackOn(Throwable ex)
Description copied from interface: TransactionAttribute
Should we roll back on the given exception?

Specified by:
rollbackOn in interface TransactionAttribute
Parameters:
ex - the exception to evaluate
Returns:
whether to perform a rollback or not

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2002-2006 The Spring Framework Project.