FileDocCategorySizeDatePackage
EntityManagerInjection.javaAPI DocGlassfish v2 API4276Fri May 04 22:34:08 BST 2007com.sun.enterprise.tools.verifier.tests.web

EntityManagerInjection

public class EntityManagerInjection extends WebTest implements WebCheck
Assertion EntityManager should not be injected into a web application that uses multithread model. EntityManager is not thread safe, hence it should not be injected into a web application that uses multithreaded model.
author
bshankar@sun.com

Fields Summary
static final String
className
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)

    
        
        
        Result result = getInitializedResult();
        addWarningDetails(result,
                getVerifierContext().getComponentNameConstructor());
        result.setStatus(Result.PASSED); //default status is PASSED
        
        for(EntityManagerReferenceDescriptor emRefDesc : descriptor.getEntityManagerReferenceDescriptors()) {
            Set<InjectionTarget> injectionTargets = emRefDesc.getInjectionTargets();
            if(injectionTargets != null) {
                for(InjectionTarget it : injectionTargets) {
                    String itClassName = it.getClassName();
                    String errMsg = smh.getLocalString(className + ".warning",
                            "Found a persistence unit by name [ {0} ] injected into [ {1} ].",
                            new Object[]{emRefDesc.getUnitName(), itClassName});
                    try {
                        Class c = Class.forName(itClassName, false, getVerifierContext().getClassLoader());
                        if(!(Servlet.class.isAssignableFrom(c))) {
                            result.warning(errMsg);
                        } else if (!(SingleThreadModel.class.isAssignableFrom(c))) {
                            result.warning(errMsg);
                        }
                    } catch(Exception ex) {
                        result.warning(errMsg);
                    }
                }
            }
        }
        return result;