Package org.reflections

Examples of org.reflections.Reflections


    // To search entity packages from other jar files..
    emf.setPackagesToScan("empty");
    emf.setPersistenceUnitPostProcessors(new PersistenceUnitPostProcessor() {
      @Override
      public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {
        Reflections reflections = new Reflections(ControllerConstants.DEFAULT_PACKAGE_NAME);
        for (Class<?> each : reflections.getTypesAnnotatedWith(Entity.class)) {
          LOGGER.trace("Entity class {} is detected as the SpringData entity.", each.getName());
          pui.addManagedClassName(each.getName());
        }
      }
    });


   * @param modules     module factory
   * @param packageName the package name from which scan is done.
   */
  @SuppressWarnings("rawtypes")
  protected void initPluginDescriptor(DefaultModuleDescriptorFactory modules, String packageName) {
    final Reflections reflections = new Reflections(packageName);
    Set<Class<? extends AbstractModuleDescriptor>> pluginDescriptors = reflections
        .getSubTypesOf(AbstractModuleDescriptor.class);

    for (Class<? extends AbstractModuleDescriptor> pluginDescriptor : pluginDescriptors) {
      PluginDescriptor pluginDescriptorAnnotation = pluginDescriptor.getAnnotation(PluginDescriptor.class);
      if (pluginDescriptorAnnotation == null) {

    }

    private void registerAllPersistenceCapables() {

        for (final String packagePrefix : Splitter.on(",").split(packagePrefixes)) {
            Reflections reflections = new Reflections(packagePrefix);
           
            Set<Class<?>> entityTypes =
                    reflections.getTypesAnnotatedWith(PersistenceCapable.class);
           
            if(noEntitiesIn(entityTypes)) {
                throw new IllegalStateException("Could not locate any @PersistenceCapable entities in package " + packagePrefix);
            }
            for (Class<?> entityType : entityTypes) {

        Set<URL> packagesToScan = getPackagesToScanForRoutes();
        builder.addUrls(packagesToScan);

        builder.addScanners(new MethodAnnotationsScanner());
        Reflections reflections = new Reflections(builder);

        // collect the allowed annotated methods
        Map<Class<?>, Set<String>> controllers = Maps.newHashMap();
        List<Method> methods = Lists.newArrayList();
        for (Method method : reflections.getMethodsAnnotatedWith(Path.class)) {

            if (allowMethod(method)) {

                // add the method to our todo list
                methods.add(method);

       
        Set<URL> packagesToScan = getPackagesToScanForRoutes(ninjaProperties);
        builder.addUrls(packagesToScan);
       
        builder.addScanners(new MethodAnnotationsScanner());
        Reflections reflections = new Reflections(builder);

        Set<Method> methods = reflections.getMethodsAnnotatedWith(Route.class);

        logger.info("Generating {} routes.", methods.size());

        for (Method method: methods) {
           

        return getReflections().getConfiguration().getUrls();
    }

    private Reflections getReflections() {
        if (reflections == null) {
            reflections = new Reflections(packagePrefix);
        }
        return reflections;
    }

  private void useTransformerScanPackageNames(Injector parentInjector)
      throws MojoExecutionException, InstantiationException,
      IllegalAccessException {
    for (String packageName : transformerScanPackageNames) {
      Reflections reflections = new Reflections(packageName);
      Set<Class<? extends Transformer>> transformers = reflections
          .getSubTypesOf(Transformer.class);
      Set<Class<? extends AbstractModule>> guiceModules = reflections
          .getSubTypesOf(AbstractModule.class);

      for (Class<? extends Transformer> transformerClazz : transformers) {
        logger.info("Start the transformation with following Transformer: "
            + transformerClazz.getName());

        if (filterBuilder != null) {
            configurationBuilder.filterInputsBy(filterBuilder);
        }

        Reflections reflections = new Reflections(configurationBuilder);

        Set<Class<?>> entityClasses = reflections.getTypesAnnotatedWith(CEntity.class, true);
        Set<Class<?>> mapEntityClasses = reflections.getTypesAnnotatedWith(CMapEntity.class, true);
        Set<Class<?>> compositeClasses = reflections.getTypesAnnotatedWith(CComposite.class, true);

        for (Class<?> compositeClass : compositeClasses) {
            model.addComposite(compositeClass);
        }
        for (Class<?> entityClass : entityClasses) {

    return map;
  }

  private static Reflections getReflections() {
    if (REFLECTIONS == null) {
      REFLECTIONS = new Reflections(new ConfigurationBuilder().setUrls(getMarkedPaths()).setScanners(subTypeScanner, annotationsScanner, resourcesScanner));
    }
    return REFLECTIONS;
  }

                // last to use the given namespace
                myNameSpaceToScan = namespaceToScan;
            }

            if (!Strings.isNullOrEmpty(myNameSpaceToScan)) {
                final Reflections reflections = new Reflections(new ConfigurationBuilder().filterInputsBy(
                            new FilterBuilder.Include(FilterBuilder.prefix(myNameSpaceToScan))).setUrls(
                            ClasspathHelper.forPackage(myNameSpaceToScan)).setScanners(new TypeAnnotationsScanner()
                                .filterResultsBy(filter)));
                final Set<Class<?>> typesAnnotatedWith = reflections.getTypesAnnotatedWith(
                        GlobalValueTransformer.class);
                for (final Class<?> foundGlobalValueTransformer : typesAnnotatedWith) {
                    final Class<?> valueTransformerReturnType = ValueTransformerUtils.getUnmarshalFromDbClass(
                            foundGlobalValueTransformer);
                    if (valueTransformerReturnType != null) {

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.