FileDocCategorySizeDatePackage
EjbCheckMgrImpl.javaAPI DocGlassfish v2 API10764Fri May 04 22:33:26 BST 2007com.sun.enterprise.tools.verifier.ejb

EjbCheckMgrImpl

public class EjbCheckMgrImpl extends CheckMgr implements JarCheck
Ejb harness

Fields Summary
private static final String
testsListFileName
name of the file containing the list of tests for the ejb architecture
private static final String
sunONETestsListFileName
private com.sun.jdo.spi.persistence.support.ejb.ejbc.JDOCodeGenerator
jdc
Constructors Summary
public EjbCheckMgrImpl(FrameworkContext frameworkContext)


       
        this.frameworkContext = frameworkContext;
    
Methods Summary
public voidcheck(Descriptor descriptor)
Check Ejb for spec. conformance

param
descriptor Ejb descriptor

        // run persistence tests first.
        checkPersistenceUnits(EjbBundleDescriptor.class.cast(descriptor));
        // an EjbBundleDescriptor can have an WebServicesDescriptor
        checkWebServices(descriptor);
        // an EjbBundleDescriptor can have  WebService References
        checkWebServicesClient(descriptor);

        if (frameworkContext.isPartition() &&
                !frameworkContext.isEjb())
            return;

        EjbBundleDescriptor bundleDescriptor = (EjbBundleDescriptor) descriptor;
        setDescClassLoader(bundleDescriptor);
        // DOL (jerome): is asking us to call this in some cases, like when
        // an ejb-ref is unresolved etc.
        try {
            EjbBundleValidator validator = new EjbBundleValidator();
            validator.accept(bundleDescriptor);
        } catch (Exception e) {
        } // nothing can be done
        
        // initialize JDOC if bundle has CMP's
        if (bundleDescriptor.containsCMPEntity()) {
            try {
                // See bug #6274161. We now pass an additional boolean
                // to indicate whether we are in portable or AS mode.
                jdc.init(bundleDescriptor, context.getClassLoader(),
                        getAbstractArchiveUri(bundleDescriptor),
                        frameworkContext.isPortabilityMode());
            } catch (Throwable ex) {
                context.setJDOException(ex);
            }
        }
        // set the JDO Codegenerator into the context
        context.setJDOCodeGenerator(jdc);
        
        // run the ParseDD test
        if (bundleDescriptor.getSpecVersion().compareTo("2.1") < 0) { // NOI18N
            EjbDeploymentDescriptorFile ddf = new EjbDeploymentDescriptorFile();
            File file = new File(getAbstractArchiveUri(bundleDescriptor),
                    ddf.getDeploymentDescriptorPath());
            FileInputStream is = new FileInputStream(file);
            try {
                if (is != null) {
                    Result result = new ParseDD().validateEJBDescriptor(is);
                    result.setComponentName(new File(bundleDescriptor.getModuleDescriptor().
                            getArchiveUri()).getName());
                    setModuleName(result);
                    frameworkContext.getResultManager().add(result);
                }
            } finally {
                try {
                    if(is != null) {
                        is.close();
                    }
                } catch (Exception e) {}
            }
        }

        for (Iterator itr = bundleDescriptor.getEjbs().iterator();
             itr.hasNext();) {
            EjbDescriptor ejbDescriptor = (EjbDescriptor) itr.next();
            super.check(ejbDescriptor);
        }

        if (bundleDescriptor.containsCMPEntity() &&
                context.getJDOException() == null) {
            try {
                jdc.cleanup();
            } catch (GeneratorException ge) {
            } // eat up the exception
            context.setJDOCodeGenerator(null);
        }
    
protected voidcheckWebServicesClient(Descriptor descriptor)

        if (frameworkContext.isPartition() &&
                !frameworkContext.isWebServicesClient())
            return;
        EjbBundleDescriptor desc = (EjbBundleDescriptor) descriptor;
        WebServiceClientCheckMgrImpl webServiceClientCheckMgr = new WebServiceClientCheckMgrImpl(
                frameworkContext);
        if (desc.hasWebServiceClients()) {
            Set ejbdescs = desc.getEjbs();
            Iterator ejbIt = ejbdescs.iterator();

            while (ejbIt.hasNext()) {
                EjbDescriptor ejbDesc = (EjbDescriptor) ejbIt.next();
                context.setEjbDescriptorForServiceRef(ejbDesc);
                Set serviceRefDescriptors = ejbDesc.getServiceReferenceDescriptors();
                Iterator it = serviceRefDescriptors.iterator();
                while (it.hasNext()) {
                    webServiceClientCheckMgr.setVerifierContext(context);
                    webServiceClientCheckMgr.check(
                            (ServiceReferenceDescriptor) it.next());
                }
            }
            context.setEjbDescriptorForServiceRef(null);
        }
    
private java.lang.StringgetAbstractArchiveUri(EjbBundleDescriptor desc)

        String archBase = context.getAbstractArchive().getArchiveUri();
        ModuleDescriptor mdesc = desc.getModuleDescriptor();
        if(mdesc.isStandalone()) {
            return archBase;
        } else {
            return archBase + File.separator +
                    FileUtils.makeFriendlyFileName(mdesc.getArchiveUri());
        }
    
protected EjbBundleDescriptorgetBundleDescriptor(Descriptor descriptor)

        return ((EjbDescriptor) descriptor).getEjbBundleDescriptor();
    
protected com.sun.enterprise.tools.verifier.tests.ComponentNameConstructorgetComponentNameConstructor(Descriptor descriptor)

        return new ComponentNameConstructor((EjbDescriptor)descriptor);
    
protected java.lang.StringgetSchemaVersion(Descriptor descriptor)

        return getBundleDescriptor(descriptor).getSpecVersion();
    
protected java.lang.StringgetSunONETestsListFileName()

return
String filename containing sunone tests

        return sunONETestsListFileName;
    
protected java.lang.StringgetTestsListFileName()
return the configuration file name for the list of tests pertinent to the connector architecture

return
String filename containing the list of tests

        return testsListFileName;
    
protected booleanisApplicable(TestInformation test, Descriptor descriptor)
entity and mdb assertions should not be run for session descriptors and similarly the other way round.

        String testName = test.getClassName();
        if(descriptor instanceof EjbSessionDescriptor && 
                (testName.indexOf("tests.ejb.entity")>=0 || // NOI18N
                testName.indexOf("tests.ejb.messagebean")>=0)) // NOI18N
            return false;
        if(descriptor instanceof EjbEntityDescriptor && 
                (testName.indexOf("tests.ejb.session")>=0 || // NOI18N
                testName.indexOf("tests.ejb.messagebean")>=0)) // NOI18N
            return false;
        if(descriptor instanceof EjbMessageBeanDescriptor && 
                (testName.indexOf("tests.ejb.session")>=0 || // NOI18N
                testName.indexOf("tests.ejb.entity")>=0)) // NOI18N
            return false;
        return true;
    
private voidsetDescClassLoader(EjbBundleDescriptor bundleDescriptor)

        Iterator bundleItr = bundleDescriptor.getEjbs().iterator();
        while (bundleItr.hasNext()) {
            EjbDescriptor descriptor = (EjbDescriptor) bundleItr.next();
            if (descriptor instanceof IASEjbCMPEntityDescriptor) {
                ((IASEjbCMPEntityDescriptor) (descriptor)).setClassLoader(
                        context.getClassLoader());
            }
        }
    
protected voidsetModuleName(Result r)

        r.setModuleName(Result.EJB);