1 23 package com.sun.enterprise.tools.verifier.ejb; 24 25 import java.io.File ; 26 import java.io.IOException ; 27 28 import com.sun.enterprise.deployment.Descriptor; 29 import com.sun.enterprise.deployment.EjbBundleDescriptor; 30 import com.sun.enterprise.tools.verifier.BaseVerifier; 31 import com.sun.enterprise.tools.verifier.FrameworkContext; 32 import com.sun.enterprise.tools.verifier.SpecVersionMapper; 33 import com.sun.enterprise.tools.verifier.apiscan.classfile.ClassFileLoaderFactory; 34 import com.sun.enterprise.tools.verifier.apiscan.packaging.ClassPathBuilder; 35 import com.sun.enterprise.tools.verifier.apiscan.stdapis.EjbClosureCompiler; 36 import com.sun.enterprise.util.io.FileUtils; 37 38 43 public class EjbVerifier extends BaseVerifier { 44 45 private EjbBundleDescriptor ejbd = null; 46 private String classPath; private boolean isASMode = false; 48 49 public EjbVerifier(FrameworkContext frameworkContext, 50 EjbBundleDescriptor ejbd) { 51 this.frameworkContext = frameworkContext; 52 this.ejbd = ejbd; 53 this.isASMode = !frameworkContext.isPortabilityMode(); 54 } 55 56 public void verify() throws Exception { 57 if (areTestsNotRequired(frameworkContext.isEjb()) && 58 areTestsNotRequired(frameworkContext.isWebServices()) && 59 areTestsNotRequired(frameworkContext.isWebServicesClient()) && 60 areTestsNotRequired(frameworkContext.isPersistenceUnits())) 61 return; 62 63 preVerification(); 64 createClosureCompiler(); verify(ejbd, new EjbCheckMgrImpl(frameworkContext)); 66 } 67 68 public Descriptor getDescriptor() { 69 return ejbd; 70 } 71 72 75 protected ClassLoader createClassLoader() 76 throws IOException { 77 return ejbd.getClassLoader(); 78 } 79 80 protected String getArchiveUri() { 81 return FileUtils.makeFriendlyFileName(ejbd.getModuleDescriptor().getArchiveUri()); 82 } 83 84 protected String [] getDDString() { 85 String dd[] = {"META-INF/sun-ejb-jar.xml", "META-INF/ejb-jar.xml", "META-INF/webservices.xml"}; return dd; 88 } 89 90 97 protected String getClassPath() throws IOException { 98 if (classPath != null) return classPath; 99 100 if(isASMode) 101 return (classPath = getClassPath(frameworkContext.getClassPath())); 102 103 String cp; 104 if (!ejbd.getModuleDescriptor().isStandalone()) { 105 String ear_uri = frameworkContext.getExplodedArchivePath(); 107 File ear = new File (ear_uri); 108 assert(ear.isDirectory()); 109 String earCP = ClassPathBuilder.buildClassPathForEar(ear); 110 String libdir = ejbd.getApplication().getLibraryDirectory(); 111 if (libdir!=null) { 112 earCP = getLibdirClasspath(ear_uri, libdir) + earCP; 113 } 114 String module_uri = ejbd.getModuleDescriptor().getArchiveUri(); File module = new File (module_uri); 116 assert(module.isFile() && !module.isAbsolute()); 117 File explodedModuleDir = new File (ear_uri, 119 FileUtils.makeFriendlyFileName(module_uri)); 120 String moduleCP = ClassPathBuilder.buildClassPathForJar( 121 explodedModuleDir); 122 cp = moduleCP + File.pathSeparator + earCP; 123 } else { 124 String module_uri = frameworkContext.getExplodedArchivePath(); File module = new File (module_uri); 126 assert(module.isDirectory() && module.isAbsolute()); 127 cp = ClassPathBuilder.buildClassPathForJar(module); 128 } 129 return (classPath = cp); 130 } 131 132 139 protected void createClosureCompiler() throws IOException { 140 String specVer = SpecVersionMapper.getEJBVersion( 141 frameworkContext.getJavaEEVersion()); 142 Object arg = (isASMode)?ejbd.getClassLoader():(Object )getClassPath(); 143 EjbClosureCompiler cc = new EjbClosureCompiler(specVer, 144 ClassFileLoaderFactory.newInstance(new Object []{arg})); 145 context.setClosureCompiler(cc); 146 } 147 } 148 | Popular Tags |