All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.digitolio.jdbi.codegen.Scanner Maven / Gradle / Ivy

package com.digitolio.jdbi.codegen;

import org.reflections.Reflections;
import org.reflections.scanners.ResourcesScanner;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
 * @author C.Koc
 */
public class Scanner {
    public Set> scanPackage(String inputPackage) {

        List classLoadersList = new LinkedList();
        classLoadersList.add(ClasspathHelper.contextClassLoader());
        classLoadersList.add(ClasspathHelper.staticClassLoader());

        ConfigurationBuilder configuration = new ConfigurationBuilder()
                .setScanners(new SubTypesScanner(false), new ResourcesScanner())
                .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[classLoadersList.size()])))
                .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(inputPackage)));

        Reflections reflections = new Reflections(configuration);

        return reflections.getSubTypesOf(Object.class);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy