KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > framework > autoproxy > metadata > TxClassWithClassAttribute


1 /*
2  * Copyright 2002-2005 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.aop.framework.autoproxy.metadata;
18
19 import org.springframework.transaction.interceptor.TransactionInterceptor;
20
21
22 /**
23  * Illustrates class and method attributes
24  * <br>The attribute syntax is that of Commons Attributes.
25  *
26  * @@org.springframework.aop.framework.autoproxy.target.PoolingAttribute (10)
27  *
28  * @@org.springframework.transaction.interceptor.DefaultTransactionAttribute ()
29  *
30  * @author Rod Johnson
31  */

32 public class TxClassWithClassAttribute {
33     
34     
35     public int inheritClassTxAttribute(int i) {
36         return i;
37     }
38     
39     /**
40      * Inherits transaction attribute from class.
41      * Illustrates programmatic rollback.
42      * @param rollbackOnly
43      */

44     public void rollbackOnly(boolean rollbackOnly) {
45         if (rollbackOnly) {
46             setRollbackOnly();
47         }
48     }
49     
50     /**
51      * Extracted in a protected method to facilitate testing
52      */

53     protected void setRollbackOnly() {
54         TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
55     }
56
57     /**
58      * @@org.springframework.transaction.interceptor.RuleBasedTransactionAttribute ()
59      * @@org.springframework.transaction.interceptor.RollbackRuleAttribute (Exception.class)
60      * @@org.springframework.transaction.interceptor.NoRollbackRuleAttribute ("ServletException")
61      */

62     public void echoException(Exception JavaDoc ex) throws Exception JavaDoc {
63         if (ex != null)
64             throw ex;
65     }
66
67 }
68
Popular Tags