1
2
3
4
5
6
7
8
9 package it.imolinfo.jbi4corba.webservice.generator.bcm;
10
11 import it.imolinfo.jbi4corba.Logger;
12 import it.imolinfo.jbi4corba.LoggerFactory;
13
14 import org.objectweb.asm.ClassAdapter;
15 import org.objectweb.asm.ClassVisitor;
16 import org.objectweb.asm.MethodVisitor;
17
18
19
20
21
22
23
24 public class RemoteEnhancerAdapter extends ClassAdapter {
25
26
27
28
29 private static final Logger LOG
30 = LoggerFactory.getLogger(RemoteEnhancerAdapter.class);
31
32
33
34
35 protected String portTypeClassName;
36
37
38
39
40 String completeName;
41
42
43
44
45
46
47
48
49 public RemoteEnhancerAdapter(ClassVisitor arg0, String portTypeClassName) {
50 super(arg0);
51 this.portTypeClassName = portTypeClassName;
52 }
53
54
55
56
57
58
59
60
61
62
63 @Override
64 public void visit(int version,
65 int access,
66 String name,
67 String signature,
68 String superName,
69 String [] interfaces) {
70
71 LOG.debug(">>>>> visit - begin");
72
73 String newName = portTypeClassName + "CorbaInterface";
74
75 String [] newInterfaces;
76
77 if (interfaces == null){
78
79 newInterfaces = new String [] {"java/rmi/Remote"};
80
81 } else {
82
83 newInterfaces = new String[interfaces.length + 1];
84
85 for (int i = 0; i < interfaces.length; i++) {
86 newInterfaces[i] = interfaces[i];
87 }
88
89 newInterfaces[newInterfaces.length - 1] = "java/rmi/Remote";
90 }
91
92 super.visit(version, access, newName, signature, superName, newInterfaces);
93
94 completeName = newName;
95
96 LOG.debug("<<<<< visit - end");
97 }
98
99
100
101
102
103
104
105
106
107
108 @Override
109 public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
110 String[] newExceptions;
111 if (exceptions==null){
112 newExceptions=new String[]{"java/rmi/RemoteException"};
113 } else {
114 newExceptions = new String[exceptions.length + 1];
115 if (exceptions!=null){
116 for (int i = 0; i < exceptions.length; i++) {
117 newExceptions[i] = exceptions[i];
118 }
119 }
120 newExceptions[newExceptions.length - 1] = "java/rmi/RemoteException";
121 }
122 return super.visitMethod(access, name, desc, signature, newExceptions);
123 }
124
125
126
127
128 public String getCompleteName() {
129 return completeName;
130 }
131
132 }