FileDocCategorySizeDatePackage
MDBImplementsListenerMethods.javaAPI DocGlassfish v2 API4424Fri May 04 22:33:34 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.ejb30

MDBImplementsListenerMethods

public class MDBImplementsListenerMethods extends MessageBeanTest
The message driven bean class must implement the message listener interface or the methods of the message listener interface.
author
Vikas Awasthi

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.EjbMessageBeanDescriptor descriptor)


        try {
            ClassLoader cl = getVerifierContext().getClassLoader();
            Class intfCls = Class.forName(descriptor.getMessageListenerType(), false, cl);
            Class ejbCls = Class.forName(descriptor.getEjbClassName(), false, cl);
            
            if(!intfCls.isAssignableFrom(ejbCls)) {
                Method[] methods = intfCls.getMethods();
                for (Method method : methods) {
                    boolean foundOne = false;
                    for (Method ejbMethod : ejbCls.getMethods()) {
                        if(MethodUtils.methodEquals(ejbMethod, method)) {
                            foundOne = true;
                            break;
                        }
                    }
                    if(!foundOne) {
                        addErrorDetails(result, compName);
                        result.failed(
                                smh.getLocalString(getClass().getName()+".failed",
                                "Message bean [ {0} ] neither implements listener " +
                                "interface [ {1} ] nor implements listener " +
                                "interface method [ {2} ]",
                                new Object[] {ejbCls.getSimpleName(), intfCls.getName(), method}));
                    }
                }
            }
        } catch (ClassNotFoundException e) {
            //ignore as this error will be caught by other tests
            logger.fine(descriptor.getEjbClassName() + " Not found");
        }
        
        if(result.getStatus() != Result.FAILED) {
            addGoodDetails(result, compName);
            result.passed(
                    smh.getLocalString(getClass().getName()+".passed",
                            "Valid Message bean [ {0} ]",
                            new Object[] {descriptor.getEjbClassName()}));
        }

        return result;