コード例 #1
0
  protected void load(ZipFile zipfile) throws IOException {
    Enumeration entries = zipfile.entries();
    while (entries.hasMoreElements()) {
      ZipEntry entry = (ZipEntry) entries.nextElement();

      fireBeginFile(entry.getName());

      Logger.getLogger(getClass())
          .debug("Starting file " + entry.getName() + " (" + entry.getSize() + " bytes)");

      byte[] bytes = null;
      InputStream in = null;
      try {
        in = zipfile.getInputStream(entry);
        bytes = readBytes(in);
      } finally {
        if (in != null) {
          try {
            in.close();
          } catch (IOException ex) {
            // Ignore
          }
        }
      }

      Logger.getLogger(getClass())
          .debug("Passing up file " + entry.getName() + " (" + bytes.length + " bytes)");
      getLoader().load(entry.getName(), new ByteArrayInputStream(bytes));

      fireEndFile(entry.getName());
    }
  }
コード例 #2
0
  /** {@inheritDoc} */
  @Override
  protected void setUp() throws Exception {
    Logger root = Logger.getRootLogger();

    for (Enumeration appenders = root.getAllAppenders(); appenders.hasMoreElements(); ) {
      if (appenders.nextElement() instanceof GridLog4jRollingFileAppender) return;
    }

    appender = createAppender();

    root.addAppender(appender);
  }
コード例 #3
0
  /**
   * Updates the configuration from the filter config.
   *
   * @param filterConfig
   */
  @SuppressWarnings("unchecked")
  public void updateConfigration(FilterConfig filterConfig) {
    Enumeration<String> paramEnum = filterConfig.getInitParameterNames();
    while (paramEnum.hasMoreElements()) {
      String paramName = paramEnum.nextElement();
      if (paramName.startsWith("r")) {
        try {
          if (!runOptions.containsKey(paramName)) throw new Exception("Invalid Parameter Name");
          runOptions.put(paramName, Boolean.parseBoolean(filterConfig.getInitParameter(paramName)));
        } catch (Exception e) {
          log.warn("Init Parameter [" + paramName + "] is invalid or could not be set.", e);
        }
      } else if (paramName.startsWith("b")) {
        try {
          if (!batchOptions.containsKey(paramName)) throw new Exception("Invalid Parameter Name");
          batchOptions.put(paramName, Integer.parseInt(filterConfig.getInitParameter(paramName)));
        } catch (Exception e) {
          log.warn("Init Parameter [" + paramName + "] is invalid or could not be set.", e);
        }
      } else if (paramName.startsWith("p")) {
        try {
          if (!parameterNames.containsKey(paramName)) throw new Exception("Invalid Parameter Name");
          parameterNames.put(paramName, filterConfig.getInitParameter(paramName));
        } catch (Exception e) {
          log.warn("Init Parameter [" + paramName + "] is invalid or could not be set.", e);
        }
      } else if ("listenerClassName".equals(paramName)) {
        listenerClassName = filterConfig.getInitParameter(paramName);
      } else if ("agentLogLevel".equals(paramName)) {
        try {
          agentLogLevel = Integer.parseInt(filterConfig.getInitParameter(paramName));
        } catch (Exception e) {
          log.warn("Agent Log Level Could Not Be Set. Defaulting to [" + agentLogLevel + "].", e);
        }

      } else {
        log.warn("Init Parameter [" + paramName + "] was not recognized.");
      }
    }
    log.info("Completed AjaxMetrics Filter Configuration. Config is:\n" + toString());
    inited = true;
  }