1 23 24 25 package com.sun.enterprise.tools.verifier.tests.web; 26 27 import com.sun.enterprise.deployment.InjectionTarget; 28 import com.sun.enterprise.tools.verifier.Result; 29 import com.sun.enterprise.deployment.EntityManagerReferenceDescriptor; 30 import com.sun.enterprise.deployment.WebBundleDescriptor; 31 import java.util.Set ; 32 import javax.servlet.Servlet ; 33 import javax.servlet.SingleThreadModel ; 34 35 44 public class EntityManagerInjection extends WebTest implements WebCheck { 45 46 final static String className = EntityManagerInjection.class.getName(); 47 48 public Result check(WebBundleDescriptor descriptor) { 49 50 Result result = getInitializedResult(); 51 addWarningDetails(result, 52 getVerifierContext().getComponentNameConstructor()); 53 result.setStatus(Result.PASSED); 55 for(EntityManagerReferenceDescriptor emRefDesc : descriptor.getEntityManagerReferenceDescriptors()) { 56 Set <InjectionTarget> injectionTargets = emRefDesc.getInjectionTargets(); 57 if(injectionTargets != null) { 58 for(InjectionTarget it : injectionTargets) { 59 String itClassName = it.getClassName(); 60 String errMsg = smh.getLocalString(className + ".warning", 61 "Found a persistence unit by name [ {0} ] injected into [ {1} ].", 62 new Object []{emRefDesc.getUnitName(), itClassName}); 63 try { 64 Class c = Class.forName(itClassName, false, getVerifierContext().getClassLoader()); 65 if(!(Servlet .class.isAssignableFrom(c))) { 66 result.warning(errMsg); 67 } else if (!(SingleThreadModel .class.isAssignableFrom(c))) { 68 result.warning(errMsg); 69 } 70 } catch(Exception ex) { 71 result.warning(errMsg); 72 } 73 } 74 } 75 } 76 return result; 77 } 78 79 } 80 | Popular Tags |