1 20 package org.apache.cactus.integration.ant.deployment.webapp; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.io.InputStream ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 28 import javax.xml.parsers.ParserConfigurationException ; 29 30 import org.apache.cactus.integration.ant.deployment.DefaultJarArchive; 31 import org.apache.cactus.integration.ant.deployment.JarArchive; 32 import org.xml.sax.SAXException ; 33 34 40 public class DefaultWarArchive extends DefaultJarArchive implements WarArchive 41 { 42 44 47 private WebXml webXml; 48 49 51 57 public DefaultWarArchive(File theFile) 58 throws IOException 59 { 60 super(theFile); 61 } 62 63 69 public DefaultWarArchive(InputStream theInputStream) 70 throws IOException 71 { 72 super(theInputStream); 73 } 74 75 77 80 public final WebXml getWebXml() 81 throws IOException , SAXException , ParserConfigurationException 82 { 83 if (this.webXml == null) 84 { 85 InputStream in = null; 86 try 87 { 88 in = getResource("WEB-INF/web.xml"); 89 if (in != null) 90 { 91 this.webXml = WebXmlIo.parseWebXml(in, null); 92 } 93 } 94 finally 95 { 96 if (in != null) 97 { 98 in.close(); 99 } 100 } 101 } 102 return this.webXml; 103 } 104 105 114 public final boolean containsClass(String theClassName) 115 throws IOException 116 { 117 String resourceName = 119 "WEB-INF/classes/" + theClassName.replace('.', '/') + ".class"; 120 if (getResource(resourceName) != null) 121 { 122 return true; 123 } 124 125 List jars = getResources("WEB-INF/lib/"); 127 for (Iterator i = jars.iterator(); i.hasNext();) 128 { 129 JarArchive jar = new DefaultJarArchive( 130 getResource((String ) i.next())); 131 if (jar.containsClass(theClassName)) 132 { 133 return true; 134 } 135 } 136 137 return false; 138 } 139 140 } 141 | Popular Tags |