Package org.reflections

Examples of org.reflections.Reflections


  }

  private static void dynamicallyBuildCommandFactoryMap()
  {
    Reflections reflections = new Reflections("edu.isi.karma");

    Set<Class<? extends CommandFactory>> subTypes =
        reflections.getSubTypesOf(CommandFactory.class);

    for (Class<? extends CommandFactory> subType : subTypes)
    {
      if(subType.getClass().getName().contains("FetchTransformingData"))
      {


        final Set<Class<?>> entities = new HashSet<Class<?>>();
        for (final String packageName : packages) {
            if (packageName.split("\\.").length < 3) {
                throw new IllegalArgumentException("The package name " + packageName + " is too short, please be more specific");
            }
            final Reflections reflections = new Reflections(packageName);
            entities.addAll(reflections.getTypesAnnotatedWith(Entity.class));
            entities.addAll(reflections.getTypesAnnotatedWith(MappedSuperclass.class));
        }
        return entities;
    }

      filterBuilder.include(FilterBuilder.prefix(basePkg));
    }

    cfgBldr.filterInputsBy(filterBuilder).setScanners(
        new SubTypesScanner(), new TypeAnnotationsScanner());
    this.reflections = new Reflections(cfgBldr);
  }

  @Provides
  private EventHubHandler getEventHubHandler(Injector injector, EventHub eventHub)
      throws ClassNotFoundException {
    Map<String, Provider<Command>> commandsMap = Maps.newHashMap();
    Reflections reflections = new Reflections(PACKAGE_NAME);
    Set<Class<? extends Command>> commandClasses = reflections.getSubTypesOf(Command.class);
    for (Class<? extends Command> commandClass : commandClasses) {
      String path = commandClass.getAnnotation(Path.class).value();
      //noinspection unchecked
      commandsMap.put(path, (Provider<Command>) injector.getProvider(commandClass));
    }

        }
    }

    // Gets all classes with some annotation from a package
    public static Set<Class<?>> getClassesWithAnnotation(Class<? extends Annotation> annotation, String[] packageNames) {
        Reflections reflections;
        Set<Class<?>> classes = new HashSet<Class<?>>();
        for (String packageName : packageNames) {
            reflections = new Reflections(packageName);
            classes.addAll(reflections.getTypesAnnotatedWith(annotation));
        }
        return classes;
    }

      });
      super.run(notifier);
    }
    private static Class<?>[] findClasses() {
      Reflections reflections = new Reflections("org.zkoss.test.zss.cases");
      Set<Class<?>> testCases = reflections.getTypesAnnotatedWith(ZSSTestCase.class);
      return testCases.toArray(new Class[testCases.size()]);
    }

        System.out.println("Starting command scan...");

        vault = new HashMap<String, Class<? extends Command>>();

        Reflections reflections = new Reflections("net.eldiosantos");

        Set<Class<? extends Command>> subTypes = reflections
            .getSubTypesOf(Command.class);

        for (Class<? extends Command> c : subTypes) {
          if (!Modifier.isAbstract(c.getModifiers())) {
            addClass(c);

        s.addAll(Arrays.asList(ClasspathUrlFinder.findClassPaths()));
        conf.setUrls(new ArrayList(s));

        conf.filterInputsBy(predicate);

        final Reflections r = new Reflections(conf);

        final Set<Class<?>> entities = r.getTypesAnnotatedWith(Entity.class);
        for (final Class<?> c : entities) {
            m.map(c);
        }
    }

        .forClassLoader())) {
      if (url.toString().toLowerCase().endsWith(".jar")) {
        urls.add(url);
      }
    }
    this.reflections = new Reflections(new ConfigurationBuilder()
        .setScanners(new TypeAnnotationsScanner())
        .setUrls(ClasspathHelper.forPackage("")).addUrls(urls));
  }

    mapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
    mapper.disable(SerializationFeature.CLOSE_CLOSEABLE);
    mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

    Reflections reflections = new Reflections("com.twitter.ambrose");
    Set<Class<? extends Job>> jobSubTypes = reflections.getSubTypesOf(Job.class);
    mapper.registerSubtypes(jobSubTypes.toArray(new Class<?>[jobSubTypes.size()]));
    return mapper;
  }

TOP

Related Classes of org.reflections.Reflections

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.