src/share/jaxws_classes/com/sun/xml/internal/ws/model/RuntimeModeler.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 384
8f2986ff0235
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
24 */ 24 */
25 25
26 package com.sun.xml.internal.ws.model; 26 package com.sun.xml.internal.ws.model;
27 27
28 import com.sun.istack.internal.NotNull; 28 import com.sun.istack.internal.NotNull;
29 import com.sun.istack.internal.localization.Localizable;
29 import com.sun.xml.internal.ws.api.BindingID; 30 import com.sun.xml.internal.ws.api.BindingID;
30 import com.sun.xml.internal.ws.api.SOAPVersion; 31 import com.sun.xml.internal.ws.api.SOAPVersion;
31 import com.sun.xml.internal.ws.api.WSBinding; 32 import com.sun.xml.internal.ws.api.WSBinding;
32 import com.sun.xml.internal.ws.api.databinding.DatabindingConfig; 33 import com.sun.xml.internal.ws.api.databinding.DatabindingConfig;
33 import com.sun.xml.internal.ws.api.databinding.MetadataReader; 34 import com.sun.xml.internal.ws.api.databinding.MetadataReader;
45 import com.sun.xml.internal.ws.resources.ServerMessages; 46 import com.sun.xml.internal.ws.resources.ServerMessages;
46 import com.sun.xml.internal.ws.spi.db.BindingContext; 47 import com.sun.xml.internal.ws.spi.db.BindingContext;
47 import com.sun.xml.internal.ws.spi.db.BindingHelper; 48 import com.sun.xml.internal.ws.spi.db.BindingHelper;
48 import com.sun.xml.internal.ws.spi.db.TypeInfo; 49 import com.sun.xml.internal.ws.spi.db.TypeInfo;
49 import com.sun.xml.internal.ws.spi.db.WrapperComposite; 50 import com.sun.xml.internal.ws.spi.db.WrapperComposite;
50 import com.sun.xml.internal.ws.util.localization.Localizable; 51
51 import com.sun.xml.internal.org.jvnet.ws.databinding.DatabindingMode; 52 import static com.sun.xml.internal.ws.binding.WebServiceFeatureList.getSoapVersion;
52 53
53 import javax.jws.*; 54 import javax.jws.*;
54 import javax.jws.WebParam.Mode; 55 import javax.jws.WebParam.Mode;
55 import javax.jws.soap.SOAPBinding; 56 import javax.jws.soap.SOAPBinding;
56 import javax.jws.soap.SOAPBinding.Style; 57 import javax.jws.soap.SOAPBinding.Style;
115 public static final String PORT = "Port"; 116 public static final String PORT = "Port";
116 public static final Class HOLDER_CLASS = Holder.class; 117 public static final Class HOLDER_CLASS = Holder.class;
117 public static final Class<RemoteException> REMOTE_EXCEPTION_CLASS = RemoteException.class; 118 public static final Class<RemoteException> REMOTE_EXCEPTION_CLASS = RemoteException.class;
118 public static final Class<RuntimeException> RUNTIME_EXCEPTION_CLASS = RuntimeException.class; 119 public static final Class<RuntimeException> RUNTIME_EXCEPTION_CLASS = RuntimeException.class;
119 public static final Class<Exception> EXCEPTION_CLASS = Exception.class; 120 public static final Class<Exception> EXCEPTION_CLASS = Exception.class;
121 public static final String DecapitalizeExceptionBeanProperties = "com.sun.xml.internal.ws.api.model.DecapitalizeExceptionBeanProperties";
122 public static final String SuppressDocLitWrapperGeneration = "com.sun.xml.internal.ws.api.model.SuppressDocLitWrapperGeneration";
123 public static final String DocWrappeeNamespapceQualified = "com.sun.xml.internal.ws.api.model.DocWrappeeNamespapceQualified";
120 124
121 /*public RuntimeModeler(@NotNull Class portClass, @NotNull QName serviceName, @NotNull BindingID bindingId, @NotNull WebServiceFeature... features) { 125 /*public RuntimeModeler(@NotNull Class portClass, @NotNull QName serviceName, @NotNull BindingID bindingId, @NotNull WebServiceFeature... features) {
122 this(portClass, serviceName, null, bindingId, features); 126 this(portClass, serviceName, null, bindingId, features);
123 }*/ 127 }*/
124 128
149 this.classLoader = config.getClassLoader(); 153 this.classLoader = config.getClassLoader();
150 this.portName = config.getMappingInfo().getPortName(); 154 this.portName = config.getMappingInfo().getPortName();
151 this.config = config; 155 this.config = config;
152 this.wsBinding = config.getWSBinding(); 156 this.wsBinding = config.getWSBinding();
153 metadataReader = config.getMetadataReader(); 157 metadataReader = config.getMetadataReader();
158 targetNamespace = config.getMappingInfo().getTargetNamespace();
154 if (metadataReader == null) metadataReader = new ReflectAnnotationReader(); 159 if (metadataReader == null) metadataReader = new ReflectAnnotationReader();
155 if (wsBinding != null) { 160 if (wsBinding != null) {
156 this.bindingId = wsBinding.getBindingId(); 161 this.bindingId = wsBinding.getBindingId();
157 if (config.getFeatures() != null) wsBinding.getFeatures().mergeFeatures(config.getFeatures(), false); 162 if (config.getFeatures() != null) wsBinding.getFeatures().mergeFeatures(config.getFeatures(), false);
158 if (binding != null) wsBinding.getFeatures().mergeFeatures(binding.getFeatures(), false); 163 if (binding != null) wsBinding.getFeatures().mergeFeatures(binding.getFeatures(), false);
159 this.features = WebServiceFeatureList.toList(wsBinding.getFeatures()); 164 this.features = WebServiceFeatureList.toList(wsBinding.getFeatures());
160 } else { 165 } else {
161 this.bindingId = config.getMappingInfo().getBindingID(); 166 this.bindingId = config.getMappingInfo().getBindingID();
167 this.features = WebServiceFeatureList.toList(config.getFeatures());
162 if (binding != null) bindingId = binding.getBinding().getBindingId(); 168 if (binding != null) bindingId = binding.getBinding().getBindingId();
163 if (bindingId == null) bindingId = getDefaultBindingID(); 169 if (bindingId == null) bindingId = getDefaultBindingID();
164 this.features = WebServiceFeatureList.toList(config.getFeatures());
165 if (!features.contains(MTOMFeature.class)) { 170 if (!features.contains(MTOMFeature.class)) {
166 MTOM mtomAn = getAnnotation(portClass, MTOM.class); 171 MTOM mtomAn = getAnnotation(portClass, MTOM.class);
167 if (mtomAn != null) features.add(WebServiceFeatureList.getFeature(mtomAn)); 172 if (mtomAn != null) features.add(WebServiceFeatureList.getFeature(mtomAn));
168 } 173 }
174 if (!features.contains(com.oracle.webservices.internal.api.EnvelopeStyleFeature.class)) {
175 com.oracle.webservices.internal.api.EnvelopeStyle es = getAnnotation(portClass, com.oracle.webservices.internal.api.EnvelopeStyle.class);
176 if (es != null) features.add(WebServiceFeatureList.getFeature(es));
177 }
169 this.wsBinding = bindingId.createBinding(features); 178 this.wsBinding = bindingId.createBinding(features);
170 } 179 }
171 } 180 }
172 181
173 private BindingID getDefaultBindingID() { 182 private BindingID getDefaultBindingID() {
174 BindingType bt = getAnnotation(portClass, BindingType.class); 183 BindingType bt = getAnnotation(portClass, BindingType.class);
175 String id = (bt != null) ? bt.value() : javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING; 184 if (bt != null) return BindingID.parse(bt.value());
176 return BindingID.parse(id); 185 SOAPVersion ver = getSoapVersion(features);
186 boolean mtomEnabled = features.isEnabled(MTOMFeature.class);
187 if (SOAPVersion.SOAP_12.equals(ver)) {
188 return (mtomEnabled) ? BindingID.SOAP12_HTTP_MTOM : BindingID.SOAP12_HTTP;
189 } else {
190 return (mtomEnabled) ? BindingID.SOAP11_HTTP_MTOM : BindingID.SOAP11_HTTP;
191 }
177 } 192 }
178 193
179 /** 194 /**
180 * sets the classloader to be used when loading classes by the <code>RuntimeModeler</code>. 195 * sets the classloader to be used when loading classes by the <code>RuntimeModeler</code>.
181 * @param classLoader ClassLoader used to load classes 196 * @param classLoader ClassLoader used to load classes
293 // if (!portName.getNamespaceURI().equals(serviceName.getNamespaceURI())) { 308 // if (!portName.getNamespaceURI().equals(serviceName.getNamespaceURI())) {
294 // throw new RuntimeModelerException("runtime.modeler.portname.servicename.namespace.mismatch", 309 // throw new RuntimeModelerException("runtime.modeler.portname.servicename.namespace.mismatch",
295 // serviceName, portName); 310 // serviceName, portName);
296 // } 311 // }
297 312
298 if (portName == null) portName = getPortName(portClass, serviceName.getNamespaceURI(), metadataReader); 313 if (portName == null) portName = getPortName(portClass, metadataReader, serviceName.getNamespaceURI());
299 model.setPortName(portName); 314 model.setPortName(portName);
300 315
301 // Check if databinding is overridden in annotation. 316 // Check if databinding is overridden in annotation.
302 DatabindingMode dbm = getAnnotation(portClass, DatabindingMode.class); 317 com.oracle.webservices.internal.api.databinding.DatabindingMode dbm2 = getAnnotation(portClass, com.oracle.webservices.internal.api.databinding.DatabindingMode.class);
303 if (dbm != null) model.databindingInfo.setDatabindingMode(dbm.value()); 318 if (dbm2 != null) model.databindingInfo.setDatabindingMode(dbm2.value());
304 319
305 processClass(seiClass); 320 processClass(seiClass);
306 if (model.getJavaMethods().size() == 0) 321 if (model.getJavaMethods().size() == 0)
307 throw new RuntimeModelerException("runtime.modeler.no.operations", 322 throw new RuntimeModelerException("runtime.modeler.no.operations",
308 portClass.getName()); 323 portClass.getName());
343 } catch (ClassNotFoundException e) { 358 } catch (ClassNotFoundException e) {
344 throw new RuntimeModelerException(errorMessage); 359 throw new RuntimeModelerException(errorMessage);
345 } 360 }
346 } 361 }
347 362
363 private boolean noWrapperGen() {
364 Object o = config.properties().get(SuppressDocLitWrapperGeneration);
365 return (o!= null && o instanceof Boolean) ? ((Boolean) o) : false;
366 }
367
348 private Class getRequestWrapperClass(String className, Method method, QName reqElemName) { 368 private Class getRequestWrapperClass(String className, Method method, QName reqElemName) {
349 ClassLoader loader = (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader; 369 ClassLoader loader = (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader;
350 try { 370 try {
351 return loader.loadClass(className); 371 return loader.loadClass(className);
352 } catch (ClassNotFoundException e) { 372 } catch (ClassNotFoundException e) {
373 if (noWrapperGen()) return WrapperComposite.class;
353 logger.fine("Dynamically creating request wrapper Class " + className); 374 logger.fine("Dynamically creating request wrapper Class " + className);
354 return WrapperBeanGenerator.createRequestWrapperBean(className, method, reqElemName, loader); 375 return WrapperBeanGenerator.createRequestWrapperBean(className, method, reqElemName, loader);
355 } 376 }
356 } 377 }
357 378
358 private Class getResponseWrapperClass(String className, Method method, QName resElemName) { 379 private Class getResponseWrapperClass(String className, Method method, QName resElemName) {
359 ClassLoader loader = (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader; 380 ClassLoader loader = (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader;
360 try { 381 try {
361 return loader.loadClass(className); 382 return loader.loadClass(className);
362 } catch (ClassNotFoundException e) { 383 } catch (ClassNotFoundException e) {
384 if (noWrapperGen()) return WrapperComposite.class;
363 logger.fine("Dynamically creating response wrapper bean Class " + className); 385 logger.fine("Dynamically creating response wrapper bean Class " + className);
364 return WrapperBeanGenerator.createResponseWrapperBean(className, method, resElemName, loader); 386 return WrapperBeanGenerator.createResponseWrapperBean(className, method, resElemName, loader);
365 } 387 }
366 } 388 }
367 389
368 390
369 private Class getExceptionBeanClass(String className, Class exception, String name, String namespace) { 391 private Class getExceptionBeanClass(String className, Class exception, String name, String namespace) {
392 boolean decapitalizeExceptionBeanProperties = true;
393 Object o = config.properties().get(DecapitalizeExceptionBeanProperties);
394 if (o!= null && o instanceof Boolean) decapitalizeExceptionBeanProperties = (Boolean) o;
370 ClassLoader loader = (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader; 395 ClassLoader loader = (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader;
371 try { 396 try {
372 return loader.loadClass(className); 397 return loader.loadClass(className);
373 } catch (ClassNotFoundException e) { 398 } catch (ClassNotFoundException e) {
374 logger.fine("Dynamically creating exception bean Class " + className); 399 logger.fine("Dynamically creating exception bean Class " + className);
375 return WrapperBeanGenerator.createExceptionBean(className, exception, targetNamespace, name, namespace, loader); 400 return WrapperBeanGenerator.createExceptionBean(className, exception, targetNamespace, name, namespace, loader, decapitalizeExceptionBeanProperties);
376 } 401 }
377 } 402 }
378 403
379 protected void determineWebMethodUse(Class clazz) { 404 protected void determineWebMethodUse(Class clazz) {
380 if (clazz == null) 405 if (clazz == null)
415 // model.setTargetNamespace(targetNamespace); 440 // model.setTargetNamespace(targetNamespace);
416 // QName portTypeName = new QName(targetNamespace, portTypeLocalName); 441 // QName portTypeName = new QName(targetNamespace, portTypeLocalName);
417 targetNamespace = portTypeName.getNamespaceURI(); 442 targetNamespace = portTypeName.getNamespaceURI();
418 model.setPortTypeName(portTypeName); 443 model.setPortTypeName(portTypeName);
419 model.setTargetNamespace(targetNamespace); 444 model.setTargetNamespace(targetNamespace);
445 model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
420 model.setWSDLLocation(webService.wsdlLocation()); 446 model.setWSDLLocation(webService.wsdlLocation());
421 447
422 SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class); 448 SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
423 if (soapBinding != null) { 449 if (soapBinding != null) {
424 if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) { 450 if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
578 /** 604 /**
579 * creates the runtime model for a method on the <code>portClass</code> 605 * creates the runtime model for a method on the <code>portClass</code>
580 * @param method the method to model 606 * @param method the method to model
581 */ 607 */
582 private void processMethod(Method method) { 608 private void processMethod(Method method) {
583 int mods = method.getModifiers(); 609 // int mods = method.getModifiers();
584 WebMethod webMethod = getAnnotation(method, WebMethod.class); 610 WebMethod webMethod = getAnnotation(method, WebMethod.class);
611 if (webMethod != null && webMethod.exclude()) return;
585 /* 612 /*
586 validations are already done 613 validations are already done
587 614
588 if (!Modifier.isPublic(mods) || Modifier.isStatic(mods)) { 615 if (!Modifier.isPublic(mods) || Modifier.isStatic(mods)) {
589 if(webMethod != null) { 616 if(webMethod != null) {
731 boolean methodHasHeaderParams = false; 758 boolean methodHasHeaderParams = false;
732 boolean isOneway = getAnnotation(method, Oneway.class)!= null; 759 boolean isOneway = getAnnotation(method, Oneway.class)!= null;
733 RequestWrapper reqWrapper = getAnnotation(method,RequestWrapper.class); 760 RequestWrapper reqWrapper = getAnnotation(method,RequestWrapper.class);
734 ResponseWrapper resWrapper = getAnnotation(method,ResponseWrapper.class); 761 ResponseWrapper resWrapper = getAnnotation(method,ResponseWrapper.class);
735 String beanPackage = packageName + PD_JAXWS_PACKAGE_PD; 762 String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
736 if (packageName == null || (packageName != null && packageName.length() == 0)) 763 if (packageName == null || packageName.length() == 0) {
737 beanPackage = JAXWS_PACKAGE_PD; 764 beanPackage = JAXWS_PACKAGE_PD;
765 }
738 String requestClassName; 766 String requestClassName;
739 if(reqWrapper != null && reqWrapper.className().length()>0){ 767 if(reqWrapper != null && reqWrapper.className().length()>0){
740 requestClassName = reqWrapper.className(); 768 requestClassName = reqWrapper.className();
741 }else{ 769 }else{
742 requestClassName = beanPackage + capitalize(method.getName()); 770 requestClassName = beanPackage + capitalize(method.getName());
832 860
833 if(javaMethod.isAsync()){ 861 if(javaMethod.isAsync()){
834 returnType = getAsyncReturnType(method, returnType); 862 returnType = getAsyncReturnType(method, returnType);
835 resultQName = new QName(RETURN); 863 resultQName = new QName(RETURN);
836 } 864 }
837 865 resultQName = qualifyWrappeeIfNeeded(resultQName, resNamespace);
838 if (!isOneway && (returnType != null) && (!returnType.getName().equals("void"))) { 866 if (!isOneway && (returnType != null) && (!returnType.getName().equals("void"))) {
839 Annotation[] rann = getAnnotations(method); 867 Annotation[] rann = getAnnotations(method);
840 if (resultQName.getLocalPart() != null) { 868 if (resultQName.getLocalPart() != null) {
841 TypeInfo rTypeReference = new TypeInfo(resultQName, returnType, rann); 869 TypeInfo rTypeReference = new TypeInfo(resultQName, returnType, rann);
842 metadataReader.getProperties(rTypeReference.properties(), method); 870 metadataReader.getProperties(rTypeReference.properties(), method);
871 rTypeReference.setGenericType(method.getGenericReturnType());
843 ParameterImpl returnParameter = new ParameterImpl(javaMethod, rTypeReference, Mode.OUT, -1); 872 ParameterImpl returnParameter = new ParameterImpl(javaMethod, rTypeReference, Mode.OUT, -1);
844 if (isResultHeader) { 873 if (isResultHeader) {
845 returnParameter.setBinding(ParameterBinding.HEADER); 874 returnParameter.setBinding(ParameterBinding.HEADER);
846 javaMethod.addParameter(returnParameter); 875 javaMethod.addParameter(returnParameter);
847 } else { 876 } else {
899 } 928 }
900 paramMode = webParam.mode(); 929 paramMode = webParam.mode();
901 if (isHolder && paramMode == Mode.IN) 930 if (isHolder && paramMode == Mode.IN)
902 paramMode = Mode.INOUT; 931 paramMode = Mode.INOUT;
903 } 932 }
933 paramQName = qualifyWrappeeIfNeeded(paramQName, reqNamespace);
904 typeRef = 934 typeRef =
905 new TypeInfo(paramQName, clazzType, pannotations[pos]); 935 new TypeInfo(paramQName, clazzType, pannotations[pos]);
906 metadataReader.getProperties(typeRef.properties(), method, pos); 936 metadataReader.getProperties(typeRef.properties(), method, pos);
937 typeRef.setGenericType(genericParameterTypes[pos]);
907 ParameterImpl param = new ParameterImpl(javaMethod, typeRef, paramMode, pos++); 938 ParameterImpl param = new ParameterImpl(javaMethod, typeRef, paramMode, pos++);
908 939
909 if (isHeader) { 940 if (isHeader) {
910 param.setBinding(ParameterBinding.HEADER); 941 param.setBinding(ParameterBinding.HEADER);
911 javaMethod.addParameter(param); 942 javaMethod.addParameter(param);
934 if(responseWrapper != null) 965 if(responseWrapper != null)
935 responseWrapper.setPartName(resPartName); 966 responseWrapper.setPartName(resPartName);
936 processExceptions(javaMethod, method); 967 processExceptions(javaMethod, method);
937 } 968 }
938 969
970 private QName qualifyWrappeeIfNeeded(QName resultQName, String ns) {
971 Object o = config.properties().get(DocWrappeeNamespapceQualified);
972 boolean qualified = (o!= null && o instanceof Boolean) ? ((Boolean) o) : false;
973 if (qualified) {
974 if (resultQName.getNamespaceURI() == null || "".equals(resultQName.getNamespaceURI())) {
975 return new QName(ns, resultQName.getLocalPart());
976 }
977 }
978 return resultQName;
979 }
939 980
940 /** 981 /**
941 * models a rpc/literal method 982 * models a rpc/literal method
942 * @param javaMethod the runtime model <code>JavaMethod</code> instance being created 983 * @param javaMethod the runtime model <code>JavaMethod</code> instance being created
943 * @param methodName the name of the <code>method</code> being modeled. 984 * @param methodName the name of the <code>method</code> being modeled.
1343 break; 1384 break;
1344 } 1385 }
1345 } 1386 }
1346 1387
1347 QName requestQName = new QName(requestNamespace, paramName); 1388 QName requestQName = new QName(requestNamespace, paramName);
1348 if (!isHeader) javaMethod.setRequestPayloadName(requestQName); 1389 if (!isHeader && paramMode != Mode.OUT) javaMethod.setRequestPayloadName(requestQName);
1349 //doclit/wrapped 1390 //doclit/wrapped
1350 TypeInfo typeRef = //operationName with upper 1 char 1391 TypeInfo typeRef = //operationName with upper 1 char
1351 new TypeInfo(requestQName, clazzType, 1392 new TypeInfo(requestQName, clazzType,
1352 pannotations[pos]); 1393 pannotations[pos]);
1353 metadataReader.getProperties(typeRef.properties(), method, pos); 1394 metadataReader.getProperties(typeRef.properties(), method, pos);
1490 * @param implClass the implementation class 1531 * @param implClass the implementation class
1491 * @param targetNamespace Namespace URI for service name 1532 * @param targetNamespace Namespace URI for service name
1492 * @return the <code>wsdl:portName</code> for the <code>implClass</code> 1533 * @return the <code>wsdl:portName</code> for the <code>implClass</code>
1493 */ 1534 */
1494 public static QName getPortName(Class<?> implClass, String targetNamespace) { 1535 public static QName getPortName(Class<?> implClass, String targetNamespace) {
1495 return getPortName(implClass, targetNamespace, null); 1536 return getPortName(implClass, null, targetNamespace);
1496 } 1537 }
1497 1538
1498 public static QName getPortName(Class<?> implClass, String targetNamespace, boolean isStandard) { 1539 public static QName getPortName(Class<?> implClass, String targetNamespace, boolean isStandard) {
1499 return getPortName(implClass, targetNamespace, null, isStandard); 1540 return getPortName(implClass, null, targetNamespace, isStandard);
1500 } 1541 }
1501 1542
1502 public static QName getPortName(Class<?> implClass, String targetNamespace, MetadataReader reader) { 1543 public static QName getPortName(Class<?> implClass, MetadataReader reader, String targetNamespace) {
1503 return getPortName(implClass, targetNamespace, reader, true); 1544 return getPortName(implClass, reader, targetNamespace, true);
1504 } 1545 }
1505 1546
1506 public static QName getPortName(Class<?> implClass, String targetNamespace, MetadataReader reader, boolean isStandard) { 1547 public static QName getPortName(Class<?> implClass, MetadataReader reader, String targetNamespace, boolean isStandard) {
1507 WebService webService = getAnnotation(WebService.class, implClass, reader); 1548 WebService webService = getAnnotation(WebService.class, implClass, reader);
1508 if (isStandard && webService == null) { 1549 if (isStandard && webService == null) {
1509 throw new RuntimeModelerException("runtime.modeler.no.webservice.annotation", 1550 throw new RuntimeModelerException("runtime.modeler.no.webservice.annotation",
1510 implClass.getCanonicalName()); 1551 implClass.getCanonicalName());
1511 } 1552 }
1524 } else { 1565 } else {
1525 String packageName = null; 1566 String packageName = null;
1526 if (implClass.getPackage() != null) { 1567 if (implClass.getPackage() != null) {
1527 packageName = implClass.getPackage().getName(); 1568 packageName = implClass.getPackage().getName();
1528 } 1569 }
1529 targetNamespace = getNamespace(packageName); 1570 if (packageName != null) {
1571 targetNamespace = getNamespace(packageName);
1572 }
1530 if (targetNamespace == null) { 1573 if (targetNamespace == null) {
1531 throw new RuntimeModelerException("runtime.modeler.no.package", 1574 throw new RuntimeModelerException("runtime.modeler.no.package",
1532 implClass.getName()); 1575 implClass.getName());
1533 } 1576 }
1534 } 1577 }
1548 * @return <code>wsdl:portType@name</code>, null if it could not find the annotated class. 1591 * @return <code>wsdl:portType@name</code>, null if it could not find the annotated class.
1549 */ 1592 */
1550 public static QName getPortTypeName(Class<?> implOrSeiClass){ 1593 public static QName getPortTypeName(Class<?> implOrSeiClass){
1551 return getPortTypeName(implOrSeiClass, null, null); 1594 return getPortTypeName(implOrSeiClass, null, null);
1552 } 1595 }
1596
1597 public static QName getPortTypeName(Class<?> implOrSeiClass, MetadataReader metadataReader){
1598 return getPortTypeName(implOrSeiClass, null, metadataReader);
1599 }
1600
1553 public static QName getPortTypeName(Class<?> implOrSeiClass, String tns, MetadataReader reader){ 1601 public static QName getPortTypeName(Class<?> implOrSeiClass, String tns, MetadataReader reader){
1554 assert(implOrSeiClass != null); 1602 assert(implOrSeiClass != null);
1555 WebService webService = getAnnotation(WebService.class, implOrSeiClass, reader); 1603 WebService webService = getAnnotation(WebService.class, implOrSeiClass, reader);
1556 Class<?> clazz = implOrSeiClass; 1604 Class<?> clazz = implOrSeiClass;
1557 if (webService == null) 1605 if (webService == null)
1564 try { 1612 try {
1565 clazz = Thread.currentThread().getContextClassLoader().loadClass(epi); 1613 clazz = Thread.currentThread().getContextClassLoader().loadClass(epi);
1566 } catch (ClassNotFoundException e) { 1614 } catch (ClassNotFoundException e) {
1567 throw new RuntimeModelerException("runtime.modeler.class.not.found", epi); 1615 throw new RuntimeModelerException("runtime.modeler.class.not.found", epi);
1568 } 1616 }
1569 if (!clazz.isAnnotationPresent(javax.jws.WebService.class)) { 1617 WebService ws = getAnnotation(WebService.class, clazz, reader);
1618 if (ws == null) {
1570 throw new RuntimeModelerException("runtime.modeler.endpoint.interface.no.webservice", 1619 throw new RuntimeModelerException("runtime.modeler.endpoint.interface.no.webservice",
1571 webService.endpointInterface()); 1620 webService.endpointInterface());
1572 } 1621 }
1573 } 1622 }
1574 } 1623 }
1576 webService = getAnnotation(WebService.class, clazz, reader); 1625 webService = getAnnotation(WebService.class, clazz, reader);
1577 String name = webService.name(); 1626 String name = webService.name();
1578 if(name.length() == 0){ 1627 if(name.length() == 0){
1579 name = clazz.getSimpleName(); 1628 name = clazz.getSimpleName();
1580 } 1629 }
1581 tns = webService.targetNamespace();
1582 if (tns == null || "".equals(tns.trim())) tns = webService.targetNamespace(); 1630 if (tns == null || "".equals(tns.trim())) tns = webService.targetNamespace();
1583 if (tns.length() == 0) 1631 if (tns.length() == 0)
1584 tns = getNamespace(clazz.getPackage().getName()); 1632 tns = getNamespace(clazz.getPackage().getName());
1585 if (tns == null) { 1633 if (tns == null) {
1586 throw new RuntimeModelerException("runtime.modeler.no.package", clazz.getName()); 1634 throw new RuntimeModelerException("runtime.modeler.no.package", clazz.getName());

mercurial