KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > transaction > interceptor > DefaultTransactionAttribute


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 DefaultTransactionDefinition implements TransactionAttribute {
29
30     /**
31      * Create a new DefaultTransactionAttribute, with default settings.
32      * Can be modified through bean property setters.
33      * @see #setPropagationBehavior
34      * @see #setIsolationLevel
35      * @see #setTimeout
36      * @see #setReadOnly
37      * @see #setName
38      */

39     public DefaultTransactionAttribute() {
40         super();
41     }
42
43     /**
44      * Copy constructor. Definition can be modified through bean property setters.
45      * @see #setPropagationBehavior
46      * @see #setIsolationLevel
47      * @see #setTimeout
48      * @see #setReadOnly
49      * @see #setName
50      */

51     public DefaultTransactionAttribute(TransactionAttribute other) {
52         super(other);
53     }
54
55     /**
56      * Create a new DefaultTransactionAttribute with the the given
57      * propagation behavior. Can be modified through bean property setters.
58      * @param propagationBehavior one of the propagation constants in the
59      * TransactionDefinition interface
60      * @see #setIsolationLevel
61      * @see #setTimeout
62      * @see #setReadOnly
63      */

64     public DefaultTransactionAttribute(int propagationBehavior) {
65         super(propagationBehavior);
66     }
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 JavaDoc ex) {
75         return (ex instanceof RuntimeException JavaDoc || ex instanceof Error JavaDoc);
76     }
77
78 }
79
Popular Tags