1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.enhance; |
16 |
| |
17 |
| import java.lang.reflect.Method; |
18 |
| import java.lang.reflect.Modifier; |
19 |
| import java.util.HashSet; |
20 |
| import java.util.Set; |
21 |
| |
22 |
| import org.apache.hivemind.ErrorLog; |
23 |
| import org.apache.hivemind.service.MethodSignature; |
24 |
| import org.apache.tapestry.spec.IComponentSpecification; |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| public class EnhancedClassValidatorImpl implements EnhancedClassValidator |
34 |
| { |
35 |
| private ErrorLog _errorLog; |
36 |
| |
37 |
421
| public void validate(Class baseClass, Class enhancedClass, IComponentSpecification specification)
|
38 |
| { |
39 |
421
| Set implementedMethods = new HashSet();
|
40 |
| |
41 |
421
| Class current = enhancedClass;
|
42 |
| |
43 |
421
| while (true)
|
44 |
| { |
45 |
1161
| Method[] methods = current.getDeclaredMethods();
|
46 |
| |
47 |
1161
| for (int i = 0; i < methods.length; i++)
|
48 |
| { |
49 |
22888
| Method m = methods[i];
|
50 |
| |
51 |
22888
| boolean isAbstract = Modifier.isAbstract(m.getModifiers());
|
52 |
| |
53 |
22888
| MethodSignature s = new MethodSignature(m);
|
54 |
| |
55 |
22888
| if (isAbstract)
|
56 |
| { |
57 |
2117
| if (implementedMethods.contains(s))
|
58 |
2116
| continue;
|
59 |
| |
60 |
1
| _errorLog.error(EnhanceMessages.noImplForAbstractMethod(m, current, baseClass
|
61 |
| .getName(), enhancedClass), specification.getLocation(), null); |
62 |
| } |
63 |
| |
64 |
20772
| implementedMethods.add(s);
|
65 |
| } |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
1161
| current = current.getSuperclass();
|
75 |
| |
76 |
| |
77 |
| |
78 |
| |
79 |
| |
80 |
| |
81 |
1161
| if (current == null || !Modifier.isAbstract(current.getModifiers()))
|
82 |
421
| break;
|
83 |
| } |
84 |
| |
85 |
| } |
86 |
| |
87 |
42
| public void setErrorLog(ErrorLog errorLog)
|
88 |
| { |
89 |
42
| _errorLog = errorLog;
|
90 |
| } |
91 |
| } |