类 RollbackRuleAttribute
- java.lang.Object
- org.springframework.transaction.interceptor.RollbackRuleAttribute
- 所有已实现的接口:
Serializable
- 直接已知子类:
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.
- 从以下版本开始:
- 09.04.2003
- 作者:
- Rod Johnson
- 另请参阅:
NoRollbackRuleAttribute
, 序列化表格
字段概要
字段 修饰符和类型 字段 说明 static RollbackRuleAttribute
ROLLBACK_ON_RUNTIME_EXCEPTIONS
Therollback rule
forRuntimeExceptions
.
构造器概要
构造器 构造器 说明 RollbackRuleAttribute(Class<?> clazz)
Create a new instance of theRollbackRuleAttribute
class.RollbackRuleAttribute(String exceptionName)
Create a new instance of theRollbackRuleAttribute
class for the givenexceptionName
.
字段详细资料
ROLLBACK_ON_RUNTIME_EXCEPTIONS
public static final RollbackRuleAttribute ROLLBACK_ON_RUNTIME_EXCEPTIONS
Therollback rule
forRuntimeExceptions
.
构造器详细资料
RollbackRuleAttribute
public RollbackRuleAttribute(Class<?> clazz)
Create a new instance of theRollbackRuleAttribute
class.This is the preferred way to construct a rollback rule that matches the supplied
Exception
class (and subclasses).- 参数:
clazz
- throwable class; must beThrowable
or a subclass ofThrowable
- 抛出:
IllegalArgumentException
- if the suppliedclazz
is not aThrowable
type or isnull
RollbackRuleAttribute
public RollbackRuleAttribute(String exceptionName)
Create a new instance of theRollbackRuleAttribute
class for the givenexceptionName
.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 is not 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 fully package-qualified name.
- 参数:
exceptionName
- the exception name pattern; can also be a fully package-qualified class name- 抛出:
IllegalArgumentException
- if the suppliedexceptionName
isnull
or empty
方法详细资料
getExceptionName
public String getExceptionName()
Return the pattern for the exception name.
getDepth
public int getDepth(Throwable ex)
Return the depth of the superclass matching.0
meansex
matches exactly. Returns-1
if there is no match. Otherwise, returns depth with the lowest depth winning.