KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.Serializable JavaDoc;
20 import java.lang.reflect.Method JavaDoc;
21
22 import org.springframework.util.Assert;
23
24 /**
25  * Composite {@link TransactionAttributeSource} implementation that iterates
26  * over a given array of {@link TransactionAttributeSource} instances.
27  *
28  * @author Juergen Hoeller
29  * @since 2.0
30  */

31 public class CompositeTransactionAttributeSource implements TransactionAttributeSource, Serializable JavaDoc {
32
33     private final TransactionAttributeSource[] transactionAttributeSources;
34
35
36     /**
37      * Create a new CompositeTransactionAttributeSource for the given sources.
38      * @param transactionAttributeSources the TransactionAttributeSource instances to combine
39      */

40     public CompositeTransactionAttributeSource(TransactionAttributeSource[] transactionAttributeSources) {
41         Assert.notNull(transactionAttributeSources, "TransactionAttributeSource array must not be null");
42         this.transactionAttributeSources = transactionAttributeSources;
43     }
44
45     /**
46      * Return the TransactionAttributeSource instances that this
47      * CompositeTransactionAttributeSource combines.
48      */

49     public final TransactionAttributeSource[] getTransactionAttributeSources() {
50         return this.transactionAttributeSources;
51     }
52
53
54     public TransactionAttribute getTransactionAttribute(Method JavaDoc method, Class JavaDoc targetClass) {
55         for (int i = 0; i < this.transactionAttributeSources.length; i++) {
56             TransactionAttributeSource tas = this.transactionAttributeSources[i];
57             TransactionAttribute ta = tas.getTransactionAttribute(method, targetClass);
58             if (ta != null) {
59                 return ta;
60             }
61         }
62         return null;
63     }
64
65 }
66
Popular Tags