1 23 package com.sun.enterprise.tools.verifier.connector; 24 25 import java.io.File ; 26 import java.io.IOException ; 27 28 import com.sun.enterprise.deployment.ConnectorDescriptor; 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.ConnectorClosureCompiler; 36 import com.sun.enterprise.util.io.FileUtils; 37 38 41 public class ConnectorVerifier extends BaseVerifier { 42 43 private ConnectorDescriptor cond = null; 44 private String classPath; private boolean isASMode = false; 46 47 public ConnectorVerifier(FrameworkContext frameworkContext, 48 ConnectorDescriptor cond) { 49 this.frameworkContext = frameworkContext; 50 this.cond = cond; 51 this.isASMode = !frameworkContext.isPortabilityMode(); 52 } 53 54 public void verify() throws Exception { 55 if (areTestsNotRequired(frameworkContext.isConnector())) 56 return; 57 58 preVerification(); 59 createClosureCompiler(); verify(cond, new ConnectorCheckMgrImpl(frameworkContext)); 61 } 62 63 public Descriptor getDescriptor() { 64 return cond; 65 } 66 67 protected ClassLoader createClassLoader() 68 throws IOException { 69 return cond.getClassLoader(); 70 } 71 72 protected String getArchiveUri() { 73 return FileUtils.makeFriendlyFileName(cond.getModuleDescriptor().getArchiveUri()); 74 } 75 76 protected String [] getDDString() { 77 String dd[] = {"META-INF/sun-ra.xml", "META-INF/ra.xml"}; return dd; 79 } 80 81 88 protected String getClassPath() throws IOException { 89 if (classPath != null) return classPath; 90 91 if(isASMode) 92 return (classPath = getClassPath(frameworkContext.getClassPath())); 93 94 String cp; 95 if (!cond.getModuleDescriptor().isStandalone()) { 96 String ear_uri = frameworkContext.getExplodedArchivePath(); 98 File ear = new File (ear_uri); 99 assert(ear.isDirectory()); 100 cp = ClassPathBuilder.buildClassPathForEar(ear); 101 String libdir = cond.getApplication().getLibraryDirectory(); 102 if (libdir!=null) { 103 cp = getLibdirClasspath(ear_uri, libdir) + cp; 104 } 105 106 118 } else { 119 String module_uri = frameworkContext.getExplodedArchivePath(); 121 File module = new File (module_uri); 122 assert(module.isDirectory() && module.isAbsolute()); 123 cp = ClassPathBuilder.buildClassPathForRar(module); 124 } 125 return (classPath = cp); 126 } 127 128 135 protected void createClosureCompiler() throws IOException { 136 String specVer = SpecVersionMapper.getJCAVersion( 137 frameworkContext.getJavaEEVersion()); 138 Object arg = (isASMode)?cond.getClassLoader():(Object )getClassPath(); 139 ConnectorClosureCompiler cc = new ConnectorClosureCompiler(specVer, 140 ClassFileLoaderFactory.newInstance(new Object []{arg})); 141 context.setClosureCompiler(cc); 142 } 143 } 144 | Popular Tags |