use of javax.resource.spi.Activation in project Payara by payara.
the class ActivationHandler method processAnnotation.
public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
Activation activation = (Activation) element.getAnnotation();
if (aeHandler instanceof RarBundleContext) {
RarBundleContext rarContext = (RarBundleContext) aeHandler;
ConnectorDescriptor desc = rarContext.getDescriptor();
// process annotation only if message-listeners are provided
if (activation.messageListeners().length > 0) {
// initialize inbound if it was not done already
if (!desc.getInBoundDefined()) {
desc.setInboundResourceAdapter(new InboundResourceAdapter());
}
InboundResourceAdapter ira = desc.getInboundResourceAdapter();
// get the activation-spec implementation class-name
Class c = (Class) element.getAnnotatedElement();
String activationSpecClass = c.getName();
// process all message-listeners, ensure that no duplicate message-listener-types are found
for (Class mlClass : activation.messageListeners()) {
MessageListener ml = new MessageListener();
ml.setActivationSpecClass(activationSpecClass);
ml.setMessageListenerType(mlClass.getName());
if (!ira.hasMessageListenerType(mlClass.getName())) {
ira.addMessageListener(ml);
}
// else {
// ignore the duplicates
// duplicates can be via :
// (i) message listner defined in DD
// (ii) as part of this particular annotation processing,
// already this message-listener-type is defined
// TODO V3 how to handle (ii)
// }
}
}
} else {
getFailureResult(element, "Not a rar bundle context", true);
}
return getDefaultProcessedResult();
}
Aggregations