1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.impl.util.spring; |
17 | |
|
18 | |
import java.lang.reflect.Method; |
19 | |
|
20 | |
import org.apache.commons.beanutils.PropertyUtils; |
21 | |
import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource; |
22 | |
import org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource; |
23 | |
import org.springframework.transaction.interceptor.TransactionAttribute; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class AnnotationAndNameMatchingTransactionAttributeSource extends NameMatchTransactionAttributeSource { |
30 | |
|
31 | |
private static final long serialVersionUID = 6119879657045541414L; |
32 | |
|
33 | |
private AnnotationTransactionAttributeSource annotationTransactionAttributeSource; |
34 | |
private Integer transactionTimeout; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@Override |
41 | |
public TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass) { |
42 | 0 | TransactionAttribute transactionAttribute = annotationTransactionAttributeSource.getTransactionAttribute(method, targetClass); |
43 | 0 | if (transactionAttribute != null) { |
44 | 0 | TransactionAttribute overridingTransactionAttribute = super.getTransactionAttribute(method, targetClass); |
45 | 0 | if (overridingTransactionAttribute != null) { |
46 | 0 | transactionAttribute = overridingTransactionAttribute; |
47 | |
} |
48 | |
} |
49 | 0 | setTimeout(transactionAttribute); |
50 | 0 | return transactionAttribute; |
51 | |
} |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
public void setAnnotationTransactionAttributeSource(AnnotationTransactionAttributeSource annotationTransactionAttributeSource) { |
59 | 0 | this.annotationTransactionAttributeSource = annotationTransactionAttributeSource; |
60 | 0 | } |
61 | |
|
62 | |
public void setTransactionTimeout(Integer transactionTimeout) { |
63 | 0 | this.transactionTimeout = transactionTimeout; |
64 | 0 | } |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
protected void setTimeout(TransactionAttribute transactionAttribute) { |
71 | |
try { |
72 | 0 | if (transactionTimeout != null) { |
73 | 0 | PropertyUtils.setSimpleProperty(transactionAttribute, "timeout", new Integer(transactionTimeout)); |
74 | |
} |
75 | 0 | } catch (Exception e) { |
76 | |
|
77 | 0 | } |
78 | 0 | } |
79 | |
} |