Package org.reflections

Examples of org.reflections.Reflections


            return headers;
        }

        @Override
        public Enumeration findEntries(String path, String filePattern, boolean recurse) {
            Reflections reflections = new Reflections(this.packageName);
            Set<Class<?>> types = reflections.getTypesAnnotatedWith(Model.class);
            Vector<URL> urls = new Vector<URL>(); // NOPMD
            try {
                for (Class<?> type : types) {
                    urls.add(new URL("file:/" + type.getName().replace('.', '/') + ".class"));
                }


    this.notMatchingRegex = notMatchingRegex;
    return this;
  }

  private Set<Class<?>> scanTypes(String packageName) {
    Reflections reflections = new Reflections(packageName,
        new MethodAnnotationsScanner());
    Set<Class<?>> types = new HashSet<Class<?>>();
    types.addAll(typesAnnotatedWith(reflections, Given.class));
    types.addAll(typesAnnotatedWith(reflections, When.class));
    types.addAll(typesAnnotatedWith(reflections, Then.class));

        return null;
    }


    public List<RouteClass> buildClasses() {
        Reflections ref = new Reflections(sourcePackage);
        Set<Class<?>> classes = ref.getTypesAnnotatedWith(Path.class);

        List<RouteClass> routeClassList = Lists.newArrayList();

        for (Class<?> klazz : classes) {
            RouteClass routeClass = buildRouteClass(klazz);

    public Generator(String packageName, ObjectMapper mapper) {
        this.mapper = mapper;

        synchronized (lock) {
            if (reflections == null) {
                reflections = new Reflections(packageName);
            }
        }
    }

      URL url = urlIter.next();
      if(url.toString().toLowerCase().endsWith(".jar") || !url.toString().toLowerCase().contains(".")) {
        urls.add(url);
      }
    }
    Reflections ref = new Reflections(new ConfigurationBuilder().setUrls(urls));
    for(Class<?> clazz: ref.getTypesAnnotatedWith(URIHandler.class)) {
      if(PipelineModifier.class.isAssignableFrom(clazz)) {
        URIHandler uhandler = clazz.getAnnotation(URIHandler.class);
        try {
          PipelineModifier pm = (PipelineModifier)clazz.newInstance();
          String[] names = uhandler.uri();

*/
public class PeriodicalBindings extends AbstractModule {
    @Override
    protected void configure() {
        Multibinder<Periodical> periodicalBinder = Multibinder.newSetBinder(binder(), Periodical.class);
        Reflections reflections = new Reflections("org.graylog2.periodical");
        for (Class<? extends Periodical> periodicalClass : reflections.getSubTypesOf(Periodical.class))
            if (!Modifier.isAbstract(periodicalClass.getModifiers()))
                periodicalBinder.addBinding().to(periodicalClass);
    }

    private static final Logger LOG = LoggerFactory.getLogger(NodeRunner.class);

    protected static List<Module> getBindingsModules(InstantiationService instantiationService, Module... specificModules) {
        List<Module> result = Lists.newArrayList();
        result.add(new GenericBindings(instantiationService));
        Reflections reflections = new Reflections("org.graylog2.shared.bindings");
        final Set<Class<? extends AbstractModule>> generic = reflections.getSubTypesOf(AbstractModule.class);
        final Set<Class<? extends Graylog2Module>> gl2Modules = reflections.getSubTypesOf(Graylog2Module.class);
        for (Class<? extends Module> type : Iterables.concat(generic, gl2Modules)) {
            // skip the GenericBindings module, because we have already instantiated it above, avoids a bogus log message
            if (type.equals(GenericBindings.class)) {
                continue;
            }

    }

    @Override
    public void initialize(Map<String, String> config) throws InitializerConfigurationException {
        String packageName = Periodical.class.getPackage().toString();
        Reflections reflections = new Reflections("org.graylog2.shared.periodical");

        for (Class<? extends Periodical> type : reflections.getSubTypesOf(Periodical.class)) {
            try {
                Periodical periodical = instantiationService.getInstance(type);

                periodical.initialize();

public class ReflectionsClasspathScanner implements ClasspathScanner {

    @Override
    public Set<Class<? extends Initializer>> scanInitializers(List<String> packages) {
       
        Reflections reflections = new Reflections(packages.toArray());
        Set<Class<? extends Initializer>> initializers =
                reflections.getSubTypesOf(Initializer.class);
        removeNonInstantiableClasses(initializers);
        return initializers;
    }

    }

    @Override
    public Set<Class<? extends Module>> scanModules(List<String> packages) {
       
        Reflections reflections = new Reflections(packages.toArray());
        Set<Class<? extends Module>> modules = reflections.getSubTypesOf(Module.class);
        /* we have to check for AbstractModule explicitly because users may have either
         * implemented Module or sub-classed AbstractModule */
        modules.addAll(reflections.getSubTypesOf(AbstractModule.class));
       
        /* make sure the framework's module is never included in the scan results */
        modules.remove(ServletResourceModule.class);
       
        removeNonInstantiableClasses(modules);

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.