1 23 package com.sun.enterprise.tools.verifier.appclient; 24 25 import java.io.File ; 26 import java.io.IOException ; 27 28 import com.sun.enterprise.deployment.ApplicationClientDescriptor; 29 import com.sun.enterprise.deployment.Descriptor; 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.AppClientClosureCompiler; 36 import com.sun.enterprise.util.io.FileUtils; 37 38 41 public class AppClientVerifier extends BaseVerifier { 42 43 private ApplicationClientDescriptor appclientd = null; 44 private String classPath; private boolean isASMode = false; 46 47 public AppClientVerifier(FrameworkContext frameworkContext, 48 ApplicationClientDescriptor appClientDescriptor) { 49 this.frameworkContext = frameworkContext; 50 this.appclientd = appClientDescriptor; 51 this.isASMode = !frameworkContext.isPortabilityMode(); 52 } 53 54 60 public void verify() throws Exception { 61 if (areTestsNotRequired(frameworkContext.isAppClient()) && 62 areTestsNotRequired(frameworkContext.isWebServicesClient()) && 63 areTestsNotRequired(frameworkContext.isPersistenceUnits())) 64 return; 65 66 preVerification(); 67 createClosureCompiler(); verify(appclientd, new AppClientCheckMgrImpl(frameworkContext)); 69 } 70 71 public Descriptor getDescriptor() { 72 return appclientd; 73 } 74 75 protected ClassLoader createClassLoader() 76 throws IOException { 77 return appclientd.getClassLoader(); 78 } 79 80 protected String getArchiveUri() { 81 return FileUtils.makeFriendlyFileName(appclientd.getModuleDescriptor().getArchiveUri()); 82 } 83 84 protected String [] getDDString() { 85 String dd[] = {"META-INF/sun-application-client.xml", "META-INF/application-client.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 (!appclientd.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 = appclientd.getApplication().getLibraryDirectory(); 111 if (libdir!=null) { 112 earCP = getLibdirClasspath(ear_uri, libdir) + earCP; 113 } 114 String module_uri = appclientd.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.getAppClientVersion( 141 frameworkContext.getJavaEEVersion()); 142 Object arg = (isASMode)?appclientd.getClassLoader():(Object )getClassPath(); 143 AppClientClosureCompiler cc = new AppClientClosureCompiler(specVer, 144 ClassFileLoaderFactory.newInstance(new Object []{arg})); 145 context.setClosureCompiler(cc); 146 } 147 148 } 149 | Popular Tags |