tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util ExtensionValidator.java LocalStrings.properties
Date Mon, 05 Apr 2004 20:32:34 GMT
remm        2004/04/05 13:32:34

  Modified:    catalina/src/share/org/apache/catalina/util
                        ExtensionValidator.java LocalStrings.properties
  Log:
  - Refactor the Extension validator without using a singleton pattern (since all
    the methods are static, and getInstance never gets called inside Tomcat).
    This fixes a NPE I ran into.
  
  Revision  Changes    Path
  1.10      +22 -24    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/ExtensionValidator.java
  
  Index: ExtensionValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/ExtensionValidator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ExtensionValidator.java	27 Feb 2004 14:58:50 -0000	1.9
  +++ ExtensionValidator.java	5 Apr 2004 20:32:34 -0000	1.10
  @@ -62,28 +62,23 @@
       private static StringManager sm =
           StringManager.getManager("org.apache.catalina.util");
       
  -    private static ExtensionValidator validator = null;
       private static HashMap containerAvailableExtensions = null;
       private static ArrayList containerManifestResources = null;
       private static ResourceBundle messages = null;
   
   
  -    // ----------------------------------------------------------- Constructors
  +    // ----------------------------------------------------- Static Initializer
   
   
       /**
  -     *  Access to this class can only be made through the factory method
  -     *  getInstance()
  -     *
  -     *  This private constructor loads the container level extensions that are
  +     *  This static initializer loads the container level extensions that are
        *  available to all web applications. This method scans all extension 
        *  directories available via the "java.ext.dirs" System property. 
        *
        *  The System Class-Path is also scanned for jar files that may contain 
  -     *  available extensions. The system extensions are loaded only the 
  -     *  first time an instance of the ExtensionValidator is created.
  +     *  available extensions.
        */
  -    private ExtensionValidator() throws IOException {
  +    static {
   
           // check for container level optional packages
           String systemClasspath = System.getProperty("java.class.path");
  @@ -97,7 +92,12 @@
               if (classpathItem.toLowerCase().endsWith(".jar")) {
                   File item = new File(classpathItem);
                   if (item.exists()) {
  -                    addSystemResource(item);
  +                    try {
  +                        addSystemResource(item);
  +                    } catch (IOException e) {
  +                        log.error(sm.getString
  +                                  ("extensionValidator.failload", item), e);
  +                    }
                   }
               }
           }
  @@ -115,11 +115,18 @@
                   File[] files = targetDir.listFiles();
                   for (int i = 0; i < files.length; i++) {
                       if (files[i].getName().toLowerCase().endsWith(".jar")) {
  -                        addSystemResource(files[i]);
  +                        try {
  +                            addSystemResource(files[i]);
  +                        } catch (IOException e) {
  +                            log.error
  +                                (sm.getString
  +                                 ("extensionValidator.failload", files[i]), e);
  +                        }
                       }
                   }
               }
           }
  +
       }
   
   
  @@ -214,19 +221,10 @@
   
           return validateManifestResources(appName, appManifestResources);
       }
  -    
  -    /**
  -     * Return an instance of the ExtensionValidator. 
  -     * The ExtensionValidator is a singleton.
  -     */
  -    public static ExtensionValidator getInstance() throws IOException {
  -        if (validator == null) {
  -            validator = new ExtensionValidator();
  -        }
  -        return validator;
  -    }
  -    
  +
  +
       // -------------------------------------------------------- Private Methods
  +
   
       /**
        * Validates a <code>ArrayList</code> of <code>ManifestResource</code>

  
  
  
  1.5       +1 -0      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/LocalStrings.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LocalStrings.properties	24 Sep 2002 15:52:39 -0000	1.4
  +++ LocalStrings.properties	5 Apr 2004 20:32:34 -0000	1.5
  @@ -6,5 +6,6 @@
   extensionValidator.web-application-manifest=Web Application Manifest
   extensionValidator.extension-not-found-error=ExtensionValidator[{0}][{1}]: Required extension
"{2}" not found.
   extensionValidator.extension-validation-error=ExtensionValidator[{0}]: Failure to find
{1} required extension(s).
  +extensionValidator.failload=Failure loading extension {0}
   SecurityUtil.doAsPrivilege=An exception occurs when running the PrivilegedExceptionAction
block.
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message