"annotation not allowed on this element."), annInfo);
}
ServiceReferenceContainer[] containers = null;
ServiceReferenceDescriptor aRef =null;
if (annCtx instanceof ServiceReferenceContainerContext) {
containers = ((ServiceReferenceContainerContext) annCtx).getServiceRefContainers();
}
if (containers==null || containers.length==0) {
annInfo.getProcessingContext().getErrorHandler().warning(
new AnnotationProcessorException(
localStrings.getLocalString(
"enterprise.deployment.annotation.handlers.invalidannotationforthisclass",
"Illegal annotation symbol for this class will be ignored"),
annInfo));
return HandlerProcessingResultImpl.getDefaultResult(getAnnotationType(), ResultType.PROCESSED);
}
// now process the annotation for all the containers.
for (ServiceReferenceContainer container : containers) {
try {
aRef =container.getServiceReferenceByName(serviceRefName);
} catch(Throwable t) {}; // ignore
if (aRef==null) {
// time to create it...
aRef = new ServiceReferenceDescriptor();
aRef.setName(serviceRefName);
container.addServiceReferenceDescriptor(aRef);
}
// Store mapped name that is specified
if(aRef.getMappedName() == null) {
if(annotation.mappedName() != null && annotation.mappedName().length() != 0) {
aRef.setMappedName(annotation.mappedName());
}
}
aRef.setInjectResourceType("javax.jws.WebServiceRef");
if (!annInfo.getElementType().equals(ElementType.TYPE)) {
InjectionTarget target = new InjectionTarget();
if (annInfo.getElementType().equals(ElementType.FIELD)) {
// this is a field injection
Field annotatedField = (Field) annElem;
target.setFieldName(annotatedField.getName());
target.setClassName(annotatedField.getDeclaringClass().getName());
} else {
if (annInfo.getElementType().equals(ElementType.METHOD)) {
// this is a method injection
Method annotatedMethod = (Method) annElem;
target.setMethodName(annotatedMethod.getName());
target.setClassName(annotatedMethod.getDeclaringClass().getName());
}
}
aRef.addInjectionTarget(target);
}
if (!Object.class.equals(annotation.value())) {
// a value was provided, which should be the Service
// interface, the requested injection is therefore on the
// port.
if (aRef.getServiceInterface()==null) {
aRef.setServiceInterface(annotation.value().getName());
}
if (aRef.getPortInfoBySEI(annotatedType.getName())==null) {
ServiceRefPortInfo portInfo = new ServiceRefPortInfo();
portInfo.setServiceEndpointInterface(annotatedType.getName());
aRef.addPortInfo(portInfo);
}
// set the port type requested for injection
if (aRef.getInjectionTargetType()==null) {
aRef.setInjectionTargetType(annotatedType.getName());
}
}
// watch the override order
if(aRef.getName()==null || aRef.getName().length()==0) {
aRef.setName(annotation.name());
}
if (aRef.getWsdlFileUri()==null) {
if (annotation.wsdlLocation()==null || annotation.wsdlLocation().length()!=0) {
aRef.setWsdlFileUri(annotation.wsdlLocation());
}
}
// Read the WebServiceClient annotation for the service name space uri and wsdl (if required)
WebServiceClient wsclientAnn;
if (Object.class.equals(annotation.value())) {
wsclientAnn = (WebServiceClient) annotatedType.getAnnotation(WebServiceClient.class);
} else {
wsclientAnn = (WebServiceClient) annotation.value().getAnnotation(WebServiceClient.class);
}
if (wsclientAnn==null) {
throw new AnnotationProcessorException(
localStrings.getLocalString(
"enterprise.deployment.annotation.handlers.classnotannotated",
"Class must be annotated with a {1} annotation\n symbol : {1}\n location: {0}",
new Object[] { annotatedType.toString(), WebServiceClient.class.toString() }));
}
// If wsdl file was not specified in a descriptor and not in the annotation, get it from WebServiceClient
// annotation
if (aRef.getWsdlFileUri()==null) {
aRef.setWsdlFileUri(wsclientAnn.wsdlLocation());
}
// Set service name space URI and service local part
if(aRef.getServiceName() == null) {
aRef.setServiceNamespaceUri(wsclientAnn.targetNamespace());
aRef.setServiceLocalPart(wsclientAnn.name());
}
if (aRef.getServiceInterface()==null) {
aRef.setServiceInterface(annotatedType.getName());
}
}
// Now force a HandlerChain annotation processing
// This is to take care of the case where the client class does not
// have @HandlerChain but the SEI has one specified through JAXWS customization