//------------------------------------------------------------------------------------------
// 1. <service-ref>
//------------------------------------------------------------------------------------------
ServiceRef serviceRef = null;
Collection<ServiceRef> serviceRefs = annotatedApp.getServiceRef();
for (ServiceRef currServiceRef : serviceRefs) {
if (currServiceRef.getServiceRefName().trim().equals(webServiceRefName)) {
serviceRef = currServiceRef;
break;
}
}
if (serviceRef == null) {
// Doesn't exist in deployment descriptor -- add new
serviceRef = new ServiceRef();
// ------------------------------------------------------------------------------
// <service-ref> required elements:
// ------------------------------------------------------------------------------
// service-ref-name
serviceRef.setServiceRefName(webServiceRefName);
// service-ref-interface
if (webServiceRefValue == javax.xml.ws.Service.class) {
serviceRef.setServiceInterface(webServiceRefType.getName());
} else {
serviceRef.setServiceInterface(webServiceRefValue.getName());
}
annotatedApp.getServiceRef().add(serviceRef);
}
//------------------------------------------------------------------------------
// <service-ref> optional elements:
//------------------------------------------------------------------------------
// Look-up
if (serviceRef.getLookupName() == null && !annotation.lookup().trim().isEmpty()) {
serviceRef.setLookupName(annotation.lookup().trim());
}
// service-ref-type
if (serviceRef.getServiceRefType() == null && !webServiceRefType.equals(Object.class)) {
serviceRef.setServiceRefType(webServiceRefType.getName());
}
// mapped-name
if (serviceRef.getMappedName() == null && annotation.mappedName().trim().length() > 0) {
serviceRef.setMappedName(annotation.mappedName().trim());
}
// WSDL document location
if (serviceRef.getWsdlFile() == null) {
String wsdlLocation = annotation.wsdlLocation();
if (wsdlLocation == null || wsdlLocation.trim().length() == 0) {
WebServiceClient wsClient = null;
if (javax.xml.ws.Service.class == webServiceRefValue) {
wsClient = (WebServiceClient) webServiceRefType.getAnnotation(WebServiceClient.class);
} else {
wsClient = (WebServiceClient) webServiceRefValue.getAnnotation(WebServiceClient.class);
}
if (wsClient == null) {
wsdlLocation = null;
} else {
wsdlLocation = wsClient.wsdlLocation();
}
}
if (wsdlLocation != null && wsdlLocation.trim().length() > 0) {
serviceRef.setWsdlFile(wsdlLocation);
}
}
// handler-chains
if (serviceRef.getHandlerChains() == null) {
HandlerChain handlerChain = null;
Class annotatedClass = null;
if (method != null) {
handlerChain = method.getAnnotation(HandlerChain.class);
annotatedClass = method.getDeclaringClass();
} else if (field != null) {
handlerChain = field.getAnnotation(HandlerChain.class);
annotatedClass = field.getDeclaringClass();
}
// if not specified on method or field, try to get it from Service class
if (handlerChain == null) {
if (javax.xml.ws.Service.class == webServiceRefValue) {
handlerChain = (HandlerChain) webServiceRefType.getAnnotation(HandlerChain.class);
annotatedClass = webServiceRefType;
} else {
handlerChain = (HandlerChain) webServiceRefValue.getAnnotation(HandlerChain.class);
annotatedClass = webServiceRefValue;
}
}
if (handlerChain != null) {
HandlerChainAnnotationHelper.insertHandlers(serviceRef, handlerChain, annotatedClass);
}
}
if (method != null || field != null) {
serviceRef.getInjectionTarget().add(configureInjectionTarget(method, field));
}
// web service features
Annotation[] candidateAnnotations = null;
if (cls != null) {