예제 #1
0
 static void loadTraceProperties() {
   // The following section is new
   // Load and apply the JDBC Server Trace value.
   String value = SystemProperties.getProperty(SystemProperties.TRACE_JDBC_SERVER);
   if (value != null) {
     try {
       JDBCServerTraceCategories_ = (new Integer(value)).intValue();
     } catch (Exception e) {
       if (JDTrace.isTraceOn())
         JDTrace.logInformation(
             "ServerTrace", "Value " + value + " for JDBCServerTrace is not valid.");
     }
   }
 }
예제 #2
0
 // Returns the maximum number of seconds to wait for a list to be built.
 private static int getMaxWaitTime() {
   int listWaitTimeout = DEFAULT_MAX_WAIT_TIME;
   String propVal = SystemProperties.getProperty(SystemProperties.LIST_WAIT_TIMEOUT);
   if (propVal != null) {
     try {
       listWaitTimeout = Integer.parseInt(propVal);
       if (listWaitTimeout == 0) listWaitTimeout = Integer.MAX_VALUE; // '0' means "no limit"
     } catch (Exception e) {
       if (Trace.traceOn_)
         Trace.log(Trace.WARNING, "Error retrieving listWaitTimeout property value:", e);
     }
   }
   return listWaitTimeout;
 }
  /**
   * See if the location of ${findbugs.home} can be inferred from the location of findbugs.jar in
   * the classpath.
   *
   * @return inferred ${findbugs.home}, or null if we can't figure it out
   */
  private static String inferFindBugsHome() {
    Pattern[] findbugsJarNames = {
      Pattern.compile("findbugs\\.jar$"),
    };

    for (Pattern jarNamePattern : findbugsJarNames) {
      String findbugsJarCodeBase =
          ClassPathUtil.findCodeBaseInClassPath(
              jarNamePattern, SystemProperties.getProperty("java.class.path"));
      if (findbugsJarCodeBase != null) {
        File findbugsJar = new File(findbugsJarCodeBase);
        File libDir = findbugsJar.getParentFile();
        if ("lib".equals(libDir.getName())) {
          String fbHome = libDir.getParent();
          FindBugs.setHome(fbHome);
          return fbHome;
        }
      }
    }
    String classFilePath = FindBugs.class.getName().replaceAll("\\.", "/") + ".class";
    URL resource = FindBugs.class.getClassLoader().getResource(classFilePath);
    if (resource != null && "file".equals(resource.getProtocol())) {
      try {
        String classfile = URLDecoder.decode(resource.getPath(), Charset.defaultCharset().name());
        Matcher m = Pattern.compile("(.*)/.*?/edu/umd.*").matcher(classfile);
        if (m.matches()) {
          String home = m.group(1);
          if (new File(home + "/etc/findbugs.xml").exists()) {
            FindBugs.setHome(home);
            return home;
          }
        }
      } catch (UnsupportedEncodingException e) {
      }
    }
    return null;
  }