Search in sources :

Example 1 with MessageListener

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

the class CheckActivationSpecClass method check.

/**
 * <p>
 * Test for each message-listener , that "activationspec-class"
 * implements "javax.resource.spi.ActivationSpec".
 * </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;
        }
        if (!isImplementorOf(implClass, "javax.resource.spi.ActivationSpec")) {
            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} ] does not implement javax.resource.spi.ActivationSpec.", new Object[] { impl }));
            return result;
        }
    }
    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 implement javax.resource.spi.ActivationSpec"));
    }
    return result;
}
Also used : Set(java.util.Set) InboundResourceAdapter(com.sun.enterprise.deployment.InboundResourceAdapter) Iterator(java.util.Iterator) MessageListener(com.sun.enterprise.deployment.MessageListener) Result(com.sun.enterprise.tools.verifier.Result)

Example 2 with MessageListener

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

the class CheckActivationSpecJavaBean method check.

/**
 * <p>
 * Test for each message-listener, that "activationspec-class" is a Java Bean.
 * </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;
        }
        Set configProps = msgListener.getConfigProperties();
        Iterator propIter = configProps.iterator();
        BeanInfo bi = null;
        try {
            bi = Introspector.getBeanInfo(implClass, Object.class);
        } catch (IntrospectionException ie) {
            oneFailed = true;
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: The activationspec-class [ {0} ] is not JavaBeans compliant", new Object[] { impl }));
            return result;
        }
        PropertyDescriptor[] properties = bi.getPropertyDescriptors();
        Hashtable<String, PropertyDescriptor> props = new Hashtable<String, PropertyDescriptor>();
        for (int i = 0; i < properties.length; i++) {
            props.put(properties[i].getName(), properties[i]);
        }
        while (propIter.hasNext()) {
            EnvironmentProperty envProp = (EnvironmentProperty) propIter.next();
            String name = envProp.getName();
            String type = envProp.getType();
            PropertyDescriptor propDesc = (PropertyDescriptor) props.get(name.substring(0, 1).toLowerCase() + name.substring(1));
            if (propDesc != null) {
                if (propDesc.getReadMethod() == null || propDesc.getWriteMethod() == null) {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: The activationspec-class [ {0} ] does not provide accessor methods for [ {1} ].", new Object[] { impl, name }));
                    return result;
                }
            } else {
                oneFailed = true;
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: The activationspec-class [ {0} ] does not provide accessor methods for [ {1} ].", new Object[] { impl, name }));
                return result;
            }
        }
    }
    if (!oneFailed) {
        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: Each activationspec-class is a Java Bean"));
    }
    return result;
}
Also used : InboundResourceAdapter(com.sun.enterprise.deployment.InboundResourceAdapter) MessageListener(com.sun.enterprise.deployment.MessageListener) Result(com.sun.enterprise.tools.verifier.Result) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty)

Example 3 with MessageListener

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

the class CheckActivationSpecSerializable method check.

/**
 * <p>
 * Test that "activationspec-class" implements java.io.Serializable
 * </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;
        }
        if (!isImplementorOf(implClass, "java.io.Serializable")) {
            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} ] does not implement java.io.Serializable", new Object[] { impl }));
            return result;
        }
    }
    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 implement java.io.Serializable"));
    }
    return result;
}
Also used : Set(java.util.Set) InboundResourceAdapter(com.sun.enterprise.deployment.InboundResourceAdapter) Iterator(java.util.Iterator) MessageListener(com.sun.enterprise.deployment.MessageListener) Result(com.sun.enterprise.tools.verifier.Result)

Example 4 with MessageListener

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

the class ConnectorMessageBeanClient method setup.

/**
 * Gets executed as part of message bean deployment. Creates the
 * <code>ActivationSpec</code> javabean and does endpointfactory
 * activation with the resource adapter. This code also converts
 * all J2EE 1.3 MDB properties to MQ resource adapter activation
 * spec properties, if user doesnt specifies resource adapter
 * module name in sun-ejb-jar.xml of the MDB. This is done using
 * <code>com.sun.enterprise.connector.system.ActiveJmsResourceAdapter
 * </code>
 *
 * @param messageBeanPM <code>MessageBeanProtocolManager</code> object.
 */
