站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

RollbackRuleAttribute (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.transaction.interceptor
Class RollbackRuleAttribute

java.lang.Object
  extended by org.springframework.transaction.interceptor.RollbackRuleAttribute
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
NoRollbackRuleAttribute

public class RollbackRuleAttribute
extends Object
implements Serializable

Rule determining whether or not a given exception (and any subclasses) should cause a rollback. Multiple such rules can be applied to determine whether a transaction should commit or rollback after an exception has been thrown.

Since:
09.04.2003
Author:
Rod Johnson
See Also:
NoRollbackRuleAttribute, Serialized Form

Field Summary
static RollbackRuleAttribute ROLLBACK_ON_RUNTIME_EXCEPTIONS
           
 
Constructor Summary
RollbackRuleAttribute(Class clazz)
          Preferred way to construct a RollbackRule, matching the exception class and subclasses.
RollbackRuleAttribute(String exceptionName)
          Construct a new RollbackRule for the given exception name.
 
Method Summary
 boolean equals(Object other)
           
 int getDepth(Throwable ex)
          Return the depth to the superclass matching. 0 means ex matches exactly.
 String getExceptionName()
          Return the pattern for the exception name.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ROLLBACK_ON_RUNTIME_EXCEPTIONS

public static final RollbackRuleAttribute ROLLBACK_ON_RUNTIME_EXCEPTIONS
Constructor Detail

RollbackRuleAttribute

public RollbackRuleAttribute(Class clazz)
Preferred way to construct a RollbackRule, matching the exception class and subclasses. The exception class must be Throwable or a subclass of Throwable.

Parameters:
clazz - throwable class

RollbackRuleAttribute

public RollbackRuleAttribute(String exceptionName)
Construct a new RollbackRule for the given exception name. This can be a substring, with no wildcard support at present. A value of "ServletException" would match javax.servlet.ServletException and subclasses, for example.

NB: Consider carefully how specific the pattern is, and whether to include package information (which isn't mandatory). For example, "Exception" will match nearly anything, and will probably hide other rules. "java.lang.Exception" would be correct if "Exception" was meant to define a rule for all checked exceptions. With more unusual exception names such as "BaseBusinessException" there's no need to use a FQN.

Parameters:
exceptionName - the exception pattern (can also be a fully qualified class name)
Method Detail

getExceptionName

public String getExceptionName()
Return the pattern for the exception name.


getDepth

public int getDepth(Throwable ex)
Return the depth to the superclass matching. 0 means ex matches exactly. Returns -1 if there's no match. Otherwise, returns depth. Lowest depth wins.


equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

The Spring Framework

Copyright © 2002-2007 The Spring Framework.