|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.acegisecurity.intercept.method.aopalliance; |
|
17 |
| |
|
18 |
| import org.acegisecurity.intercept.method.MethodDefinitionSource; |
|
19 |
| |
|
20 |
| import org.aopalliance.intercept.MethodInvocation; |
|
21 |
| |
|
22 |
| import org.springframework.aop.framework.AopConfigException; |
|
23 |
| import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; |
|
24 |
| |
|
25 |
| import java.lang.reflect.AccessibleObject; |
|
26 |
| import java.lang.reflect.Method; |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| public class MethodDefinitionSourceAdvisor |
|
56 |
| extends StaticMethodMatcherPointcutAdvisor { |
|
57 |
| |
|
58 |
| |
|
59 |
| private MethodDefinitionSource transactionAttributeSource; |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
5
| public MethodDefinitionSourceAdvisor(MethodSecurityInterceptor advice) {
|
|
64 |
5
| super(advice);
|
|
65 |
| |
|
66 |
5
| if (advice.getObjectDefinitionSource() == null) {
|
|
67 |
1
| throw new AopConfigException(
|
|
68 |
| "Cannot construct a MethodDefinitionSourceAdvisor using a " |
|
69 |
| + "MethodSecurityInterceptor that has no ObjectDefinitionSource configured"); |
|
70 |
| } |
|
71 |
| |
|
72 |
4
| this.transactionAttributeSource = advice.getObjectDefinitionSource();
|
|
73 |
| } |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
2
| public boolean matches(Method m, Class targetClass) {
|
|
78 |
2
| MethodInvocation methodInvocation = new InternalMethodInvocation(m);
|
|
79 |
| |
|
80 |
2
| return (this.transactionAttributeSource.getAttributes(methodInvocation) != null);
|
|
81 |
| } |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| class InternalMethodInvocation implements MethodInvocation { |
|
94 |
| Method method; |
|
95 |
| |
|
96 |
3
| public InternalMethodInvocation(Method method) {
|
|
97 |
3
| this.method = method;
|
|
98 |
| } |
|
99 |
| |
|
100 |
1
| protected InternalMethodInvocation() {
|
|
101 |
1
| throw new UnsupportedOperationException();
|
|
102 |
| } |
|
103 |
| |
|
104 |
1
| public Object[] getArguments() {
|
|
105 |
1
| throw new UnsupportedOperationException();
|
|
106 |
| } |
|
107 |
| |
|
108 |
2
| public Method getMethod() {
|
|
109 |
2
| return this.method;
|
|
110 |
| } |
|
111 |
| |
|
112 |
1
| public AccessibleObject getStaticPart() {
|
|
113 |
1
| throw new UnsupportedOperationException();
|
|
114 |
| } |
|
115 |
| |
|
116 |
1
| public Object getThis() {
|
|
117 |
1
| throw new UnsupportedOperationException();
|
|
118 |
| } |
|
119 |
| |
|
120 |
1
| public Object proceed() throws Throwable {
|
|
121 |
1
| throw new UnsupportedOperationException();
|
|
122 |
| } |
|
123 |
| } |
|
124 |
| } |