1
2
3
4
5
6
7
8 package it.imolinfo.jbi4corba.webservice.generator.bcm;
9
10 import it.imolinfo.jbi4corba.Logger;
11 import it.imolinfo.jbi4corba.LoggerFactory;
12
13 import org.objectweb.asm.AnnotationVisitor;
14 import org.objectweb.asm.ClassAdapter;
15 import org.objectweb.asm.ClassVisitor;
16 import org.objectweb.asm.ClassWriter;
17 import org.objectweb.asm.FieldVisitor;
18 import org.objectweb.asm.MethodVisitor;
19
20
21
22
23 public class AnnotationCollectorAdapter extends ClassAdapter {
24
25
26
27
28 private static final Logger LOG = LoggerFactory.getLogger(
29 AnnotationCollectorAdapter.class);
30
31
32
33
34 protected ClassWriter classWriter = null;
35
36
37
38
39 protected String className = null;
40
41
42
43
44 protected String javaClassName = null;
45
46 protected AnnotationsMaps tracer = null;
47
48
49
50
51
52
53
54
55
56
57
58 public AnnotationCollectorAdapter(ClassVisitor cv, ClassWriter cw, String cn,
59 AnnotationsMaps tracer, String javaClassName) {
60
61 super(cv);
62 classWriter = cw;
63 className = cn;
64
65 this.javaClassName = javaClassName;
66
67 this.tracer = (tracer == null) ? new AnnotationsMaps() : tracer;
68 }
69
70
71
72
73
74
75
76 @Override
77 public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
78 LOG.info("CRB000602_ANNOTATION", new Object[]{desc, visible});
79
80 AnnotationCollectorVisitor visitor
81 = new AnnotationCollectorVisitor();
82
83
84
85
86 AnnotationCollectorVisitor av = (AnnotationCollectorVisitor)
87 visitor.visitAnnotation(desc, visible);
88
89 AnnotationVisibleAndValue avv
90 = new AnnotationVisibleAndValue(visible, av.list);
91
92 tracer.annotationOnClass.put(desc, avv);
93
94 return av;
95 }
96
97
98
99
100
101
102
103
104
105
106 @Override
107 public MethodVisitor visitMethod(int access,
108 String name,
109 String desc,
110 String signature,
111 String[] exceptions) {
112
113 AnnotationCollectorMethodVisitor mv
114 = new AnnotationCollectorMethodVisitor(tracer, name);
115
116 return mv.visitMethod(access, name, desc, signature, exceptions);
117 }
118
119
120
121
122
123
124
125
126
127
128 @Override
129 public FieldVisitor visitField(int access,
130 String name,
131 String desc,
132 String signature,
133 Object value) {
134 LOG.debug(">>>>> visitField - begin");
135
136 AnnotationCollectorFieldVisitor fv
137 = new AnnotationCollectorFieldVisitor(tracer, name);
138
139 LOG.debug(">>>>> visitField - end");
140 return fv.visitField(access, name, desc, signature, value);
141 }
142
143 }