Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.transaction.interceptor
Class RuleBasedTransactionAttribute

    java.lang.Object
      org.springframework.transaction.support.DefaultTransactionDefinition
          org.springframework.transaction.interceptor.DefaultTransactionAttribute
              org.springframework.transaction.interceptor.RuleBasedTransactionAttribute

All Implemented Interfaces:
  java.io.Serializable, TransactionAttribute, TransactionDefinition

    public class RuleBasedTransactionAttribute

extends DefaultTransactionAttribute
implements java.io.Serializable

TransactionAttribute implementation that works out whether a given exception should cause transaction rollback by applying a number of rollback rules, both positive and negative. If no rules are relevant to the exception, it behaves like DefaultTransactionAttribute (rolling back on runtime exceptions).

`TransactionAttributeEditor` creates objects of this class.

Since:
  09.04.2003
Author:
  Rod Johnson, Juergen Hoeller
See Also:
  `TransactionAttributeEditor`, Serialized Form

Field Summary
`static java.lang.String` | `PREFIX_COMMIT_RULE` Prefix for commit-on-exception rules in description strings
`static java.lang.String` | `PREFIX_ROLLBACK_RULE` Prefix for rollback-on-exception rules in description strings

Fields inherited from class org.springframework.transaction.support.DefaultTransactionDefinition
`PREFIX_ISOLATION, PREFIX_PROPAGATION, PREFIX_TIMEOUT, READ_ONLY_MARKER`

Fields inherited from interface org.springframework.transaction.TransactionDefinition
`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 Summary
`RuleBasedTransactionAttribute()` Create a new RuleBasedTransactionAttribute, with default settings.
`RuleBasedTransactionAttribute(int propagationBehavior, java.util.List<RollbackRuleAttribute> rollbackRules)` Create a new DefaultTransactionAttribute with the the given propagation behavior.
`RuleBasedTransactionAttribute(RuleBasedTransactionAttribute other)` Copy constructor.

Method Summary
`java.util.List<RollbackRuleAttribute>` | `getRollbackRules()` Return the list of `RollbackRuleAttribute` objects (never `null`).
`boolean` | `rollbackOn(java.lang.Throwable ex)` Winning rule is the shallowest rule (that is, the closest in the inheritance hierarchy to the exception).
`void` | `setRollbackRules(java.util.List<RollbackRuleAttribute> rollbackRules)` Set the list of `RollbackRuleAttribute` objects (and/or `NoRollbackRuleAttribute` objects) to apply.
`java.lang.String` | `toString()` Return an identifying description for this transaction definition.

Methods inherited from class org.springframework.transaction.interceptor.DefaultTransactionAttribute
`getAttributeDescription, getQualifier, setQualifier`

Methods inherited from class org.springframework.transaction.support.DefaultTransactionDefinition
`equals, getDefinitionDescription, getIsolationLevel, getName, getPropagationBehavior, getTimeout, hashCode, isReadOnly, setIsolationLevel, setIsolationLevelName, setName, setPropagationBehavior, setPropagationBehaviorName, setReadOnly, setTimeout`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.springframework.transaction.TransactionDefinition
`getIsolationLevel, getName, getPropagationBehavior, getTimeout, isReadOnly`

Field Detail

### PREFIX_ROLLBACK_RULE

    public static final java.lang.String PREFIX_ROLLBACK_RULE

  Prefix for rollback-on-exception rules in description strings

  See Also:
    Constant Field Values

### PREFIX_COMMIT_RULE

    public static final java.lang.String PREFIX_COMMIT_RULE

  Prefix for commit-on-exception rules in description strings

  See Also:
    Constant Field Values

Constructor Detail

### RuleBasedTransactionAttribute

    public RuleBasedTransactionAttribute()

  Create a new RuleBasedTransactionAttribute, with default settings. Can be modified through bean property setters.

  See Also:
    `DefaultTransactionDefinition.setPropagationBehavior(int)`, `DefaultTransactionDefinition.setIsolationLevel(int)`, `DefaultTransactionDefinition.setTimeout(int)`, `DefaultTransactionDefinition.setReadOnly(boolean)`, `DefaultTransactionDefinition.setName(java.lang.String)`, `setRollbackRules(java.util.List)`

### RuleBasedTransactionAttribute

    public RuleBasedTransactionAttribute(RuleBasedTransactionAttribute other)

  Copy constructor. Definition can be modified through bean property setters.

  See Also:
    `DefaultTransactionDefinition.setPropagationBehavior(int)`, `DefaultTransactionDefinition.setIsolationLevel(int)`, `DefaultTransactionDefinition.setTimeout(int)`, `DefaultTransactionDefinition.setReadOnly(boolean)`, `DefaultTransactionDefinition.setName(java.lang.String)`, `setRollbackRules(java.util.List)`

### RuleBasedTransactionAttribute

    public RuleBasedTransactionAttribute(int propagationBehavior,
                                         java.util.List<RollbackRuleAttribute> rollbackRules)

  Create a new DefaultTransactionAttribute with the the given propagation behavior. Can be modified through bean property setters.

  Parameters:
    `propagationBehavior` - one of the propagation constants in the TransactionDefinition interface
    `rollbackRules` - the list of RollbackRuleAttributes to apply
  See Also:
    `DefaultTransactionDefinition.setIsolationLevel(int)`, `DefaultTransactionDefinition.setTimeout(int)`, `DefaultTransactionDefinition.setReadOnly(boolean)`

Method Detail

### setRollbackRules

    public void setRollbackRules(java.util.List<RollbackRuleAttribute> rollbackRules)

  Set the list of `RollbackRuleAttribute` objects (and/or `NoRollbackRuleAttribute` objects) to apply.

  See Also:
    `RollbackRuleAttribute`, `NoRollbackRuleAttribute`

### getRollbackRules

    public java.util.List<RollbackRuleAttribute> getRollbackRules()

  Return the list of `RollbackRuleAttribute` objects (never `null`).

### rollbackOn

    public boolean rollbackOn(java.lang.Throwable ex)

  Winning rule is the shallowest rule (that is, the closest in the inheritance hierarchy to the exception). If no rule applies (-1), return false.

  Specified by:
    `rollbackOn` in interface `TransactionAttribute`
  Overrides:
    `rollbackOn` in class `DefaultTransactionAttribute`
  Parameters:
    `ex` - the exception to evaluate
  Returns:
    whether to perform a rollback or not
  See Also:
    `TransactionAttribute.rollbackOn(java.lang.Throwable)`

### toString

    public java.lang.String toString()

  Description copied from class: `DefaultTransactionDefinition`
  Return an identifying description for this transaction definition.

  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.

  Overrides:
    `toString` in class `DefaultTransactionDefinition`
  See Also:
    `DefaultTransactionDefinition.getDefinitionDescription()`, `TransactionAttributeEditor`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD