KickJava   Java API By Example, From Geeks To Geeks.

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


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 // This import is purely to allow attributes to use constants defined in this class:
20
// and to avoid FQNs
21
// don't let your IDE remove it!
22
import org.springframework.transaction.TransactionDefinition;
23 import org.springframework.transaction.interceptor.*;
24
25 /**
26  * The attribute syntax is that of Commons Attributes.
27  *
28  * @author Rod Johnson
29  */

30 public class TxClassImpl implements TxClass {
31     
32     private int invocations;
33     
34     /**
35      * The following constant requires TransactionDefinition to be imported.
36      * Of course an FQN could be used...
37      * @@DefaultTransactionAttribute (TransactionDefinition.PROPAGATION_REQUIRED)
38      */

39     public int defaultTxAttribute() {
40         return ++invocations;
41     }
42     
43     
44     /**
45      * Don't put a space before string values...
46      * We don't need FQN because we imported this package.
47      * The first RollbackRuleAttribute shows the preferred constructor,
48      * taking a Class rather than a String. Normally this class wouldn't
49      * need to be imported, as it would be imported for use in the business method.
50      * Note that both FQN and relying on the import above work.
51      *
52      * @@RuleBasedTransactionAttribute()
53      * @@RollbackRuleAttribute (Exception.class)
54      * @@org.springframework.transaction.interceptor.NoRollbackRuleAttribute ("ServletException")
55      */

56     public void echoException(Exception JavaDoc ex) throws Exception JavaDoc {
57         if (ex != null)
58             throw ex;
59     }
60
61 }
62
Popular Tags