1 23 package com.sun.enterprise.deployment.annotation.impl; 24 25 import java.io.File ; 26 import java.io.FileFilter ; 27 import java.io.IOException ; 28 import java.net.URL ; 29 import java.net.URLClassLoader ; 30 import java.util.Iterator ; 31 import java.util.Set ; 32 import java.util.Vector ; 33 import java.util.logging.Level ; 34 35 import com.sun.enterprise.deployment.WebBundleDescriptor; 36 import com.sun.enterprise.deployment.WebComponentDescriptor; 37 import com.sun.enterprise.deployment.web.ServletFilter; 38 import com.sun.enterprise.deployment.web.AppListenerDescriptor; 39 40 45 public class WarScanner extends ModuleScanner { 46 public WarScanner(File archiveFile, WebBundleDescriptor webBundleDesc) 47 throws IOException { 48 this(archiveFile, webBundleDesc, null); 49 } 50 51 57 public WarScanner(File archiveFile, WebBundleDescriptor webBundleDesc, 58 ClassLoader classLoader) throws IOException { 59 if (AnnotationUtils.getLogger().isLoggable(Level.FINE)) { 60 AnnotationUtils.getLogger().fine("archiveFile is " + archiveFile); 61 AnnotationUtils.getLogger().fine("webBundle is " + webBundleDesc); 62 AnnotationUtils.getLogger().fine("classLoader is " + classLoader); 63 } 64 this.archiveFile = archiveFile; 65 this.classLoader = classLoader; 66 67 if (!archiveFile.isDirectory()) { 68 return; 70 } 71 72 File webinf = new File (archiveFile, "WEB-INF"); 73 File classes = new File (webinf, "classes"); 74 if (classes.exists()) { 75 addScanDirectory(classes); 76 } 77 File lib = new File (webinf, "lib"); 78 if (lib.exists()) { 79 File [] jarFiles = lib.listFiles(new FileFilter () { 80 public boolean accept(File pathname) { 81 return (pathname.isFile() && 82 pathname.getAbsolutePath().endsWith(".jar")); 83 } 84 }); 85 86 if (jarFiles != null && jarFiles.length > 0) { 87 for (File jarFile : jarFiles) { 88 addScanJar(jarFile); 89 } 90 } 91 } 92 93 96 for (Iterator webComponents = 97 webBundleDesc.getWebComponentDescriptorsSet().iterator(); 98 webComponents.hasNext();) { 99 WebComponentDescriptor webCompDesc = 100 (WebComponentDescriptor)webComponents.next(); 101 if (webCompDesc.isServlet()) { 102 addScanClassName(webCompDesc.getWebComponentImplementation()); 103 } 104 } 105 106 Vector servletFilters = webBundleDesc.getServletFilters(); 107 for (int i = 0; i < servletFilters.size(); i++) { 108 ServletFilter filter = (ServletFilter)servletFilters.elementAt(i); 109 addScanClassName(filter.getClassName()); 110 } 111 112 Vector listeners = webBundleDesc.getAppListenerDescriptors(); 113 for (int j = 0; j < listeners.size(); j++) { 114 AppListenerDescriptor listenerDesc = 115 (AppListenerDescriptor) listeners.elementAt(j); 116 addScanClassName(listenerDesc.getListener()); 117 } 118 } 119 } 120 121 | Popular Tags |