|
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 java.util.ArrayList; |
|
29 |
| import java.util.List; |
|
30 |
| |
|
31 |
| import org.objectweb.easybeans.deployment.annotations.exceptions.ResolverException; |
|
32 |
| import org.objectweb.easybeans.deployment.annotations.impl.JLocal; |
|
33 |
| import org.objectweb.easybeans.deployment.annotations.impl.JRemote; |
|
34 |
| import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; |
|
35 |
| import org.objectweb.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata; |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| public final class InheritanceInterfacesHelper { |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| public static final String JAVA_LANG_OBJECT = "java/lang/Object"; |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
0
| private InheritanceInterfacesHelper() {
|
|
53 |
| |
|
54 |
| } |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
31
| public static void resolve(final ClassAnnotationMetadata classAnnotationMetadata) throws ResolverException {
|
|
63 |
31
| loop(classAnnotationMetadata, classAnnotationMetadata);
|
|
64 |
| |
|
65 |
| } |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
37
| public static void loop(final ClassAnnotationMetadata beanClassAnnotationMetadata,
|
|
74 |
| final ClassAnnotationMetadata visitingClassAnnotationMetadata) throws ResolverException { |
|
75 |
37
| String superClass = visitingClassAnnotationMetadata.getSuperName();
|
|
76 |
37
| if (superClass != null) {
|
|
77 |
| |
|
78 |
37
| if (!superClass.equals(JAVA_LANG_OBJECT)) {
|
|
79 |
6
| EjbJarAnnotationMetadata ejbJarAnnotationMetadata = beanClassAnnotationMetadata
|
|
80 |
| .getEjbJarAnnotationMetadata(); |
|
81 |
6
| ClassAnnotationMetadata superMetadata = ejbJarAnnotationMetadata.getClassAnnotationMetadata(superClass);
|
|
82 |
| |
|
83 |
6
| if (superMetadata == null) {
|
|
84 |
0
| throw new IllegalStateException("No super class named '" + superClass
|
|
85 |
| + "' was analyzed. But it is referenced from '" + visitingClassAnnotationMetadata.getClassName() |
|
86 |
| + "'."); |
|
87 |
| } |
|
88 |
| |
|
89 |
| |
|
90 |
6
| List<String> newInterfacesLst = new ArrayList<String>();
|
|
91 |
6
| String[] currentInterfaces = beanClassAnnotationMetadata.getInterfaces();
|
|
92 |
6
| if (currentInterfaces != null) {
|
|
93 |
6
| for (String itf : currentInterfaces) {
|
|
94 |
6
| newInterfacesLst.add(itf);
|
|
95 |
| } |
|
96 |
| } |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
6
| String[] superInterfaces = superMetadata.getInterfaces();
|
|
101 |
6
| if (superInterfaces != null) {
|
|
102 |
6
| for (String itf : superInterfaces) {
|
|
103 |
6
| if (!newInterfacesLst.contains(itf)) {
|
|
104 |
0
| newInterfacesLst.add(itf);
|
|
105 |
| } |
|
106 |
| } |
|
107 |
| } |
|
108 |
| |
|
109 |
| |
|
110 |
6
| beanClassAnnotationMetadata.setInterfaces(newInterfacesLst.toArray(new String[newInterfacesLst.size()]));
|
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
6
| JLocal currentLocalInterfaces = beanClassAnnotationMetadata.getLocalInterfaces();
|
|
115 |
6
| JLocal superLocalInterfaces = superMetadata.getLocalInterfaces();
|
|
116 |
6
| if (superLocalInterfaces != null) {
|
|
117 |
0
| if (currentLocalInterfaces == null) {
|
|
118 |
0
| currentLocalInterfaces = new JLocal();
|
|
119 |
0
| beanClassAnnotationMetadata.setLocalInterfaces(currentLocalInterfaces);
|
|
120 |
| } |
|
121 |
0
| for (String itf : superLocalInterfaces.getInterfaces()) {
|
|
122 |
0
| if (!currentLocalInterfaces.getInterfaces().contains(itf)) {
|
|
123 |
0
| currentLocalInterfaces.addInterface(itf);
|
|
124 |
| } |
|
125 |
| } |
|
126 |
| } |
|
127 |
| |
|
128 |
| |
|
129 |
6
| JRemote currentRemoteInterfaces = beanClassAnnotationMetadata.getRemoteInterfaces();
|
|
130 |
6
| JRemote superRemoteInterfaces = superMetadata.getRemoteInterfaces();
|
|
131 |
6
| if (superRemoteInterfaces != null) {
|
|
132 |
0
| if (currentRemoteInterfaces == null) {
|
|
133 |
0
| currentRemoteInterfaces = new JRemote();
|
|
134 |
0
| beanClassAnnotationMetadata.setRemoteInterfaces(currentRemoteInterfaces);
|
|
135 |
| } |
|
136 |
0
| for (String itf : superRemoteInterfaces.getInterfaces()) {
|
|
137 |
0
| if (!currentRemoteInterfaces.getInterfaces().contains(itf)) {
|
|
138 |
0
| currentRemoteInterfaces.addInterface(itf);
|
|
139 |
| } |
|
140 |
| } |
|
141 |
| } |
|
142 |
| |
|
143 |
| |
|
144 |
6
| if (!superMetadata.getClassName().equals(JAVA_LANG_OBJECT)) {
|
|
145 |
6
| loop(beanClassAnnotationMetadata, superMetadata);
|
|
146 |
| } |
|
147 |
| } |
|
148 |
| } |
|
149 |
| } |
|
150 |
| } |