TUSCANY-3641 - Support @WebServiceProvider/wsdlLocation annotation

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@984314 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
slaws 2010-08-11 07:35:04 +00:00
commit 747aa47ae5

View file

@ -80,17 +80,18 @@ public class JAXWSProcessor extends BaseJavaClassVisitor {
// Process @WebService annotation - POJO_8029, POJO_8030 // Process @WebService annotation - POJO_8029, POJO_8030
WebService webServiceAnnotation = clazz.getAnnotation(WebService.class); WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
org.oasisopen.sca.annotation.Service serviceAnnotation = clazz.getAnnotation(org.oasisopen.sca.annotation.Service.class); org.oasisopen.sca.annotation.Service serviceAnnotation = clazz.getAnnotation(org.oasisopen.sca.annotation.Service.class);
String localName = clazz.getSimpleName();
Class<?> interfaze = clazz;
if (webServiceAnnotation != null && if (webServiceAnnotation != null &&
serviceAnnotation == null) { serviceAnnotation == null) {
localName = getValue(webServiceAnnotation.name(), localName); String serviceName = clazz.getSimpleName();
String serviceInterfaceName = webServiceAnnotation.endpointInterface(); serviceName = getValue(webServiceAnnotation.name(), serviceName);
String serviceInterfaceClassName = webServiceAnnotation.endpointInterface();
String wsdlLocation = webServiceAnnotation.wsdlLocation(); String wsdlLocation = webServiceAnnotation.wsdlLocation();
try { try {
createService(type, clazz, localName, serviceInterfaceName, wsdlLocation); createService(type, clazz, serviceName, serviceInterfaceClassName, wsdlLocation, false);
} catch (InvalidInterfaceException e) { } catch (InvalidInterfaceException e) {
throw new IntrospectionException(e); throw new IntrospectionException(e);
} }
@ -98,15 +99,26 @@ public class JAXWSProcessor extends BaseJavaClassVisitor {
// Process @WebServiceProvider annotation - JCA_11015, POJO_8034 // Process @WebServiceProvider annotation - JCA_11015, POJO_8034
WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class); WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
if (webServiceProviderAnnotation != null && if (webServiceProviderAnnotation != null) {
serviceAnnotation == null) { // if the implmentation already has a service set, use it's name
localName = clazz.getSimpleName(); // and the new service, which uses the implementation as an interface,
localName = getValue(webServiceProviderAnnotation.serviceName(), localName); // will be replaced
String serviceName = clazz.getSimpleName();
if (type.getServices().size() > 0){
serviceName = ((Service)type.getServices().get(0)).getName();
}
// the annotation may specify a service name
serviceName = getValue(webServiceProviderAnnotation.serviceName(), serviceName);
String wsdlLocation = webServiceProviderAnnotation.wsdlLocation();
// Make sure that there is a service with an interface // Make sure that there is a service with an interface
// based on the implementation class // based on the implementation class and have it replace
// any service with the same name
try { try {
createService(type, clazz, localName, null, null); createService(type, clazz, serviceName, null, wsdlLocation, true);
} catch (InvalidInterfaceException e) { } catch (InvalidInterfaceException e) {
throw new IntrospectionException(e); throw new IntrospectionException(e);
} }
@ -118,6 +130,7 @@ public class JAXWSProcessor extends BaseJavaClassVisitor {
} }
// Process @WebParam and @WebResult annotations - POJO_8031, POJO_8032 // Process @WebParam and @WebResult annotations - POJO_8031, POJO_8032
Class<?> interfaze = clazz;
Method[] implMethods = interfaze.getDeclaredMethods(); Method[] implMethods = interfaze.getDeclaredMethods();
for ( Service service : type.getServices() ) { for ( Service service : type.getServices() ) {
JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getInterface(); JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getInterface();
@ -178,7 +191,7 @@ public class JAXWSProcessor extends BaseJavaClassVisitor {
return "".equals(value) ? defaultValue : value; return "".equals(value) ? defaultValue : value;
} }
public Service createService(JavaImplementation type, Class<?> clazz, String serviceName, String javaInterfaceName, String wsdlFileName) throws InvalidInterfaceException, IntrospectionException { public Service createService(JavaImplementation type, Class<?> clazz, String serviceName, String javaInterfaceName, String wsdlFileName, boolean replace) throws InvalidInterfaceException, IntrospectionException {
Service service = assemblyFactory.createService(); Service service = assemblyFactory.createService();
if (serviceName != null) { if (serviceName != null) {
@ -221,15 +234,21 @@ public class JAXWSProcessor extends BaseJavaClassVisitor {
} }
// add the service model into the implementation type // add the service model into the implementation type
boolean serviceAlreadyPresent = false; Service serviceAlreadyPresent = null;
for (Service typeService : type.getServices()){ for (Service typeService : type.getServices()){
if (typeService.getName().equals(service.getName())){ if (typeService.getName().equals(service.getName())){
serviceAlreadyPresent = true; serviceAlreadyPresent = typeService;
break; break;
} }
} }
if (!serviceAlreadyPresent){
if (replace == true){
type.getServices().remove(serviceAlreadyPresent);
type.getServices().add(service); type.getServices().add(service);
} else {
if (serviceAlreadyPresent == null){
type.getServices().add(service);
}
} }
return service; return service;