Package com.google.common.reflect

Examples of com.google.common.reflect.ClassPath$Scanner


  private ArrayList<Class> blockClasses = new ArrayList<Class>();
  private HashMap<Class, ArrayList<Block>> blockRegistry = new HashMap<Class, ArrayList<Block>>();

  public void registerClasses() {
    try {
      ClassPath classPath = ClassPath.from(this.getClass().getClassLoader());
      for (ClassPath.ClassInfo classInfo : classPath.getTopLevelClassesRecursive("thaumic.tinkerer.common.block")) {
        if (ITTinkererBlock.class.isAssignableFrom(classInfo.load()) && !Modifier.isAbstract(classInfo.load().getModifiers())) {
          blockClasses.add(classInfo.load());
        }
      }
      for (ClassPath.ClassInfo classInfo : classPath.getTopLevelClassesRecursive("thaumic.tinkerer.common.item")) {
        if (ITTinkererItem.class.isAssignableFrom(classInfo.load()) && !ItemBlock.class.isAssignableFrom(classInfo.load()) && !Modifier.isAbstract(classInfo.load().getModifiers())) {
          itemClasses.add(classInfo.load());
        }
      }
View Full Code Here


     *
     * @param keyFilterPredicate
     * @return
     */
    public Map<String, VersionInfo> build(Predicate<String> keyFilterPredicate) {
      ClassPath cp;
      try {
        cp = ClassPath.from(VersionInfo.class.getClassLoader());
      } catch (IOException e) {
        logger.warn("Unable to fetch versioning information from classpath ! {}", e);
        return Collections.emptyMap();
      }
      Iterable<ResourceInfo> pomPropFiles = Iterables.filter(cp.getResources().asList(),
          new Predicate<ResourceInfo>() {
            @Override
            public boolean apply(ResourceInfo input) {
              if (input.getResourceName().contains("pom.properties")) {
                Matcher m = groupIdArtifact.matcher(input.getResourceName());
View Full Code Here

    PackageContainer res = new PackageContainer();
    res.setName(packagetoParse);
    List<AnnotatedClass> classes = res.getClasses();
    Set<Class<?>> packClasses = new HashSet<Class<?>>();
    try {
      ClassPath classpath = ClassPath.from(Thread.currentThread()
          .getContextClassLoader()); // scans the class path used by
                        // classloader
      for (ClassPath.ClassInfo classInfo : classpath
          .getTopLevelClassesRecursive(packagetoParse)) {
        packClasses.add(classInfo.load());
      }
      for (Class<?> c : packClasses) {
        log.debug("Parsing class {}", c.getName());
View Full Code Here

     * @return
     * @throws java.io.IOException
     */
    @VisibleForTesting
    static Set<ClassPath.ClassInfo> findControllers(String controllerPackage, final Set<String> controllerSuffixes) throws IOException {
        ClassPath classPath = ClassPath.from(Thread.currentThread().getContextClassLoader());

        Set<ClassPath.ClassInfo> allClasses = classPath.getTopLevelClassesRecursive(controllerPackage);
        Set<ClassPath.ClassInfo> controllers = Sets.filter(allClasses, new Predicate<ClassPath.ClassInfo>() {
            @Override
            public boolean apply(ClassPath.ClassInfo classInfo) {
                for (String controllerSuffix : controllerSuffixes) {
                    // 判断是否是指定后缀结束
View Full Code Here

     * @return
     * @throws java.io.IOException
     */
    @VisibleForTesting
    static Set<ClassPath.ClassInfo> findControllers(String controllerPackage, final Set<String> controllerSuffixes) throws IOException {
        ClassPath classPath = ClassPath.from(Thread.currentThread().getContextClassLoader());

        Set<ClassPath.ClassInfo> allClasses = classPath.getTopLevelClassesRecursive(controllerPackage);
        Set<ClassPath.ClassInfo> controllers = Sets.filter(allClasses, new Predicate<ClassPath.ClassInfo>() {
            @Override
            public boolean apply(ClassPath.ClassInfo classInfo) {
                for (String controllerSuffix : controllerSuffixes) {
                    // 判断是否是指定后缀结束
View Full Code Here

     * @return
     * @throws java.io.IOException
     */
    @VisibleForTesting
    public static Set<ClassPath.ClassInfo> findControllers(String controllerPackage, final Set<String> controllerSuffixes) throws IOException {
        ClassPath classPath = ClassPath.from(Thread.currentThread().getContextClassLoader());

        Set<ClassPath.ClassInfo> allClasses = classPath.getTopLevelClassesRecursive(controllerPackage);
        Set<ClassPath.ClassInfo> controllers = Sets.filter(allClasses, new Predicate<ClassPath.ClassInfo>() {
            @Override
            public boolean apply(ClassPath.ClassInfo classInfo) {
                for (String controllerSuffix : controllerSuffixes) {
                    // 判断是否是指定后缀结束
View Full Code Here

        return classes;       
    }

    private Set<ClassInfo> getTopLevelClassesRecursive() {
        try {
            ClassPath cp = ClassPath.from(cl);
            Set<ClassInfo> classInfoSet = cp.getTopLevelClassesRecursive(basePackage);
            return classInfoSet;
        } catch (IOException io) {
            throw Throwables.propagate(io);
        }
    }
View Full Code Here

     * @return
     * @throws java.io.IOException
     */
    @VisibleForTesting
    static Set<ClassPath.ClassInfo> findControllers(String controllerPackage, final Set<String> controllerSuffixes) throws IOException {
        ClassPath classPath = ClassPath.from(Thread.currentThread().getContextClassLoader());

        Set<ClassPath.ClassInfo> allClasses = classPath.getTopLevelClassesRecursive(controllerPackage);
        Set<ClassPath.ClassInfo> controllers = Sets.filter(allClasses, new Predicate<ClassPath.ClassInfo>() {
            @Override
            public boolean apply(ClassPath.ClassInfo classInfo) {
                for (String controllerSuffix : controllerSuffixes) {
                    // 判断是否是指定后缀结束
View Full Code Here

TOP

Related Classes of com.google.common.reflect.ClassPath$Scanner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.