Package org.reflections.util

Examples of org.reflections.util.ConfigurationBuilder


/** */
public class ReflectionsParallelTest extends ReflectionsTest {

    @BeforeClass
    public static void init() {
        reflections = new Reflections(new ConfigurationBuilder()
                .setUrls(asList(ClasspathHelper.forClass(TestModel.class)))
                .filterInputsBy(TestModelFilter)
                .setScanners(
                        new SubTypesScanner(false),
                        new TypeAnnotationsScanner(),
View Full Code Here


/** */
public class ReflectionsCollectTest extends ReflectionsTest {

    @BeforeClass
    public static void init() {
        Reflections ref = new Reflections(new ConfigurationBuilder()
                .addUrls(ClasspathHelper.forClass(TestModel.class))
                .filterInputsBy(TestModelFilter)
                .setScanners(
                        new SubTypesScanner(false),
                        new TypeAnnotationsScanner(),
                        new MethodAnnotationsScanner(),
                        new MethodParameterNamesScanner(),
                        new MemberUsageScanner()));

        ref.save(getUserDir() + "/target/test-classes" + "/META-INF/reflections/testModel-reflections.xml");

        ref = new Reflections(new ConfigurationBuilder()
                .setUrls(asList(ClasspathHelper.forClass(TestModel.class)))
                .filterInputsBy(TestModelFilter)
                .setScanners(
                        new MethodParameterScanner()));

View Full Code Here

    }

    @Test
    public void testResourcesScanner() {
        Predicate<String> filter = new FilterBuilder().include(".*\\.xml").include(".*\\.json");
        Reflections reflections = new Reflections(new ConfigurationBuilder()
                .filterInputsBy(filter)
                .setScanners(new ResourcesScanner())
                .setUrls(asList(ClasspathHelper.forClass(TestModel.class))));

        Set<String> resolved = reflections.getResources(Pattern.compile(".*resource1-reflections\\.xml"));
 
View Full Code Here

        try {
            Constructor<Reflections> constructor = Reflections.class.getDeclaredConstructor();
            constructor.setAccessible(true);
            reflections = constructor.newInstance();
        } catch (Exception e) {
            reflections = new Reflections(new ConfigurationBuilder());
        }

        try {
            Document document = new SAXReader().read(inputStream);
            for (Object e1 : document.getRootElement().elements()) {
View Full Code Here

        Predicate<String> filter = new FilterBuilder().includePackage(
                Constants.DISCONF_PACK_NAME).includePackage(packName);

        //
        Reflections reflections = new Reflections(new ConfigurationBuilder()
                .filterInputsBy(filter)
                .setScanners(new SubTypesScanner().filterResultsBy(filter),
                        new TypeAnnotationsScanner().filterResultsBy(filter),
                        new FieldAnnotationsScanner().filterResultsBy(filter),
                        new MethodAnnotationsScanner().filterResultsBy(filter),
View Full Code Here

    }
  }

  private static Configuration getConfig(String prefix) {
   
    ConfigurationBuilder config = new ConfigurationBuilder();
   
    if (prefix != null) {
      config.filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(prefix )));
      config.setUrls(ClasspathHelper.forPackage(prefix));
    } else {
      config.setUrls(ClasspathHelper.forJavaClassPath());
    }
   
    return config.setScanners(new SubTypesScanner());
  }
View Full Code Here

    Predicate<String> localPredicate = predicate;
    if (localPredicate == null) {
      localPredicate = Predicates.alwaysTrue();
    }
    Assert.parametersNotNull("m, predicate", m, localPredicate);
    final ConfigurationBuilder conf = new ConfigurationBuilder();
    conf.setScanners(new TypesScanner(), new TypeAnnotationsScanner());

    final Set<URL> s = new HashSet<URL>();
    s.addAll(ClasspathHelper.forClassLoader());
    s.addAll(Arrays.asList(ClasspathUrlFinder.findClassPaths()));
    final Iterator<URL> iterator = s.iterator();
    while (iterator.hasNext()) {
      final URL url = iterator.next();
      if (url.getPath().endsWith("jnilib")) {
        iterator.remove();
      }
    }
    conf.setUrls(new ArrayList<URL>(s));

    conf.filterInputsBy(localPredicate);

    final Reflections r = new Reflections(conf);

    final Set<Class<?>> entities = r.getTypesAnnotatedWith(Entity.class);
    for (final Class<?> c : entities) {
View Full Code Here

            }
    );

    MetaDataScanner(List<URL> urls) {

        configuration = new ConfigurationBuilder()
                .setUrls(urls)
                        //.filterInputsBy(new FilterBuilder().exclude(CLIENT_PKG_REGEX))
                .setScanners(
                        //new FieldAnnotationsScanner(),
                        //new MethodAnnotationsScanner(),
View Full Code Here

    }

    public static List<RestxSpec> findSpecsIn(String location) throws IOException {
        RestxSpecLoader loader = new RestxSpecLoader(Factory.getInstance());

        Set<String> specResources = new ConfigurationBuilder()
                .setUrls(ClasspathHelper.forPackage(location))
                .setScanners(new ResourcesScanner())
                .filterInputsBy(new FilterBuilder().includePackage(location.replace('/','.')))
                .build()
                .getResources(Pattern.compile(".*\\.spec\\.yaml"));
 
View Full Code Here

                }
            }
        }

        // now we search for real resources, but avoid duplicates, especially for the one found in sources
        for (String r : new ConfigurationBuilder()
                        .setUrls(ClasspathHelper.forPackage(packageName))
                        .setScanners(new ResourcesScanner())
                        .build()
                        .getResources(p)) {
            if (!resourcesUrls.containsKey(r) && r.startsWith(packageName.replace('.', '/'))) {
View Full Code Here

TOP

Related Classes of org.reflections.util.ConfigurationBuilder

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.