Skip to content

hierynomus/scannit

Repository files navigation

Scannit: An (extensible) Java metadata scanner

Scannit is an extensible Java metadata scanner inspired upon scannotation and reflections. It currently contains scanners which scan the classpath for:

  • Class level annotations
  • Field level annotations
  • Method level annotations
  • Sub/Supertype hierarchy

Technology

Scannit relies on some libraries to provide services, these are:

  • Javassist: For the bytecode reading of classfiles
  • Truezip: For the scanning of the classpath and traversing through jars as though they're a filesystem
  • Guava: For the collections API

Usage

Configuration config = Configuration.config()
    .with(new SubTypeScanner(), new TypeAnnotationScanner())
    .scan("foo.bar");
Scannit scannit = new Scannit(config);
Set<Class<?>> clazzes = scannit.getTypesAnnotatedWith(MyAnnotation.class);
Set<Class<?>> subClazzes = scannit.getSubTypesOf(ParentClass.class);

Extension

Extending Scannit is pretty easy, you can write a new Scanner by extending nl.javadude.scannit.scanner.AbstractScanner and implementing void doScan(ClassFile file, Registry registry).