FileDocCategorySizeDatePackage
EjbClassExposed.javaAPI DocGlassfish v2 API5042Fri May 04 22:33:32 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.beanclass

EjbClassExposed

public class EjbClassExposed extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest
Enterprise Java Bean class exposed test. The class must not be exposed through remote or local interfaces.
author
Sheetal Vartak

Fields Summary
Result
result
ComponentNameConstructor
compName
Constructors Summary
Methods Summary
public Resultcheck(EjbDescriptor descriptor)
Enterprise Java Bean class exposed test.

param
descriptor the Enterprise Java Bean deployment descriptor
return
Result the results for this assertion

                                      
        

	result = getInitializedResult();
	compName = getVerifierContext().getComponentNameConstructor();

    if (descriptor instanceof EjbSessionDescriptor ||
            descriptor instanceof EjbEntityDescriptor) { 
        if (descriptor.getRemoteClassName() != null && 
                !((descriptor.getRemoteClassName()).equals(""))) 
            commonToBothInterfaces(descriptor.getRemoteClassName(),descriptor); 
        if (descriptor.getLocalClassName() != null && 
                !((descriptor.getLocalClassName()).equals(""))) 
            commonToBothInterfaces(descriptor.getLocalClassName(),descriptor); 
    }

    if(result.getStatus() != Result.FAILED) {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(
                getClass().getName() + ".passed",
                "Ejb Bean Class [{0}] is valid.",
                new Object[] {descriptor.getEjbClassName()}));
    }
    return result;

    
private voidcommonToBothInterfaces(java.lang.String remote, EjbDescriptor descriptor)
This method is responsible for the logic of the test. It is called for both local and remote interfaces.

param
descriptor the Enterprise Java Bean deployment descriptor
param
remote for the Remote/Local interface of the Ejb.

	try { 
        Class c = Class.forName(remote, 
                                false, 
                                getVerifierContext().getClassLoader());

        for (Method method : c.getDeclaredMethods()) {
            String ejbClassName = descriptor.getEjbClassName();
            if(((method.getReturnType()).getName()).equals(ejbClassName)) {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(
                        getClass().getName() + ".failed",
                        "Error: Ejb Bean Class [{0}] is exposed through interface [{1}]",
                        new Object[] {ejbClassName, remote}));
            }
        }
	}catch (ClassNotFoundException e) {
        addErrorDetails(result, compName);
	    result.failed(smh.getLocalString(
					     getClass().getName() + ".failedException",
					     "Error: interface class [{0}] not found",
					     new Object[] {remote}));
	}