public void setup(MessageBeanProtocolManager messageBeanPM) throws Exception {
    ClassLoader loader = descriptor_.getEjbBundleDescriptor().getClassLoader();
    if (loader == null) {
        loader = Thread.currentThread().getContextClassLoader();
    }
    beanClass_ = loader.loadClass(descriptor_.getEjbClassName());
    messageBeanPM_ = messageBeanPM;
    String resourceAdapterMid = getResourceAdapterMid(descriptor_);
    ActiveInboundResourceAdapter aira = getActiveResourceAdapter(resourceAdapterMid);
    aira.updateMDBRuntimeInfo(descriptor_, messageBeanPM_.getPoolDescriptor());
    // the resource adapter this MDB client is deployed to
    ResourceAdapter ra = aira.getResourceAdapter();
    if (ra == null) {
        String i18nMsg = localStrings.getString("msg-bean-client.ra.class.not.specified", resourceAdapterMid);
        throw new ConnectorRuntimeException(i18nMsg);
    }
    ConnectorDescriptor desc = aira.getDescriptor();
    MessageListener msgListener = getMessageListener(desc);
    String activationSpecClassName = null;
    if (msgListener != null) {
        activationSpecClassName = msgListener.getActivationSpecClass();
    }
    if (activationSpecClassName != null) {
        if (logger.isLoggable(Level.FINEST)) {
            String msg = "ActivationSpecClassName = " + activationSpecClassName;
            logger.log(Level.FINEST, msg);
        }
        try {
            ActivationSpec activationSpec = getActivationSpec(aira, activationSpecClassName);
            activationSpec.setResourceAdapter(ra);
            // at this stage, activation-spec is created, config properties merged with ejb-descriptor.
            // validate activation-spec now
            ConnectorRuntime runtime = ConnectorRuntime.getRuntime();
            runtime.getConnectorBeanValidator().validateJavaBean(activationSpec, resourceAdapterMid);
            aira.validateActivationSpec(activationSpec);
            myState = BLOCKED;
            ra.endpointActivation(this, activationSpec);
            aira.addEndpointFactoryInfo(beanID_, new MessageEndpointFactoryInfo(this, activationSpec));
        } catch (Exception ex) {
            Object[] args = new Object[] { resourceAdapterMid, activationSpecClassName, ex };
            logger.log(Level.WARNING, "endpoint.activation.failure", args);
            throw (Exception) (new Exception()).initCause(ex);
        }
    } else {
        // FIXME  throw some exception here.
        throw new Exception("Unsupported message listener type");
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ActivationSpec(javax.resource.spi.ActivationSpec) MessageListener(com.sun.enterprise.deployment.MessageListener) ActiveResourceAdapter(com.sun.enterprise.connectors.ActiveResourceAdapter) ResourceAdapter(javax.resource.spi.ResourceAdapter) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) UnavailableException(javax.resource.spi.UnavailableException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ConnectorRuntime(com.sun.enterprise.connectors.ConnectorRuntime)

Example 5 with MessageListener

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

the class ConnectorMessageBeanClient method getMessageListener.

private MessageListener getMessageListener(ConnectorDescriptor desc) {
    String msgListenerType = getDescriptor().getMessageListenerType();
    if (msgListenerType == null || "".equals(msgListenerType))
        msgListenerType = "javax.jms.MessageListener";
    Iterator i = desc.getInboundResourceAdapter().getMessageListeners().iterator();
    MessageListener msgListener = null;
    while (i.hasNext()) {
        msgListener = (MessageListener) i.next();
        if (msgListenerType.equals(msgListener.getMessageListenerType()))
            break;
    }
    return msgListener;
}
Also used : 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