1 7 package org.jboss.webservice.metadata.jaxrpcmapping; 8 9 11 import org.jboss.logging.Logger; 12 13 import javax.xml.namespace.QName ; 14 import java.util.ArrayList ; 15 import java.util.Iterator ; 16 17 23 public class JavaWsdlMapping 24 { 25 private final Logger log = Logger.getLogger(JavaWsdlMapping.class); 27 28 private ArrayList packageMappings = new ArrayList (); 30 private ArrayList javaXmlTypeMappings = new ArrayList (); 32 private ArrayList exceptionMappings = new ArrayList (); 34 private ArrayList serviceInterfaceMappings = new ArrayList (); 36 private ArrayList serviceEndpointInterfaceMappings = new ArrayList (); 38 39 public PackageMapping[] getPackageMappings() 40 { 41 PackageMapping[] arr = new PackageMapping[packageMappings.size()]; 42 packageMappings.toArray(arr); 43 return arr; 44 } 45 46 public JavaXmlTypeMapping[] getJavaXmlTypeMappings() 47 { 48 JavaXmlTypeMapping[] arr = new JavaXmlTypeMapping[javaXmlTypeMappings.size()]; 49 javaXmlTypeMappings.toArray(arr); 50 return arr; 51 } 52 53 public ExceptionMapping[] getExceptionMappings() 54 { 55 ExceptionMapping[] arr = new ExceptionMapping[exceptionMappings.size()]; 56 exceptionMappings.toArray(arr); 57 return arr; 58 } 59 60 public ServiceInterfaceMapping[] getServiceInterfaceMappings() 61 { 62 ServiceInterfaceMapping[] arr = new ServiceInterfaceMapping[serviceInterfaceMappings.size()]; 63 serviceInterfaceMappings.toArray(arr); 64 return arr; 65 } 66 67 public ServiceEndpointInterfaceMapping[] getServiceEndpointInterfaceMappings() 68 { 69 ServiceEndpointInterfaceMapping[] arr = new ServiceEndpointInterfaceMapping[serviceEndpointInterfaceMappings.size()]; 70 serviceEndpointInterfaceMappings.toArray(arr); 71 return arr; 72 } 73 74 76 78 public String getPackageTypeForURI(String uri) 79 { 80 String packageStr = null; 81 for (int i = 0; packageStr == null && i < packageMappings.size(); i++) 82 { 83 PackageMapping mapping = (PackageMapping)packageMappings.get(i); 84 if (mapping.getNamespaceURI().equals(uri)) 85 packageStr = mapping.getPackageType(); 86 } 87 return packageStr; 88 } 89 90 91 93 public JavaXmlTypeMapping getTypeMappingForQName(QName xmlType) 94 { 95 JavaXmlTypeMapping typeMapping = null; 96 97 if (xmlType != null) 98 { 99 Iterator it = javaXmlTypeMappings.iterator(); 101 while (typeMapping == null && it.hasNext()) 102 { 103 JavaXmlTypeMapping mapping = (JavaXmlTypeMapping)it.next(); 104 if (xmlType.equals(mapping.getRootTypeQName())) 105 typeMapping = mapping; 106 } 107 108 it = javaXmlTypeMappings.iterator(); 110 while (typeMapping == null && it.hasNext()) 111 { 112 JavaXmlTypeMapping mapping = (JavaXmlTypeMapping)it.next(); 113 QName anonymousQName = mapping.getAnonymousTypeQName(); 114 if (anonymousQName != null) 115 { 116 if (xmlType.getNamespaceURI().equals(anonymousQName.getNamespaceURI())) 117 { 118 String localPart = xmlType.getLocalPart(); 119 if (anonymousQName.getLocalPart().equals(localPart)) 120 typeMapping = mapping; 121 if (anonymousQName.getLocalPart().equals(">" + localPart)) 122 typeMapping = mapping; 123 } 124 } 125 } 126 127 if (typeMapping == null) 128 log.warn("Cannot find jaxrpc-mapping for type: " + xmlType); 129 } 130 131 return typeMapping; 132 } 133 134 136 public ExceptionMapping getExceptionMappingForMessageQName(QName wsdlMessage) 137 { 138 ExceptionMapping exMapping = null; 139 140 if (wsdlMessage != null) 141 { 142 Iterator it = exceptionMappings.iterator(); 143 while (it.hasNext()) 144 { 145 ExceptionMapping mapping = (ExceptionMapping)it.next(); 146 if (wsdlMessage.equals(mapping.getWsdlMessage())) 147 exMapping = mapping; 148 } 149 } 150 151 return exMapping; 152 } 153 154 156 public QName getPortTypeQNameForServiceEndpointInterface(String seiName) 157 { 158 QName portTypeQName = null; 159 160 ServiceEndpointInterfaceMapping[] seiMappings = getServiceEndpointInterfaceMappings(); 161 for (int i = 0; i < seiMappings.length; i++) 162 { 163 ServiceEndpointInterfaceMapping aux = seiMappings[i]; 164 if (aux.getServiceEndpointInterface().equals(seiName)) 165 portTypeQName = aux.getWsdlPortType(); 166 } 167 168 return portTypeQName; 169 } 170 171 173 public ServiceEndpointInterfaceMapping getServiceEndpointInterfaceMappingByPortType(QName portType) 174 { 175 ServiceEndpointInterfaceMapping seiMapping = null; 176 177 ServiceEndpointInterfaceMapping[] seiMappings = getServiceEndpointInterfaceMappings(); 178 for (int i = 0; seiMapping == null && i < seiMappings.length; i++) 179 { 180 ServiceEndpointInterfaceMapping aux = seiMappings[i]; 181 if (aux.getWsdlPortType().equals(portType)) 182 seiMapping = aux; 183 } 184 185 return seiMapping; 186 } 187 188 190 public ServiceEndpointInterfaceMapping getServiceEndpointInterfaceMapping(String seiName) 191 { 192 ServiceEndpointInterfaceMapping seiMapping = null; 193 194 ServiceEndpointInterfaceMapping[] seiMappings = getServiceEndpointInterfaceMappings(); 195 for (int i = 0; seiMapping == null && i < seiMappings.length; i++) 196 { 197 ServiceEndpointInterfaceMapping aux = seiMappings[i]; 198 if (aux.getServiceEndpointInterface().equals(seiName)) 199 seiMapping = aux; 200 } 201 202 return seiMapping; 203 } 204 205 207 public void addPackageMapping(PackageMapping packageMapping) 208 { 209 packageMappings.add(packageMapping); 210 } 211 212 public void addJavaXmlTypeMappings(JavaXmlTypeMapping typeMapping) 213 { 214 javaXmlTypeMappings.add(typeMapping); 215 } 216 217 public void addExceptionMappings(ExceptionMapping exceptionMapping) 218 { 219 exceptionMappings.add(exceptionMapping); 220 } 221 222 public void addServiceInterfaceMappings(ServiceInterfaceMapping serviceInterfaceMapping) 223 { 224 serviceInterfaceMappings.add(serviceInterfaceMapping); 225 } 226 227 public void addServiceEndpointInterfaceMappings(ServiceEndpointInterfaceMapping serviceEndpointInterfaceMapping) 228 { 229 serviceEndpointInterfaceMappings.add(serviceEndpointInterfaceMapping); 230 } 231 } 232 | Popular Tags |