Package org.reflections

Examples of org.reflections.Reflections


        this.pluginSuffix = pluginSuffix;

        this.plugins = new ArrayList<Class<? extends PluginType>>();
        this.interfaces = new ArrayList<Class<? extends PluginType>>();

        Reflections reflections;
        if (classpath == null) {
            reflections = defaultReflections;
        } else {
            addClasspath(classpath);
            reflections = new Reflections( new ConfigurationBuilder()
                .setUrls(classpath)
                .setScanners(new SubTypesScanner()));
        }

        // Load all classes types filtering them by concrete.
        @SuppressWarnings("unchecked")
        Set<Class<? extends PluginType>> allTypes = reflections.getSubTypesOf(pluginType);
        for( Class<? extends PluginType> type: allTypes ) {
            // The plugin manager does not support anonymous classes; to be a plugin, a class must have a name.
            if(JVMUtils.isAnonymous(type))
                continue;


  public int managedBeansCount() {
    return managedBeans.size();
  }
 
  public void loadManagedBeans(String path) {
    Reflections reflections = new Reflections(path);
    this.loadManagedBeans(reflections.getTypesAnnotatedWith(com.khs.sherpa.annotation.Endpoint.class));
  }

    servletContextEvent.getServletContext().log("Loading Sherpa Context... Finished");
  }

  private void setupInitializer(ApplicationContext applicationContext) {
    Set<Class<?>> initialized = new HashSet<Class<?>>();
    Reflections reflections = new Reflections("com.khs.sherpa");
      for(Class<? extends SherpaInitializer> clazz : reflections.getSubTypesOf(SherpaInitializer.class)) {
        // skip the Initializer if its been loaded
        if(initialized.contains(clazz)) {
          LOGGER.warn("Initializer [" + clazz + "] is already loaded. Skipping.....");
          continue;
        }

    }

    public Map<String, ApiListing> createApiListings() {
        Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
        for (String controllerPackage : controllerPackages) {
            Reflections reflections = new Reflections(controllerPackage);
            controllerClasses.addAll(reflections.getTypesAnnotatedWith(Controller.class));
            try {
                controllerClasses.addAll(reflections.getTypesAnnotatedWith(RestController.class));
            } catch (NoClassDefFoundError  e) {
                //Check for NoClassDefFoundError in the case that this is being used in a Spring 3 project where the RestController does not exist.
                LOGGER.debug("No RestController found.  RestController is found in Spring 4.  This is potentially an earlier version of Spring", e);
            }
        }

* </pre>
* */
public class XmlSerializer implements Serializer {

    public Reflections read(InputStream inputStream) {
        Reflections reflections = new Reflections(new ConfigurationBuilder());

        Document document;
        try {
            document = new SAXReader().read(inputStream);
        } catch (DocumentException e) {
            throw new RuntimeException(e);
        }
        for (Object e1 : document.getRootElement().elements()) {
            Element index = (Element) e1;
            for (Object e2 : index.elements()) {
                Element entry = (Element) e2;
                Element key = entry.element("key");
                Element values = entry.element("values");
                for (Object o3 : values.elements()) {
                    Element value = (Element) o3;
                    reflections.getStore().getOrCreate(index.getName()).put(key.getText(), value.getText());
                }
            }
        }

        return reflections;

    assertThat(widgets().size()).isGreaterThan(23);
  }

  private Set<Class<? extends CoreWidget>> widgetClasses() {
    String[] packages = {"org.sonar.plugins.core.widgets", "org.sonar.plugins.core.widgets.issues"};
    return new Reflections(packages).getSubTypesOf(CoreWidget.class);
  }

     */
    public static Class<? extends ITest>[] getClasses() {
        if (1 != 1) {
            return new Class[]{BooleanTest.class};
        }
        Reflections reflections = new Reflections(new ConfigurationBuilder()
                .filterInputsBy(new FilterBuilder().includePackage("be.pw999.jape.tests.impl"))
                .setUrls(ClasspathHelper.forPackage("be.pw999.jape.tests.impl"))
                .setScanners(new SubTypesScanner())
        );
        Set<Class<? extends ITest>> allClasses = reflections.getSubTypesOf(ITest.class);
        Set<Class<? extends ITest>> classes = new HashSet<Class<? extends ITest>>();
        for (Class<? extends ITest> clazz : allClasses) {
            if ((clazz.getModifiers() & Modifier.ABSTRACT) == 0) {
                classes.add(clazz);
            }

    if (name.charAt(dot + 1) == '*') {
      List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
      classLoadersList.add(ClasspathHelper.contextClassLoader());
      classLoadersList.add(ClasspathHelper.staticClassLoader());
     
      Reflections reflections = new Reflections(new ConfigurationBuilder().setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner())
          .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]))).filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix(name.substring(0, dot)))));
      Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
      for (Class<?> clazz : classes) {
        name = clazz.getName();
        dot = name.lastIndexOf('.');
        imports.put(name.substring(dot + 1), name);
      }

public class StageScanner {
 
  public List<Class<?>> getClasses(List<URL> jars) {
    ClassLoader cl = new URLClassLoader(jars.toArray(new URL[jars.size()]));
   
    Reflections reflections = new Reflections(jars, cl);
    return getClasses(reflections);
  }

    return StringUtils.join(list, "\\\\ \\\\ ");
  }
 
  public static void main(String[] args) {
    StageScanner ss = new StageScanner();
    List<Class<?>> classes = ss.getClasses(new Reflections("com.findwise"));
    printWikiTable(classes);
  }

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.