Exemple #1
0
  /**
   * Print out report of .jars found in a classpath.
   *
   * <p>Takes the information encoded from a checkPathForJars() call and dumps it out to our
   * PrintWriter.
   *
   * @param v Vector of Hashtables of .jar file info
   * @param desc description to print out in header
   * @return false if OK, true if any .jars were reported as having errors
   * @see #checkPathForJars(String, String[])
   */
  protected boolean logFoundJars(Vector v, String desc) {

    if ((null == v) || (v.size() < 1)) return false;

    boolean errors = false;

    logMsg("#---- BEGIN Listing XML-related jars in: " + desc + " ----");

    for (int i = 0; i < v.size(); i++) {
      Hashtable subhash = (Hashtable) v.elementAt(i);

      for (Enumeration keys = subhash.keys(); keys.hasMoreElements();
      /* no increment portion */
      ) {
        Object key = keys.nextElement();
        String keyStr = (String) key;
        try {
          if (keyStr.startsWith(ERROR)) {
            errors = true;
          }
          logMsg(keyStr + "=" + subhash.get(keyStr));

        } catch (Exception e) {
          errors = true;
          logMsg("Reading-" + key + "= threw: " + e.toString());
        }
      }
    }

    logMsg("#----- END Listing XML-related jars in: " + desc + " -----");

    return errors;
  }
Exemple #2
0
  /**
   * Programmatic entrypoint: Report on basic Java environment and CLASSPATH settings that affect
   * Xalan.
   *
   * <p>Note that this class is not advanced enough to tell you everything about the environment
   * that affects Xalan, and sometimes reports errors that will not actually affect Xalan's
   * behavior. Currently, it very simplistically checks the JVM's environment for some basic
   * properties and logs them out; it will report a problem if it finds a setting or .jar file that
   * is <i>likely</i> to cause problems.
   *
   * <p>Advanced users can peruse the code herein to help them investigate potential environment
   * problems found; other users may simply send the output from this tool along with any bugs they
   * submit to help us in the debugging process.
   *
   * @param pw PrintWriter to send output to; can be sent to a file that will look similar to a
   *     Properties file; defaults to System.out if null
   * @return true if your environment appears to have no major problems; false if potential
   *     environment problems found
   * @see #getEnvironmentHash()
   */
  public boolean checkEnvironment(PrintWriter pw) {

    // Use user-specified output writer if non-null
    if (null != pw) outWriter = pw;

    // Setup a hash to store various environment information in
    Hashtable hash = getEnvironmentHash();

    // Check for ERROR keys in the hashtable, and print report
    boolean environmentHasErrors = writeEnvironmentReport(hash);

    if (environmentHasErrors) {
      // Note: many logMsg calls have # at the start to
      //  fake a property-file like output
      logMsg("# WARNING: Potential problems found in your environment!");
      logMsg("#    Check any 'ERROR' items above against the Xalan FAQs");
      logMsg("#    to correct potential problems with your classes/jars");
      logMsg("#    http://xml.apache.org/xalan-j/faq.html");
      if (null != outWriter) outWriter.flush();
      return false;
    } else {
      logMsg("# YAHOO! Your environment seems to be OK.");
      if (null != outWriter) outWriter.flush();
      return true;
    }
  }
Exemple #3
0
  /**
   * Dump a basic Xalan environment report to outWriter.
   *
   * <p>This dumps a simple header and then each of the entries in the Hashtable to our PrintWriter;
   * it does special processing for entries that are .jars found in the classpath.
   *
   * @param h Hashtable of items to report on; presumably filled in by our various check*() methods
   * @return true if your environment appears to have no major problems; false if potential
   *     environment problems found
   * @see #appendEnvironmentReport(Node, Document, Hashtable) for an equivalent that appends to a
   *     Node instead
   */
  protected boolean writeEnvironmentReport(Hashtable h) {

    if (null == h) {
      logMsg("# ERROR: writeEnvironmentReport called with null Hashtable");
      return false;
    }

    boolean errors = false;

    logMsg("#---- BEGIN writeEnvironmentReport($Revision: #1 $): Useful stuff found: ----");

    // Fake the Properties-like output
    for (Enumeration keys = h.keys(); keys.hasMoreElements();
    /* no increment portion */
    ) {
      Object key = keys.nextElement();
      String keyStr = (String) key;
      try {
        // Special processing for classes found..
        if (keyStr.startsWith(FOUNDCLASSES)) {
          Vector v = (Vector) h.get(keyStr);
          errors |= logFoundJars(v, keyStr);
        }
        // ..normal processing for all other entries
        else {
          // Note: we could just check for the ERROR key by itself,
          //    since we now set that, but since we have to go
          //    through the whole hash anyway, do it this way,
          //    which is safer for maintenance
          if (keyStr.startsWith(ERROR)) {
            errors = true;
          }
          logMsg(keyStr + "=" + h.get(keyStr));
        }
      } catch (Exception e) {
        logMsg("Reading-" + key + "= threw: " + e.toString());
      }
    }

    logMsg("#----- END writeEnvironmentReport: Useful properties found: -----");

    return errors;
  }