Search in sources :

Example 6 with RarBundleContext

use of com.sun.enterprise.deployment.annotation.context.RarBundleContext in project Payara by payara.

the class ConnectorAnnotationHandler method processAnnotation.

public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
    AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
    Connector connector = (Connector) element.getAnnotation();
    List<Class<? extends Annotation>> list = new ArrayList<Class<? extends Annotation>>();
    list.add(getAnnotationType());
    if (aeHandler instanceof RarBundleContext) {
        RarBundleContext rarContext = (RarBundleContext) aeHandler;
        ConnectorDescriptor desc = rarContext.getDescriptor();
        Class annotatedClass = (Class) element.getAnnotatedElement();
        if (desc.getResourceAdapterClass().equals("")) {
            desc.addConnectorAnnotation(element);
            return getSuccessfulProcessedResult(list);
        } else if (!isResourceAdapterClass(annotatedClass)) {
            desc.addConnectorAnnotation(element);
            return getSuccessfulProcessedResult(list);
        } else if (!desc.getResourceAdapterClass().equals(annotatedClass.getName())) {
            desc.addConnectorAnnotation(element);
            return getSuccessfulProcessedResult(list);
        } else {
            processDescriptor(annotatedClass, connector, desc);
            desc.setValidConnectorAnnotationProcessed(true);
        }
    } else {
        String logMessage = "Not a rar bundle context";
        return getFailureResult(element, logMessage, true);
    }
    return getSuccessfulProcessedResult(list);
}
Also used : Connector(javax.resource.spi.Connector) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ArrayList(java.util.ArrayList) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext) Annotation(java.lang.annotation.Annotation)

Example 7 with RarBundleContext

use of com.sun.enterprise.deployment.annotation.context.RarBundleContext 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)

Example 8 with RarBundleContext

use of com.sun.enterprise.deployment.annotation.context.RarBundleContext in project Payara by payara.

the class ConnectionDefinitionsHandler method processAnnotation.

public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
    AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
    ConnectionDefinitions connDefns = (ConnectionDefinitions) element.getAnnotation();
    if (aeHandler instanceof RarBundleContext) {
        // TODO V3 what if there is @ConnectionDefiniton as well @ConnectionDefinitions specified on same class ?
        // TODO V3 should we detect & avoid duplicates here ?
        ConnectionDefinition[] definitions = connDefns.value();
        if (definitions != null) {
            for (ConnectionDefinition defn : definitions) {
                ConnectionDefinitionHandler cdh = new ConnectionDefinitionHandler();
                cdh.processAnnotation(element, defn);
            }
        }
    } else {
        getFailureResult(element, "not a rar bundle context", true);
    }
    return getDefaultProcessedResult();
}
Also used : ConnectionDefinition(javax.resource.spi.ConnectionDefinition) ConnectionDefinitions(javax.resource.spi.ConnectionDefinitions) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext)

Example 9 with RarBundleContext

use of com.sun.enterprise.deployment.annotation.context.RarBundleContext in project Payara by payara.

the class AdministeredObjectHandler method processAnnotation.

public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
    AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
    AdministeredObject adminObject = (AdministeredObject) element.getAnnotation();
    if (aeHandler instanceof RarBundleContext) {
        RarBundleContext rarContext = (RarBundleContext) aeHandler;
        ConnectorDescriptor desc = rarContext.getDescriptor();
        Class c = (Class) element.getAnnotatedElement();
        String adminObjectClassName = c.getName();
        Class[] adminObjectInterfaceClasses = adminObject.adminObjectInterfaces();
        // When "adminObjectInterfaces()" is specified, add one admin-object entry per interface
        if (adminObjectInterfaceClasses != null && adminObjectInterfaceClasses.length > 0) {
            for (Class adminObjectInterface : adminObjectInterfaceClasses) {
                processAdminObjectInterface(adminObjectClassName, adminObjectInterface.getName(), desc);
            }
        } else {
            List<Class> interfacesList = deriveAdminObjectInterfacesFromHierarchy(c);
            if (interfacesList.size() == 1) {
                Class intf = interfacesList.get(0);
                String intfName = intf.getName();
                processAdminObjectInterface(adminObjectClassName, intfName, desc);
            } else {
            // TODO V3 this case is, multiple interfaces implemented, no "adminObjectInterfaces()" attribute defined,
            // should we check the DD whether this Impl class is already specified in any of "admin-object" elements ?
            // If present, return. If not present, throw exception ?
            }
        }
    } else {
        getFailureResult(element, "not a rar bundle context", true);
    }
    return getDefaultProcessedResult();
}
Also used : AdministeredObject(javax.resource.spi.AdministeredObject) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext)

Example 10 with RarBundleContext

use of com.sun.enterprise.deployment.annotation.context.RarBundleContext in project Payara by payara.

the class ConfigPropertyHandler method processAnnotation.

public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
    AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
    ConfigProperty configProperty = (ConfigProperty) element.getAnnotation();
    if (aeHandler instanceof RarBundleContext) {
        RarBundleContext rbc = (RarBundleContext) aeHandler;
        ConnectorDescriptor desc = rbc.getDescriptor();
        handleConfigPropertyAnnotation(configProperty, element, desc);
    } else {
        return getFailureResult(element, "not a rar bundle context", true);
    }
    return getDefaultProcessedResult();
}
Also used : RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext)

Aggregations

RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)12 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)8 OutboundResourceAdapter (com.sun.enterprise.deployment.OutboundResourceAdapter)3 AuthMechanism (com.sun.enterprise.deployment.AuthMechanism)2 AuthenticationMechanism (javax.resource.spi.AuthenticationMechanism)2 ConnectionDefinition (javax.resource.spi.ConnectionDefinition)2 SecurityPermission (javax.resource.spi.SecurityPermission)2 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)1 InboundResourceAdapter (com.sun.enterprise.deployment.InboundResourceAdapter)1 MessageListener (com.sun.enterprise.deployment.MessageListener)1 AppClientContext (com.sun.enterprise.deployment.annotation.context.AppClientContext)1 EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)1 WebBundleContext (com.sun.enterprise.deployment.annotation.context.WebBundleContext)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 Activation (javax.resource.spi.Activation)1 AdministeredObject (javax.resource.spi.AdministeredObject)1 ConnectionDefinitions (javax.resource.spi.ConnectionDefinitions)1 Connector (javax.resource.spi.Connector)1 AnnotatedElementHandler (org.glassfish.apf.AnnotatedElementHandler)1