1
2
3
4
5
6
7
8 package it.imolinfo.jbi4corba.webservice.generator;
9
10 import it.imolinfo.jbi4corba.Logger;
11 import it.imolinfo.jbi4corba.LoggerFactory;
12 import it.imolinfo.jbi4corba.webservice.generator.bcm.InternalMethodDescriptionParser;
13
14 import java.util.HashMap;
15 import java.util.Map;
16
17 import java.util.Set;
18 import org.objectweb.asm.Type;
19 import org.omg.CORBA.TCKind;
20
21
22
23
24
25 public class InterfaceTypeUtils extends TypeUtils {
26
27 private static final TCKind INTERFACE = TCKind.tk_objref;
28
29 private static final Logger LOG = LoggerFactory
30 .getLogger(InterfaceTypeUtils.class);
31
32 @Override
33 protected SearchedType processType(Class clsType) {
34
35 InterfaceType it = new InterfaceType(clsType.getName());
36
37 return it;
38
39 }
40
41 @Override
42 protected Map<String, Class> getFields(Class clsUnion) {
43 return new HashMap<String, Class>();
44 }
45
46
47
48
49
50
51
52 public static InterfaceType isInterfaceType(String desc, boolean isArray,
53 Map<String, InterfaceType> allInterfaceTypes) {
54
55 return (InterfaceType) TypeUtils.isSearchedType(desc, isArray,
56 allInterfaceTypes, INTERFACE);
57 }
58
59
60
61
62
63
64
65
66
67
68 public static String changeInterfaceTypeDesc(String desc,
69 Map allInterfaceTypes) {
70
71 LOG.debug("Changing description: " + desc);
72
73
74 int start = desc.indexOf("(");
75 String descStart = desc.substring(0, start + 1);
76
77
78 InternalMethodDescriptionParser parser = new InternalMethodDescriptionParser(desc);
79 String params[] = parser.parse().toArray(new String[] {});
80
81
82 String result = descStart;
83 String retType = null;
84
85
86 for (int i = 0; i < params.length; i++) {
87 LOG.debug("Investigating: " + params[i]);
88 boolean isArray = TypeUtils.isArray(params[i]);
89 if (TypeUtils.isSearchedType(params[i], isArray,
90 allInterfaceTypes, TypeUtils.INTERFACE) != null) {
91
92 if (isArray) {
93
94 result += Type
95 .getDescriptor(javax.xml.ws.wsaddressing.W3CEndpointReference[].class);
96 } else {
97 result += Type
98 .getDescriptor(javax.xml.ws.wsaddressing.W3CEndpointReference.class);
99 }
100
101 } else {
102 result += params[i];
103 }
104 }
105
106 result += ")";
107
108 retType = parser.getMethodDescriptionTail();
109
110 if (retType.contains("L")) {
111
112 boolean isArray = TypeUtils.isArray(retType);
113 if (retType != null) {
114
115 if (TypeUtils.isSearchedType(retType, isArray,
116 allInterfaceTypes, TypeUtils.INTERFACE) != null) {
117
118 if (isArray) {
119
120 retType = Type
121 .getDescriptor(javax.xml.ws.wsaddressing.W3CEndpointReference[].class);
122 } else {
123 retType = Type
124 .getDescriptor(javax.xml.ws.wsaddressing.W3CEndpointReference.class);
125 }
126 }
127 }
128 } if (retType != null) {
129 result += retType;
130 }
131 LOG.debug("Changing description end, returning: " + result);
132 return result;
133
134 }
135
136 @Override
137 protected void setMethodTypes(MethodSignature methodSignature,
138 Set<String> typeList) {
139 methodSignature.setMethodInterfaceTypes(typeList);
140 }
141
142 }