FileDocCategorySizeDatePackage
WarScanner.javaAPI DocGlassfish v2 API5434Fri May 04 22:31:34 BST 2007com.sun.enterprise.deployment.annotation.impl

WarScanner

public class WarScanner extends ModuleScanner
Implementation of the Scanner interface for war.
author
Shing Wai Chan

Fields Summary
Constructors Summary
public WarScanner(File archiveFile, com.sun.enterprise.deployment.WebBundleDescriptor webBundleDesc)

        this(archiveFile, webBundleDesc, null);
    
public WarScanner(File archiveFile, com.sun.enterprise.deployment.WebBundleDescriptor webBundleDesc, ClassLoader classLoader)
This scanner will scan the archiveFile for annotation processing.

param
archiveFile
param
webBundleDesc
param
classLoader

        if (AnnotationUtils.getLogger().isLoggable(Level.FINE)) {
            AnnotationUtils.getLogger().fine("archiveFile is " + archiveFile);
            AnnotationUtils.getLogger().fine("webBundle is " + webBundleDesc);
            AnnotationUtils.getLogger().fine("classLoader is " + classLoader);
        }
        this.archiveFile = archiveFile;
        this.classLoader = classLoader;

        if (!archiveFile.isDirectory()) {
            // on client side
            return;
        }

        File webinf = new File(archiveFile, "WEB-INF");
        File classes = new File(webinf, "classes");
        if (classes.exists()) {
            addScanDirectory(classes);   
        }
        File lib = new File(webinf, "lib");
        if (lib.exists()) {
            File[] jarFiles = lib.listFiles(new FileFilter() {
                 public boolean accept(File pathname) {
                     return (pathname.isFile() &&
                            pathname.getAbsolutePath().endsWith(".jar"));
                 }
            });

            if (jarFiles != null && jarFiles.length > 0) {
                for (File jarFile : jarFiles) {
                    addScanJar(jarFile);
                }
            }
        }

        // always add servlet, filter, listener that are defined in web.xml
        // regardless of they have annotation or not
       
        for (Iterator webComponents = 
            webBundleDesc.getWebComponentDescriptorsSet().iterator(); 
            webComponents.hasNext();) {
            WebComponentDescriptor webCompDesc = 
                (WebComponentDescriptor)webComponents.next();
            if (webCompDesc.isServlet()) {
                addScanClassName(webCompDesc.getWebComponentImplementation());
            }
        }

        Vector servletFilters = webBundleDesc.getServletFilters();
        for (int i = 0; i < servletFilters.size(); i++) {
            ServletFilter filter = (ServletFilter)servletFilters.elementAt(i);
            addScanClassName(filter.getClassName());
        }

        Vector listeners = webBundleDesc.getAppListenerDescriptors();
        for (int j = 0; j < listeners.size(); j++) {
            AppListenerDescriptor listenerDesc =
                (AppListenerDescriptor) listeners.elementAt(j);
            addScanClassName(listenerDesc.getListener());
        }
    
Methods Summary