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.util.ArrayList;
13 import java.util.List;
14 import org.objectweb.asm.Opcodes;
15
16 import org.objectweb.asm.commons.EmptyVisitor;
17
18
19
20
21 public class CorbaOnewayMethodVisitor extends EmptyVisitor {
22
23
24
25
26 private static final Logger LOG
27 = LoggerFactory.getLogger(CorbaOnewayMethodVisitor.class);
28
29
30 protected String internalStubName = null;
31
32
33 protected String methodName = null;
34
35
36 protected List<String> onewayOperationList = new ArrayList<String>();
37
38
39 protected boolean zero = false;
40
41
42
43
44
45
46
47
48 public CorbaOnewayMethodVisitor(String stub, String aMethodName,
49 List<String> aOnewayOperationList) {
50 super();
51 internalStubName = stub;
52 methodName = aMethodName;
53 onewayOperationList = aOnewayOperationList;
54 }
55
56
57
58
59
60 @Override
61 public void visitInsn(int opcode) {
62 super.visitInsn(opcode);
63
64 if (Opcodes.ICONST_0 == opcode) {
65 zero = true;
66 } else {
67 zero = false;
68 }
69
70 }
71
72
73
74
75
76
77
78
79 @Override
80 public void visitMethodInsn(int opcode,String owner,String name,String desc) {
81
82 LOG.debug("CorbaOnewayMethodVisitor.visitMethodInsn. opcode=" + opcode
83 + "; owner=" + owner + "; name=" + name + "; desc=" + desc);
84
85 final String corbaOutputStream = "(Ljava/lang/String;Z)"
86 + "Lorg/omg/CORBA/portable/OutputStream;";
87
88
89
90
91
92
93
94
95 if (Opcodes.INVOKEVIRTUAL == opcode
96 && owner.equals(internalStubName)
97 && "_request".equals(name)
98 && corbaOutputStream.equals(desc)
99 && zero) {
100
101 LOG.debug("The method " + methodName + " is a oneway corba request.");
102 onewayOperationList.add(methodName);
103 } else {
104 LOG.debug("The method " + methodName + " is NOT a oneway corba request.");
105 }
106
107 super.visitMethodInsn(opcode, owner, name, desc);
108 }
109
110 }