|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| package org.objectweb.easybeans.deployment.annotations.helper.bean; |
|
27 |
| |
|
28 |
| import org.objectweb.easybeans.deployment.annotations.JMethod; |
|
29 |
| import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; |
|
30 |
| import org.objectweb.easybeans.deployment.annotations.metadata.MethodAnnotationMetadata; |
|
31 |
| import org.objectweb.easybeans.log.JLog; |
|
32 |
| import org.objectweb.easybeans.log.JLogFactory; |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| public final class BusinessMethodResolver { |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| private static final String CLASS_INIT = "<clinit>"; |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| private static final String CONST_INIT = "<init>"; |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| private static JLog logger = JLogFactory.getLog(BusinessMethodResolver.class); |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
0
| private BusinessMethodResolver() {
|
|
62 |
| |
|
63 |
| } |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
31
| public static void resolve(final ClassAnnotationMetadata classAnnotationMetadata) {
|
|
71 |
31
| loop(classAnnotationMetadata, classAnnotationMetadata);
|
|
72 |
| } |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
70
| private static void loop(final ClassAnnotationMetadata beanclassAnnotationMetadata,
|
|
81 |
| final ClassAnnotationMetadata visitingclassAnnotationMetadata) { |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
70
| for (String itf : visitingclassAnnotationMetadata.getInterfaces()) {
|
|
86 |
39
| if (itf.startsWith("javax/ejb/") || itf.startsWith("java/io/Serializable")
|
|
87 |
| || itf.startsWith("java/io/Externalizable")) { |
|
88 |
0
| continue;
|
|
89 |
| } |
|
90 |
| |
|
91 |
| |
|
92 |
39
| ClassAnnotationMetadata itfMetadata = visitingclassAnnotationMetadata.getEjbJarAnnotationMetadata()
|
|
93 |
| .getClassAnnotationMetadata(itf); |
|
94 |
| |
|
95 |
39
| if (itfMetadata == null) {
|
|
96 |
0
| logger.warn("No class was found for interface {0}.", itf);
|
|
97 |
0
| continue;
|
|
98 |
| } |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
39
| for (MethodAnnotationMetadata methodData : itfMetadata.getMethodAnnotationMetadataCollection()) {
|
|
103 |
189
| JMethod itfMethod = methodData.getJMethod();
|
|
104 |
| |
|
105 |
| |
|
106 |
189
| if (itfMethod.getName().equals(CLASS_INIT) || itfMethod.getName().equals(CONST_INIT)) {
|
|
107 |
2
| continue;
|
|
108 |
| } |
|
109 |
| |
|
110 |
| |
|
111 |
187
| MethodAnnotationMetadata beanMethod = beanclassAnnotationMetadata.getMethodAnnotationMetadata(itfMethod);
|
|
112 |
187
| if (beanMethod == null) {
|
|
113 |
| |
|
114 |
0
| throw new IllegalStateException("No method was found for method " + itfMethod + " in class "
|
|
115 |
| + beanclassAnnotationMetadata.getClassName()); |
|
116 |
| } |
|
117 |
187
| beanMethod.setBusinessMethod(true);
|
|
118 |
| } |
|
119 |
| |
|
120 |
| |
|
121 |
39
| if (itfMetadata.getInterfaces() != null) {
|
|
122 |
39
| loop(beanclassAnnotationMetadata, itfMetadata);
|
|
123 |
| } |
|
124 |
| } |
|
125 |
| } |
|
126 |
| |
|
127 |
| } |