|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.transaction.interceptor.RollbackRuleAttribute
public class RollbackRuleAttribute
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.
NoRollbackRuleAttribute
,
Serialized FormField Summary | |
---|---|
private java.lang.String |
exceptionName
Could hold exception, resolving class name but would always require FQN. |
static RollbackRuleAttribute |
ROLLBACK_ON_RUNTIME_EXCEPTIONS
The rollback rule for
RuntimeExceptions . |
Constructor Summary | |
---|---|
RollbackRuleAttribute(java.lang.Class clazz)
Create a new instance of the RollbackRuleAttribute class. |
|
RollbackRuleAttribute(java.lang.String exceptionName)
Create a new instance of the RollbackRuleAttribute class
for the given exceptionName . |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object other)
|
private int |
getDepth(java.lang.Class exceptionClass,
int depth)
|
int |
getDepth(java.lang.Throwable ex)
Return the depth of the superclass matching. |
java.lang.String |
getExceptionName()
Return the pattern for the exception name. |
int |
hashCode()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final RollbackRuleAttribute ROLLBACK_ON_RUNTIME_EXCEPTIONS
rollback rule
for
RuntimeExceptions
.
private final java.lang.String exceptionName
Constructor Detail |
---|
public RollbackRuleAttribute(java.lang.Class clazz)
RollbackRuleAttribute
class.
This is the preferred way to construct a rollback rule that matches
the supplied Exception
class (and subclasses).
clazz
- throwable class; must be Throwable
or a subclass
of Throwable
java.lang.IllegalArgumentException
- if the supplied clazz
is
not a Throwable
type or is null
public RollbackRuleAttribute(java.lang.String exceptionName)
RollbackRuleAttribute
class
for the given exceptionName
.
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
java.lang.IllegalArgumentException
- if the supplied
exceptionName
is null
or emptyMethod Detail |
---|
public java.lang.String getExceptionName()
public int getDepth(java.lang.Throwable ex)
0
means ex
matches exactly. Returns
-1
if there is no match. Otherwise, returns depth with the
lowest depth winning.
private int getDepth(java.lang.Class exceptionClass, int depth)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |