Search in sources :

Example 6 with MessageListener

use of com.sun.enterprise.deployment.MessageListener in project Payara by payara.

the class RequiredConfigNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, Descriptor descriptor) {
    if (!(descriptor instanceof MessageListener)) {
        throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
    }
    Iterator configProps = null;
    configProps = ((MessageListener) descriptor).getRequiredConfigProperties().iterator();
    // config property info
    if (configProps != null) {
        for (; configProps.hasNext(); ) {
            EnvironmentProperty config = (EnvironmentProperty) configProps.next();
            Node configNode = appendChild(parent, ConnectorTagNames.REQUIRED_CONFIG_PROP);
            writeLocalizedDescriptions(configNode, config);
            appendTextChild(configNode, ConnectorTagNames.CONFIG_PROPERTY_NAME, config.getName());
        }
    }
    return parent;
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) MessageListener(com.sun.enterprise.deployment.MessageListener) Iterator(java.util.Iterator)

Example 7 with MessageListener

use of com.sun.enterprise.deployment.MessageListener in project Payara by payara.

the class ActivationSpecNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, Descriptor descriptor) {
    if (!(descriptor instanceof MessageListener)) {
        throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
    }
    MessageListener msgListener = (MessageListener) descriptor;
    Node actSpecNode = appendChild(parent, ConnectorTagNames.ACTIVATION_SPEC);
    appendTextChild(actSpecNode, ConnectorTagNames.ACTIVATION_SPEC_CLASS, msgListener.getActivationSpecClass());
    // required-config-property
    RequiredConfigNode reqNode = new RequiredConfigNode();
    actSpecNode = reqNode.writeDescriptor(actSpecNode, msgListener);
    ConfigPropertyNode configPropertyNode = new ConfigPropertyNode();
    configPropertyNode.writeDescriptor(actSpecNode, msgListener);
    return parent;
}
Also used : Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) MessageListener(com.sun.enterprise.deployment.MessageListener)

Example 8 with MessageListener

use of com.sun.enterprise.deployment.MessageListener in project Payara by payara.

the class CheckActivationSpecOverridesEquals method check.

/**
 * <p>
 * Test for each message-listener , that "activationspec-class"
 * does not override the equals method.
 * </p>
 *
 * @param descriptor deployment descriptor for the rar file
 * @return result object containing the result of the individual test
 * performed
 */
public Result check(ConnectorDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    if (!descriptor.getInBoundDefined()) {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.notApp", "Resource Adapter does not provide inbound communication"));
        return result;
    }
    InboundResourceAdapter ra = descriptor.getInboundResourceAdapter();
    Set msgListeners = ra.getMessageListeners();
    boolean oneFailed = false;
    Iterator iter = msgListeners.iterator();
    while (iter.hasNext()) {
        MessageListener msgListener = (MessageListener) iter.next();
        String impl = msgListener.getActivationSpecClass();
        Class implClass = null;
        try {
            implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException e) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.nonexist", "Error: The class [ {0} ] as defined under activationspec-class in the deployment descriptor does not exist", new Object[] { impl }));
            return result;
        }
        try {
            Method equalsMethod = implClass.getMethod("equals", new Class[] { implClass });
            oneFailed = true;
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: activationspec-class [ {0} ] overrides the equals method", new Object[] { impl }));
            return result;
        } catch (NoSuchMethodException e) {
        // implClass does not override equals.
        } catch (SecurityException e) {
        }
    }
    if (!oneFailed) {
        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: all activationspec-class do not override the equals method"));
    }
    return result;
}
Also used : Set(java.util.Set) InboundResourceAdapter(com.sun.enterprise.deployment.InboundResourceAdapter) MessageListener(com.sun.enterprise.deployment.MessageListener) Method(java.lang.reflect.Method) Result(com.sun.enterprise.tools.verifier.Result) Iterator(java.util.Iterator)

Example 9 with MessageListener

use of com.sun.enterprise.deployment.MessageListener 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 10 with MessageListener

use of com.sun.enterprise.deployment.MessageListener in project Payara by payara.

the class MessageListenerNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, Descriptor descriptor) {
    if (!(descriptor instanceof InboundResourceAdapter)) {
        throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
    }
    Iterator msgListeners = ((InboundResourceAdapter) descriptor).getMessageListeners().iterator();
    if (!msgListeners.hasNext()) {
        throw new RuntimeException("There must be at least one messagelistener for this inbound resource adapter");
    }
    // message listeners
    for (; msgListeners.hasNext(); ) {
        MessageListener msgListener = (MessageListener) msgListeners.next();
        Node msgListenerNode = appendChild(parent, ConnectorTagNames.MSG_LISTENER);
        appendTextChild(msgListenerNode, ConnectorTagNames.MSG_LISTENER_TYPE, msgListener.getMessageListenerType());
        // activation spec node
        ActivationSpecNode actSpecNode = new ActivationSpecNode();
        msgListenerNode = actSpecNode.writeDescriptor(msgListenerNode, msgListener);
    }
    return parent;
}
Also used : InboundResourceAdapter(com.sun.enterprise.deployment.InboundResourceAdapter) Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) Iterator(java.util.Iterator) MessageListener(com.sun.enterprise.deployment.MessageListener)

Aggregations

MessageListener (com.sun.enterprise.deployment.MessageListener)10 InboundResourceAdapter (com.sun.enterprise.deployment.InboundResourceAdapter)6 Iterator (java.util.Iterator)6 Result (com.sun.enterprise.tools.verifier.Result)4 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)3 Set (java.util.Set)3 Node (org.w3c.dom.Node)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 ActiveResourceAdapter (com.sun.enterprise.connectors.ActiveResourceAdapter)1 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)1 RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)1 Method (java.lang.reflect.Method)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Activation (javax.resource.spi.Activation)1 ActivationSpec (javax.resource.spi.ActivationSpec)1 ResourceAdapter (javax.resource.spi.ResourceAdapter)1 UnavailableException (javax.resource.spi.UnavailableException)1