Extremely fast, lightweight annotation scanner for the classpath, classloader, or files for Java 6+
Go to file
nathan 0605b9e433 Cleaned up readmes
Updated readme

Changed DelayTimer to use Runnable
2015-12-15 01:13:02 +01:00
src/dorkbox/util/annotation Added intellij support. Compiled as java6 2015-06-28 00:07:01 +02:00
.classpath Updated build/classpath to have slf4j in libs dir 2015-02-02 13:02:24 +01:00
.gitignore Initial import of annotations project 2015-02-02 12:54:51 +01:00
.project Initial import of annotations project 2015-02-02 12:54:51 +01:00
Annotations.iml updated project info 2015-08-23 02:41:07 +02:00
LICENSE Initial import of annotations project 2015-02-02 12:54:51 +01:00
LICENSE.Apachev2 Initial import of annotations project 2015-02-02 12:54:51 +01:00
LICENSE.MIT Initial import of annotations project 2015-02-02 12:54:51 +01:00
README.md Cleaned up readmes 2015-12-15 01:13:02 +01:00

Annotations

The Annotations project is based on, and almost identical to the excellent infomas AnnotationDetector.

There are major changes to the API to provide for a way to easily extend the scanning functionality, hence it lives here on it's own.

This library can be used to scan (part of) the class path for annotated classes, methods or instance variables. Main advantages of this library compared with similar solutions are: light weight (simple API, 20 kb jar file) and very fast (fastest annotation detection library as far as I know).

The main features of this annotations scanning library:

  • scans the bytecode for annotation information, meaning classes do not have to be loaded by the JVM

  • small footprint

  • extremely fast performance (on moderate hardware, about 200 MB/s)!

  • can scan the classpath, classloader, or specified location

  • uses the SLF4j logging interface

  • simple builder style API

  • lightweight

  • This is for cross-platform use, specifically - linux 32/64, mac 32/64, and windows 32/64. Java 6+

We now release to maven!

There are two dependencies here because we did not want to bake-in a hard dependency into the POM file for the utilities library, which are an extremely small subset of a much larger library; including only what is necessary for this particular project to function.

This project is kept in sync with the utilities library, so "jar hell" is not an issue. Please note that the util library (in it's entirety) is not added since there are many dependencies that are not necessary for this project. No reason to require a massive amount of dependencies for one or two classes/methods.

<dependency>
  <groupId>com.dorkbox</groupId>
  <artifactId>Annotations</artifactId>
  <version>1.2</version>
</dependency>

Or if you don't want to use Maven, you can access the files directly here: https://oss.sonatype.org/content/repositories/releases/com/dorkbox/Annotations/ https://oss.sonatype.org/content/repositories/releases/com/dorkbox/Annotations-Dorkbox-Util/

try {
    // Get a list of all classes annotated with @Module, inside the "dorkbox.client" and "dorkbox.common" packages.
    List<Module> classModules = AnnotationDetector.scanClassPath("dorkbox.client", "dorkbox.common")
                                     .forAnnotations(Module.class)  // one or more annotations
                                     .on(ElementType.METHOD) // optional, default ElementType.TYPE. One ore more element types
                                     .filter((File dir, String name) -> !name.endsWith("Client.class")) // optional, default all *.class files
                                     .collect(AnnotationDefaults.getType);
} catch (IOException e) {
    throw new IllegalArgumentException("Unable to start the client", e);
}