You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by cu...@apache.org on 2001/04/25 23:07:23 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xslt EnvironmentCheck.java

curcuru     01/04/25 14:07:23

  Modified:    java/src/org/apache/xalan/xslt EnvironmentCheck.java
  Log:
  Added checkDirForJars() which checks java.ext.dirs as well now
  
  Revision  Changes    Path
  1.3       +112 -17   xml-xalan/java/src/org/apache/xalan/xslt/EnvironmentCheck.java
  
  Index: EnvironmentCheck.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/EnvironmentCheck.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EnvironmentCheck.java	2001/03/22 20:04:13	1.2
  +++ EnvironmentCheck.java	2001/04/25 21:07:21	1.3
  @@ -57,6 +57,7 @@
   package org.apache.xalan.xslt;
   
   import java.io.File;
  +import java.io.FilenameFilter;
   import java.io.FileWriter;
   import java.io.PrintWriter;
   
  @@ -100,7 +101,7 @@
    * quite slow and because it forces classes to get loaded.
    * 
    * @author Shane_Curcuru@lotus.com
  - * @version $Id: EnvironmentCheck.java,v 1.2 2001/03/22 20:04:13 curcuru Exp $
  + * @version $Id: EnvironmentCheck.java,v 1.3 2001/04/25 21:07:21 curcuru Exp $
    */
   public class EnvironmentCheck
   {
  @@ -234,7 +235,7 @@
       boolean errors = false;
   
       logMsg(
  -      "#---- BEGIN writeEnvironmentReport($Revision: 1.2 $): Useful properties found: ----");
  +      "#---- BEGIN writeEnvironmentReport($Revision: 1.3 $): Useful properties found: ----");
   
       // Fake the Properties-like output
       for (Enumeration enum = h.keys(); 
  @@ -297,7 +298,9 @@
       "xerces.jar", 
       "testxsl.jar", 
       "crimson.jar", 
  -    "jaxp.jar", "parser.jar", "dom.jar", "sax.jar", "xml.jar"
  +    "jaxp.jar", "parser.jar", "dom.jar", "sax.jar", "xml.jar",
  +    /* below are .jars associated with XSLTC for now */
  +    "BCEL.jar", "java_cup.jar", "JLex.jar", "runtime.jar", "xsltc.jar"
   
       /* @todo add other jars that commonly include either
        * SAX, DOM, or JAXP interfaces in them
  @@ -310,9 +313,6 @@
      * Logs java.class.path and other likely paths; then attempts 
      * to search those paths for .jar files with Xalan-related classes.
      *
  -   * //@todo NOTE: We don't actually search java.ext.dirs for 
  -   * //  *.jar files therein! This should be updated
  -   *
      * @param h Hashtable to put information in
      * @see #jarNames
      * @see #checkPathForJars(String, String[])
  @@ -335,7 +335,7 @@
   
         // For applet context, etc.
         h.put(
  -        "java.version",
  +        ERROR + "java.version",
           "WARNING: SecurityException thrown accessing system version properties");
       }
   
  @@ -367,29 +367,23 @@
             h.put(FOUNDCLASSES + "sun.boot.class.path", classpathJars);
         }
   
  -      //@todo NOTE: We don't actually search java.ext.dirs for 
  -      //  *.jar files therein! This should be updated
         othercp = System.getProperty("java.ext.dirs");
  -
         if (null != othercp)
         {
           h.put("java.ext.dirs", othercp);
   
  -        classpathJars = checkPathForJars(othercp, jarNames);
  +        // Check the whole extensions directory for *.jar
  +        classpathJars = checkDirForJars(othercp, jarNames);
   
           if (null != classpathJars)
             h.put(FOUNDCLASSES + "java.ext.dirs", classpathJars);
         }
  -
  -      //@todo also check other System properties' paths?
  -      //  v2 = checkPathForJars(System.getProperty("sun.boot.library.path"), jarNames);   // ?? may not be needed
  -      //  v3 = checkPathForJars(System.getProperty("java.library.path"), jarNames);   // ?? may not be needed
       }
       catch (SecurityException se2)
       {
         // For applet context, etc.
         h.put(
  -        "java.version",
  +        ERROR + "java.class.path.ext.dirs",
           "WARNING: SecurityException thrown accessing system classpath properties");
       }
     }
  @@ -406,6 +400,7 @@
      * @return false if OK, true if any .jars were reported 
      * as having errors
      * @see #checkPathForJars(String, String[])
  +   * @see #checkDirForJars(String, String[])
      */
     protected boolean logFoundJars(Vector v, String desc)
     {
  @@ -466,6 +461,7 @@
      *
      * @return Vector of Hashtables filled with info about found .jars
      * @see #jarNames
  +   * @see #checkDirForJars(String, String[])
      * @see #logFoundJars(Vector, String)
      * @see #getApparentVersion(String, long)
      */
  @@ -526,6 +522,78 @@
     }
   
     /**
  +   * Cheap-o listing of specified .jars found in a directory. 
  +   *
  +   * cp should be a directory name, presumably java.ext.dirs.
  +   *
  +   * @param cp name of directory to look in for *.jar
  +   * @param jars array of .jar base filenames to look for
  +   *
  +   * @return Vector of Hashtables filled with info about found .jars
  +   * @see #jarNames
  +   * @see #checkPathForJars(String, String[])
  +   * @see #logFoundJars(Vector, String)
  +   * @see #getApparentVersion(String, long)
  +   */
  +  protected Vector checkDirForJars(String cp, String[] jars)
  +  {
  +
  +    if ((null == cp) || (null == jars) || (0 == cp.length())
  +            || (0 == jars.length))
  +      return null;
  +
  +    File extDir = new File(cp);
  +    if (!extDir.exists())
  +      return null;
  +
  +    Vector v = new Vector();
  +    String foundJars[] = extDir.list(new JarFileFilter());
  +    for (int j = 0; j < foundJars.length; j++)
  +    {
  +      // Look at each .jar entry for each of our requested jarNames
  +      String filename = foundJars[j];
  +
  +      for (int i = 0; i < jars.length; i++)
  +      {
  +        if (filename.equalsIgnoreCase(jars[i]))
  +        {
  +          File f = new File(extDir, filename);
  +
  +          if (f.exists())
  +          {
  +
  +            // If any requested jarName exists, report on 
  +            //  the details of that .jar file
  +            try
  +            {
  +              Hashtable h = new Hashtable(5);
  +
  +              //h.put(jars[i] + ".jarname", jars[i]);
  +              // h.put(jars[i] + ".lastModified", String.valueOf(f.lastModified()));
  +              h.put(jars[i] + ".path", f.getAbsolutePath());
  +              h.put(jars[i] + ".apparent.version",
  +                    getApparentVersion(jars[i], f.length()));
  +              v.addElement(h);
  +            }
  +            catch (Exception e)
  +            {
  +
  +              /* no-op, don't add it  */
  +            }
  +          }
  +          else
  +          {
  +            logMsg("# Warning: Classpath entry: " + filename
  +                   + " does not exist.");
  +          }
  +        }
  +      }
  +    }
  +
  +    return v;
  +  }
  +
  +  /**
      * Cheap-o method to determine the product version of a .jar.   
      *
      * Currently does a lookup into a local table of some recent 
  @@ -551,7 +619,7 @@
       Hashtable jarVersions = new Hashtable();
   
       // key=jarsize, value=jarname ' from ' distro name
  -    // Note assumption: two jars cannot have the same size!
  +    // Note assumption: two jars will not have the same size!
       // Note: hackish Hashtable, this could use improvement
       jarVersions.put(new Long(440237), "xalan.jar from xalan-j_1_2");
       jarVersions.put(new Long(436094), "xalan.jar from xalan-j_1_2_1");
  @@ -588,6 +656,13 @@
       jarVersions.put(new Long(136198),
                       "parser.jar from jakarta-ant-1.3 or 1.2");
   
  +    // XSLTC integration jars checked-in Apr-01
  +    jarVersions.put(new Long(320367), "BCEL.jar from XSLTC integration Apr-01");
  +    jarVersions.put(new Long(61975), "java_cup.jar from XSLTC integration Apr-01");
  +    jarVersions.put(new Long(54603), "JLex.jar from XSLTC integration Apr-01");
  +    jarVersions.put(new Long(7779), "runtime.jar from XSLTC integration Apr-01");
  +    jarVersions.put(new Long(129139), "xml.jar from XSLTC integration Apr-01");
  +
       // If we found a matching size and it's for our 
       //  jar, then return it's description
       String foundSize = (String) jarVersions.get(new Long(jarSize));
  @@ -868,4 +943,24 @@
     {
       outWriter.println(s);
     }
  +
  +  private class JarFileFilter implements FilenameFilter
  +  {
  +    /**
  +     * Returns true for *.jar files
  +     * @param dir the directory in which the file was found.
  +     * @param name the name of the file.
  +     * @return <code>true</code> if the name should be included in the file list; <code>false</code> otherwise.
  +     * @since JDK1.0
  +     */
  +    public boolean accept(File dir, String name)
  +    {
  +      // Shortcuts for bogus filenames and dirs
  +      if (name == null || dir == null)
  +        return false;
  +      return name.toLowerCase().endsWith("jar");
  +    }
  +}
  +
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org