new Reflections( new AbstractConfiguration() { { setFilter(new FilterBuilder().include("your project's common package prefix here...")); setUrls(ClasspathHelper.getUrlsForCurrentClasspath()); setScanners(new SubTypesScanner(), new ClassAnnotationsScanner().filterBy(myClassAnnotationsFilter)); )); } });and than use the convenient methods to query the metadata, such as {@link #getSubTypesOf}, {@link #getTypesAnnotatedWith}, {@link #getMethodsAnnotatedWith}
another usage of Reflections is to collect pre saved metadata xml, using {@link #collect()} and {@link #collect(String,com.google.common.base.Predicate)}. in order to save a Reflections instance metadata use {@link #save(String)}
new Reflections( new ConfigurationBuilder() .filterInputsBy(new FilterBuilder().include("your project's common package prefix here...")) .setUrls(ClasspathHelper.forClassLoader()) .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner().filterResultsBy(myClassAnnotationsFilter)));and than use the convenient methods to query the metadata, such as {@link #getSubTypesOf}, {@link #getTypesAnnotatedWith}, {@link #getMethodsAnnotatedWith}, {@link #getFieldsAnnotatedWith}, {@link #getResources}
in order to save a metadata use {@link #save(String)} or {@link #save(String,org.jboss.errai.reflections.serializers.Serializer)}for example with {@link org.jboss.errai.reflections.serializers.XmlSerializer} or {@link org.jboss.errai.reflections.serializers.JavaCodeSerializer}
in order to collect pre saved metadata and avoid re-scanning, use {@link #collect(String,com.google.common.base.Predicate)}
* be aware that when using the constructor new Reflections("my.package"), only urls with prefix 'my.package' will be scanned, and any transitive classes in other urls will not be scanned (for example if my.package.SomeClass extends other.package.OtherClass, than the later will not be scanned). in that case specify the urls manually using {@link ConfigurationBuilder}
For Javadoc, source code, and more information about Reflections Library, see http://code.google.com/p/reflections/
new Reflections( new ConfigurationBuilder() .filterInputsBy(new FilterBuilder().include("your project's common package prefix here...")) .setUrls(ClasspathHelper.forClassLoader()) .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()));and than use the convenient methods to query the metadata, such as {@link #getSubTypesOf}, {@link #getTypesAnnotatedWith}, {@link #getMethodsAnnotatedWith}, {@link #getFieldsAnnotatedWith}, {@link #getResources}
in order to save a metadata use {@link #save(String)} or {@link #save(String,org.reflections.serializers.Serializer)}for example with {@link org.reflections.serializers.XmlSerializer} or {@link org.reflections.serializers.JavaCodeSerializer}
in order to collect pre saved metadata and avoid re-scanning, use {@link #collect(String,com.google.common.base.Predicate,org.reflections.serializers.Serializer)}}
* be aware that when using the constructor new Reflections("my.package"), only urls with prefix 'my.package' will be scanned, and any transitive classes in other urls will not be scanned (for example if my.package.SomeClass extends other.package.OtherClass, than the later will not be scanned). in that case use the other constructors and specify the relevant packages/urls
For Javadoc, source code, and more information about Reflections Library, see http://code.google.com/p/reflections/
|
|
|
|