コード例 #1
0
  private static String[] findStandardMBeans(URL codeBase) throws Exception {
    Set<String> names;
    if (codeBase.getProtocol().equalsIgnoreCase("file") && codeBase.toString().endsWith("/"))
      names = findStandardMBeansFromDir(codeBase);
    else names = findStandardMBeansFromJar(codeBase);

    Set<String> standardMBeanNames = new TreeSet<String>();
    for (String name : names) {
      if (name.endsWith("MBean")) {
        String prefix = name.substring(0, name.length() - 5);
        if (names.contains(prefix)) standardMBeanNames.add(prefix);
      }
    }
    return standardMBeanNames.toArray(new String[0]);
  }
コード例 #2
0
 private static Set<String> findStandardMBeansFromDir(URL codeBase) throws Exception {
   File dir = new File(new URI(codeBase.toString()));
   Set<String> names = new TreeSet<String>();
   scanDir(dir, "", names);
   return names;
 }