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 import java.io.StringWriter;
13 import java.util.ArrayList;
14 import java.util.List;
15
16
17 import org.objectweb.asm.ClassAdapter;
18 import org.objectweb.asm.ClassVisitor;
19 import org.objectweb.asm.MethodVisitor;
20
21
22
23
24
25 public class CorbaOnewayAdapter extends ClassAdapter {
26
27
28 private static final Logger LOG
29 = LoggerFactory.getLogger(CorbaOnewayAdapter.class);
30
31
32 private String internalClassName = null;
33
34
35 private String associatedInterface = null;
36
37
38 private List<String> onewayOperationList = new ArrayList<String>();
39
40
41 protected StringWriter stringWriter = null;
42
43
44
45
46
47
48
49
50 public CorbaOnewayAdapter(ClassVisitor cv, StringWriter cw) {
51 super(cv);
52 stringWriter = cw;
53 }
54
55
56
57
58
59
60
61
62
63
64 @Override
65 public void visit(int version,
66 int access,
67 String name,
68 String signature,
69 String superName,
70 String [] interfaces) {
71 LOG.debug(">>>>> visit - begin");
72
73 LOG.debug("VISIT"
74 + ".\n version=" + version
75 + ";\n access=" + access
76 + ";\n name=" + name
77 + ";\n signature=" + signature
78 + ";\n superName=" + superName
79 + ";\n interfaces=" + interfaces);
80
81 setInternalClassName(name);
82
83
84
85
86
87
88
89
90
91
92
93
94 int underscoreIndex = name.lastIndexOf('/') + 1;
95
96
97 String tempSimpleName
98 = name.substring(underscoreIndex + 1, name.length() - 4);
99 String tempPackage
100 = name.substring(0, underscoreIndex);
101 String temp = tempPackage.replace('/', '.') + tempSimpleName;
102
103 setAssociatedInterface(temp + "Operations");
104
105
106 LOG.debug("<<<<< visit - end");
107 super.visit(version, access, name, signature, superName, interfaces);
108 }
109
110
111
112
113
114
115
116
117
118
119 @Override
120 public MethodVisitor visitMethod(int access,
121 String name,
122 String desc,
123 String signature,
124 String[] exceptions) {
125
126 LOG.debug(">>>>> visitMethod - begin");
127
128 LOG.debug("visitMethod. access=" + access
129 + "; name=" + name
130 + "; desc=" + desc
131 + "; signature=" + signature
132 + "; exceptions=" + exceptions);
133
134 CorbaOnewayMethodVisitor corbaOnewayMethodVisitor
135 = new CorbaOnewayMethodVisitor(getInternalClassName(),
136 name,
137 getOnewayOperationList());
138
139 MethodVisitor mv = corbaOnewayMethodVisitor.visitMethod(access,
140 name,
141 desc,
142 signature,
143 exceptions);
144
145 LOG.debug("<<<<< visitMethod - end. "
146 + "methodName=" + name + "; methodDescription=" + desc);
147
148 return mv;
149 }
150
151
152
153
154
155
156 public String getInternalClassName() {
157 return internalClassName;
158 }
159
160
161
162
163 public void setInternalClassName(String internalClassName) {
164 this.internalClassName = internalClassName;
165 }
166
167
168
169
170 public List<String> getOnewayOperationList() {
171 return onewayOperationList;
172 }
173
174
175
176
177 public void setOnewayOperationList(List<String> onewayOperationList) {
178 this.onewayOperationList = onewayOperationList;
179 }
180
181
182
183
184 public String getAssociatedInterface() {
185 return associatedInterface;
186 }
187
188
189
190
191 public void setAssociatedInterface(String associatedInterface) {
192 this.associatedInterface = associatedInterface;
193 }
194
195 }