org.jgroups.util.Util.recurse()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.jgroups.util.Util.recurse()方法的一些代码示例,展示了Util.recurse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.recurse()方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:recurse

Util.recurse介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public static List<Class<?>> findClassesAnnotatedWith(String packageName,Class<? extends Annotation> a) throws IOException, ClassNotFoundException {
  List<Class<?>> classes=new ArrayList<>();
  recurse(classes,packageName,a);
  return classes;
}

代码示例来源:origin: wildfly/wildfly

private static void recurse(List<Class<?>> classes,String packageName,Class<? extends Annotation> a) throws ClassNotFoundException {
  ClassLoader loader=Thread.currentThread().getContextClassLoader();
  String path=packageName.replace('.','/');
  URL resource=loader.getResource(path);
  if(resource != null) {
    String filePath=resource.getFile();
    if(filePath != null && new File(filePath).isDirectory()) {
      for(String file : new File(filePath).list()) {
        if(file.endsWith(".class")) {
          String name=packageName + '.' + file.substring(0,file.indexOf(".class"));
          Class<?> clazz=Class.forName(name);
          if(clazz.isAnnotationPresent(a))
            classes.add(clazz);
        }
        else if(new File(filePath,file).isDirectory()) {
          recurse(classes,packageName + "." + file,a);
        }
      }
    }
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static List<Class<?>> findClassesAnnotatedWith(String packageName,Class<? extends Annotation> a) throws IOException, ClassNotFoundException {
  List<Class<?>> classes=new ArrayList<>();
  recurse(classes,packageName,a);
  return classes;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

private static void recurse(List<Class<?>> classes,String packageName,Class<? extends Annotation> a) throws ClassNotFoundException {
  ClassLoader loader=Thread.currentThread().getContextClassLoader();
  String path=packageName.replace('.','/');
  URL resource=loader.getResource(path);
  if(resource != null) {
    String filePath=resource.getFile();
    if(filePath != null && new File(filePath).isDirectory()) {
      for(String file : new File(filePath).list()) {
        if(file.endsWith(".class")) {
          String name=packageName + '.' + file.substring(0,file.indexOf(".class"));
          Class<?> clazz=Class.forName(name);
          if(clazz.isAnnotationPresent(a))
            classes.add(clazz);
        }
        else if(new File(filePath,file).isDirectory()) {
          recurse(classes,packageName + "." + file,a);
        }
      }
    }
  }
}

相关文章

Util类方法