Search in sources :

Example 1 with Activation

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();
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) InboundResourceAdapter(com.sun.enterprise.deployment.InboundResourceAdapter) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext) MessageListener(com.sun.enterprise.deployment.MessageListener) Activation(javax.resource.spi.Activation)

Aggregations

ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)1 InboundResourceAdapter (com.sun.enterprise.deployment.InboundResourceAdapter)1 MessageListener (com.sun.enterprise.deployment.MessageListener)1 RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)1 Activation (javax.resource.spi.Activation)1