예제 #1
0
  public static void main(String[] args) throws Exception {
    String input_file = null;
    XmlConfigurator conf;
    boolean old_format = false;

    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-old")) {
        old_format = true;
        continue;
      }
      if (args[i].equals("-file")) {
        input_file = args[++i];
        continue;
      }
      help();
      return;
    }

    if (input_file != null) {
      InputStream input = null;

      try {
        input = new FileInputStream(new File(input_file));
      } catch (Throwable t) {
      }
      if (input == null) {
        try {
          input = new URL(input_file).openStream();
        } catch (Throwable t) {
        }
      }

      if (input == null)
        input = Thread.currentThread().getContextClassLoader().getResourceAsStream(input_file);

      if (old_format) {
        String cfg = inputAsString(input);
        List<ProtocolConfiguration> tmp = Configurator.parseConfigurations(cfg);
        System.out.println(dump(tmp));
      } else {
        conf = XmlConfigurator.getInstance(input);
        String tmp = conf.getProtocolStackString();
        System.out.println("\n" + tmp);
      }
    } else {
      log.error("no input file given");
    }
  }
예제 #2
0
 private static ProtocolStackConfigurator load(String resource) throws IllegalStateException {
   URL url = find(resource, JGroupsExtension.class.getClassLoader());
   ROOT_LOGGER.debugf("Loading JGroups protocol defaults from %s", url.toString());
   try {
     return XmlConfigurator.getInstance(url);
   } catch (IOException e) {
     throw new IllegalArgumentException(JGroupsLogger.ROOT_LOGGER.parserFailure(url));
   }
 }