1 23 package com.sun.enterprise.tools.verifier.web; 24 25 import java.io.File ; 26 import java.io.FileInputStream ; 27 import java.io.IOException ; 28 import java.util.Iterator ; 29 import java.util.Set ; 30 import java.util.Vector ; 31 32 import com.sun.enterprise.deployment.Descriptor; 33 import com.sun.enterprise.deployment.ServiceReferenceDescriptor; 34 import com.sun.enterprise.deployment.WebBundleDescriptor; 35 import com.sun.enterprise.deployment.io.WebDeploymentDescriptorFile; 36 import com.sun.enterprise.tools.verifier.*; 37 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 38 import com.sun.enterprise.tools.verifier.tests.dd.ParseDD; 39 import com.sun.enterprise.tools.verifier.wsclient.WebServiceClientCheckMgrImpl; 40 41 import javax.xml.parsers.ParserConfigurationException ; 42 43 import org.xml.sax.SAXException ; 44 45 48 public class WebCheckMgrImpl extends CheckMgr implements JarCheck { 49 50 53 private static final String testsListFileName = "TestNamesWeb.xml"; private static final String sunONETestsListFileName = getSunPrefix() 55 .concat(testsListFileName); 56 private static TagLibDescriptor[] tlds; 57 58 public WebCheckMgrImpl(FrameworkContext frameworkContext) { 59 this.frameworkContext = frameworkContext; 60 } 61 62 67 public void check(Descriptor descriptor) throws Exception { 68 checkPersistenceUnits(WebBundleDescriptor.class.cast(descriptor)); 70 checkWebServices(descriptor); 72 checkWebServicesClient(descriptor); 74 75 if (frameworkContext.isPartition() && 76 !frameworkContext.isWeb()) 77 return; 78 79 createTaglibDescriptors(descriptor); 81 createFacesConfigDescriptor(descriptor); 82 83 if (getSchemaVersion(descriptor).compareTo("2.4") < 0) { WebDeploymentDescriptorFile ddf = new WebDeploymentDescriptorFile(); 86 File file = new File (getAbstractArchiveUri(descriptor), 87 ddf.getDeploymentDescriptorPath()); 88 FileInputStream is = new FileInputStream (file); 89 try { 90 if (is != null) { 91 Result result = new ParseDD().validateWebDescriptor(is); 92 result.setComponentName(getArchiveUri(descriptor)); 93 setModuleName(result); 94 frameworkContext.getResultManager().add(result); 95 is.close(); 96 } 97 } finally { 98 try { 99 if(is!=null) 100 is.close(); 101 } catch(Exception e) {} 102 } 103 } 104 105 super.check(descriptor); 106 } 107 108 115 protected String getTestsListFileName() { 116 return testsListFileName; 117 } 118 119 122 protected String getSunONETestsListFileName() { 123 return sunONETestsListFileName; 124 } 125 126 132 protected void createTaglibDescriptors(Descriptor descriptor) { 133 TagLibFactory tlf = new TagLibFactory(context, frameworkContext); 134 tlds = tlf.getTagLibDescriptors((WebBundleDescriptor) descriptor); 135 if (tlds != null) { 136 context.setTagLibDescriptors(tlds); 137 setVerifierContext(context); 138 } 139 } 140 141 146 protected void createFacesConfigDescriptor(Descriptor descriptor) { 147 FacesConfigDescriptor d = new FacesConfigDescriptor(context, (WebBundleDescriptor)descriptor); 148 context.setFacesConfigDescriptor(d); 149 } 150 151 protected void checkWebServicesClient(Descriptor descriptor) 152 throws Exception { 153 if (frameworkContext.isPartition() && 154 !frameworkContext.isWebServicesClient()) 155 return; 156 157 WebBundleDescriptor desc = (WebBundleDescriptor) descriptor; 158 WebServiceClientCheckMgrImpl webServiceClientCheckMgr = new WebServiceClientCheckMgrImpl( 159 frameworkContext); 160 if (desc.hasWebServiceClients()) { 161 Set serviceRefDescriptors = desc.getServiceReferenceDescriptors(); 162 Iterator it = serviceRefDescriptors.iterator(); 163 164 while (it.hasNext()) { 165 webServiceClientCheckMgr.setVerifierContext(context); 166 webServiceClientCheckMgr.check( 167 (ServiceReferenceDescriptor) it.next()); 168 } 169 } 170 } 171 172 protected String getSchemaVersion(Descriptor descriptor) { 173 return ((WebBundleDescriptor) descriptor).getSpecVersion(); 174 } 175 176 protected void setModuleName(Result r) { 177 r.setModuleName(Result.WEB); 178 } 179 180 188 protected Vector <TestInformation> getTestFromExcludeList() throws ParserConfigurationException , SAXException , IOException { 189 Vector <TestInformation> tests = super.getTestFromExcludeList(); 190 if(frameworkContext.getJspOutDir() !=null) { TestInformation ti = new TestInformation(); 192 ti.setClassName("com.sun.enterprise.tools.verifier.tests.web.AllJSPsMustBeCompilable"); tests.addElement(ti); 194 } 195 return tests; 196 } 197 198 protected ComponentNameConstructor getComponentNameConstructor( 199 Descriptor descriptor) { 200 return new ComponentNameConstructor((WebBundleDescriptor)descriptor); 201 } 202 203 } 204 | Popular Tags |