}
MTOM mtom = null;
Addressing addressing = null;
RespectBinding respectBinding = null;
// Other annotations like SchemaValidation etc to be passed on to
// ServiceReferenceDescriptor
Map<Class<? extends Annotation>, Annotation> otherAnnotations =
new HashMap<Class<? extends Annotation>, Annotation>();
for (Annotation a : annElem.getAnnotations()) {
if (!(a.annotationType().isAnnotationPresent(
WebServiceFeatureAnnotation.class)))
continue;
if (a instanceof MTOM) {
mtom = (MTOM)a;
} else if (a instanceof Addressing) {
addressing = (Addressing)a;
} else if (a instanceof RespectBinding) {
respectBinding = (RespectBinding)a;
} else {
if (!otherAnnotations.containsKey(a.getClass())) {
otherAnnotations.put(a.getClass(), a);
}
}
}
String serviceRefName = !ok(annotation.name()) ?
defaultServiceRefName : annotation.name();
ServiceReferenceContainer[] containers = null;
if (annCtx instanceof ServiceReferenceContainerContext) {
containers = ((ServiceReferenceContainerContext) annCtx).getServiceRefContainers();
}
if (containers == null || containers.length == 0) {
annInfo.getProcessingContext().getErrorHandler().fine(
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) {
ServiceReferenceDescriptor aRef = null;
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);
}
// merge other annotations
Map<Class<? extends Annotation>, Annotation> oa =
aRef.getOtherAnnotations();
if (oa == null)
aRef.setOtherAnnotations(otherAnnotations);
else {
for (Map.Entry<Class<? extends Annotation>, Annotation> entry :
otherAnnotations.entrySet()) {
if (!oa.containsKey(entry.getKey()))
oa.put(entry.getKey(), entry.getValue());
}
}
// merge wsdlLocation
if (!ok(aRef.getWsdlFileUri()) && ok(annotation.wsdlLocation()))
aRef.setWsdlFileUri(annotation.wsdlLocation());
if (!aRef.hasMtomEnabled() && mtom != null) {
aRef.setMtomEnabled(mtom.enabled());
aRef.setMtomThreshold(mtom.threshold());
}
// check Addressing annotation
if (aRef.getAddressing() == null && addressing != null) {
aRef.setAddressing(new com.sun.enterprise.deployment.Addressing(
addressing.enabled(),
addressing.required(),
addressing.responses().toString()));
}
// check RespectBinding annotation
if (aRef.getRespectBinding() == null && respectBinding != null) {
aRef.setRespectBinding(
new com.sun.enterprise.deployment.RespectBinding(
respectBinding.enabled()));
}
// Store mapped name that is specified
if (!ok(aRef.getMappedName()) && ok(annotation.mappedName()))
aRef.setMappedName(annotation.mappedName());