public class RuleBasedTransactionAttribute extends DefaultTransactionAttribute implements Serializable
TransactionAttributeEditor
creates objects of this class.
TransactionAttributeEditor
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
PREFIX_COMMIT_RULE
Prefix for commit-on-exception rules in description strings
|
static String |
PREFIX_ROLLBACK_RULE
Prefix for rollback-on-exception rules in description strings
|
PREFIX_ISOLATION, PREFIX_PROPAGATION, PREFIX_TIMEOUT, READ_ONLY_MARKER
ISOLATION_DEFAULT, ISOLATION_READ_COMMITTED, ISOLATION_READ_UNCOMMITTED, ISOLATION_REPEATABLE_READ, ISOLATION_SERIALIZABLE, PROPAGATION_MANDATORY, PROPAGATION_NESTED, PROPAGATION_NEVER, PROPAGATION_NOT_SUPPORTED, PROPAGATION_REQUIRED, PROPAGATION_REQUIRES_NEW, PROPAGATION_SUPPORTS, TIMEOUT_DEFAULT
Constructor and Description |
---|
RuleBasedTransactionAttribute()
Create a new RuleBasedTransactionAttribute, with default settings.
|
RuleBasedTransactionAttribute(int propagationBehavior,
List<RollbackRuleAttribute> rollbackRules)
Create a new DefaultTransactionAttribute with the the given
propagation behavior.
|
RuleBasedTransactionAttribute(RuleBasedTransactionAttribute other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
List<RollbackRuleAttribute> |
getRollbackRules()
Return the list of
RollbackRuleAttribute objects
(never null ). |
boolean |
rollbackOn(Throwable ex)
Winning rule is the shallowest rule (that is, the closest in the
inheritance hierarchy to the exception).
|
void |
setRollbackRules(List<RollbackRuleAttribute> rollbackRules)
Set the list of
RollbackRuleAttribute objects
(and/or NoRollbackRuleAttribute objects) to apply. |
String |
toString()
Return an identifying description for this transaction definition.
|
getAttributeDescription, getQualifier, setQualifier
equals, getDefinitionDescription, getIsolationLevel, getName, getPropagationBehavior, getTimeout, hashCode, isReadOnly, setIsolationLevel, setIsolationLevelName, setName, setPropagationBehavior, setPropagationBehaviorName, setReadOnly, setTimeout
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getIsolationLevel, getName, getPropagationBehavior, getTimeout, isReadOnly
public static final String PREFIX_ROLLBACK_RULE
public static final String PREFIX_COMMIT_RULE
public RuleBasedTransactionAttribute()
DefaultTransactionDefinition.setPropagationBehavior(int)
,
DefaultTransactionDefinition.setIsolationLevel(int)
,
DefaultTransactionDefinition.setTimeout(int)
,
DefaultTransactionDefinition.setReadOnly(boolean)
,
DefaultTransactionDefinition.setName(java.lang.String)
,
setRollbackRules(java.util.List<org.springframework.transaction.interceptor.RollbackRuleAttribute>)
public RuleBasedTransactionAttribute(RuleBasedTransactionAttribute other)
DefaultTransactionDefinition.setPropagationBehavior(int)
,
DefaultTransactionDefinition.setIsolationLevel(int)
,
DefaultTransactionDefinition.setTimeout(int)
,
DefaultTransactionDefinition.setReadOnly(boolean)
,
DefaultTransactionDefinition.setName(java.lang.String)
,
setRollbackRules(java.util.List<org.springframework.transaction.interceptor.RollbackRuleAttribute>)
public RuleBasedTransactionAttribute(int propagationBehavior, List<RollbackRuleAttribute> rollbackRules)
propagationBehavior
- one of the propagation constants in the
TransactionDefinition interfacerollbackRules
- the list of RollbackRuleAttributes to applyDefaultTransactionDefinition.setIsolationLevel(int)
,
DefaultTransactionDefinition.setTimeout(int)
,
DefaultTransactionDefinition.setReadOnly(boolean)
public void setRollbackRules(List<RollbackRuleAttribute> rollbackRules)
RollbackRuleAttribute
objects
(and/or NoRollbackRuleAttribute
objects) to apply.RollbackRuleAttribute
,
NoRollbackRuleAttribute
public List<RollbackRuleAttribute> getRollbackRules()
RollbackRuleAttribute
objects
(never null
).public boolean rollbackOn(Throwable ex)
rollbackOn
in interface TransactionAttribute
rollbackOn
in class DefaultTransactionAttribute
ex
- the exception to evaluateTransactionAttribute.rollbackOn(java.lang.Throwable)
public String toString()
DefaultTransactionDefinition
The format matches the one used by
TransactionAttributeEditor
,
to be able to feed toString
results into bean properties of type
TransactionAttribute
.
Has to be overridden in subclasses for correct equals
and hashCode
behavior. Alternatively, DefaultTransactionDefinition.equals(java.lang.Object)
and DefaultTransactionDefinition.hashCode()
can be overridden themselves.
toString
in class DefaultTransactionDefinition
DefaultTransactionDefinition.getDefinitionDescription()
,
TransactionAttributeEditor