01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.transaction.interceptor;
18:
19: import org.springframework.transaction.support.DefaultTransactionDefinition;
20:
21: /**
22: * Transaction attribute that takes the EJB approach to rolling
23: * back on runtime, but not checked, exceptions.
24: *
25: * @author Rod Johnson
26: * @since 16.03.2003
27: */
28: public class DefaultTransactionAttribute extends
29: DefaultTransactionDefinition implements TransactionAttribute {
30:
31: /**
32: * Create a new DefaultTransactionAttribute, with default settings.
33: * Can be modified through bean property setters.
34: * @see #setPropagationBehavior
35: * @see #setIsolationLevel
36: * @see #setTimeout
37: * @see #setReadOnly
38: * @see #setName
39: */
40: public DefaultTransactionAttribute() {
41: super ();
42: }
43:
44: /**
45: * Copy constructor. Definition can be modified through bean property setters.
46: * @see #setPropagationBehavior
47: * @see #setIsolationLevel
48: * @see #setTimeout
49: * @see #setReadOnly
50: * @see #setName
51: */
52: public DefaultTransactionAttribute(TransactionAttribute other) {
53: super (other);
54: }
55:
56: /**
57: * Create a new DefaultTransactionAttribute with the the given
58: * propagation behavior. Can be modified through bean property setters.
59: * @param propagationBehavior one of the propagation constants in the
60: * TransactionDefinition interface
61: * @see #setIsolationLevel
62: * @see #setTimeout
63: * @see #setReadOnly
64: */
65: public DefaultTransactionAttribute(int propagationBehavior) {
66: super (propagationBehavior);
67: }
68:
69: /**
70: * Default behavior is as with EJB: rollback on unchecked exception.
71: * Additionally attempt to rollback on Error.
72: * Consistent with TransactionTemplate's behavior.
73: */
74: public boolean rollbackOn(Throwable ex) {
75: return (ex instanceof RuntimeException || ex instanceof Error);
76: }
77:
78: }
|