Setup:
- Add the Maven repository which contains the dependency to your Nexus repository if you have one or else add it POM file.
- Add the Maven dependency to your POM file. GAV=(org.reflections,reflections,0.9.5-RC2)
- Depending on your needs, configure an instance of the Reflections class as outlined in the Docs.
Once setup, there are several handy methods on the Reflections class, one of which serves this exact purpose.
reflections.getTypesAnnotatedWith(SomeAnnotation.class);
I tried using a convenience constructor rather than the full blown constructor for Reflections since the javadoc on the convenience constructor seemed to be sufficient for my needs but that didn't behave as expected.
Convenience constructor
Reflections(final String prefix, final Scanner... scanners)
And since all I needed was a TypeAnnotationsScanner and the convenience constructor above seemed to add it by default, I was hoping to use the constructor without passing any scanners.
No comments:
Post a Comment