Class AnnotationScanner

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class AnnotationScanner
    extends java.lang.Object
    implements java.lang.AutoCloseable
    • Method Detail

      • forAllClassesFromContextClassLoader

        public static AnnotationScanner forAllClassesFromContextClassLoader()
        Returns:
        an instance of AnnotationScanner scanning all classes of the context class loader
      • forAllClassesFromClassLoader

        public static AnnotationScanner forAllClassesFromClassLoader​(java.lang.ClassLoader classloader)
        Parameters:
        classloader - the ClassLoader (including parents) to be scanned
        Returns:
        an instance of AnnotationScanner scanning all classes of the provided class loader
      • forAllClassesFromClassLoader

        public static AnnotationScanner forAllClassesFromClassLoader​(java.lang.String packagePrefix,
                                                                     java.lang.ClassLoader classloader)
        Parameters:
        packagePrefix - the specific package to be scanned
        classloader - the ClassLoader (including parents) to be scanned
        Returns:
        an instance of AnnotationScanner scanning all classes of the provided class loader
      • forSpecificJar

        public static AnnotationScanner forSpecificJar​(java.io.File jar)
        Parameters:
        jar - the specific jar file to be scanned
        Returns:
        an instance of AnnotationScanner scanning all classes of the provided jar file
      • forSpecificJar

        public static AnnotationScanner forSpecificJar​(java.io.File jar,
                                                       java.lang.ClassLoader classLoaderForResultClassesAndMethods)
      • forSpecificJarFromURLClassLoader

        public static AnnotationScanner forSpecificJarFromURLClassLoader​(java.net.URLClassLoader classloader)
        Scans the jar files of a specific URLClassLoader
        Parameters:
        classloader - the specific ClassLoader to scan the URLs of
        Returns:
        an instance of AnnotationScanner scanning all classes of the provided URLClassLoader (parent excluded)
      • forSpecificJarFromURLClassLoader

        public static AnnotationScanner forSpecificJarFromURLClassLoader​(java.net.URLClassLoader classloader,
                                                                         java.lang.ClassLoader classLoaderForResultClassesAndMethods)
        Scans the jar files of a specific URLClassLoader
        Parameters:
        classloader - the specific ClassLoader to scan the URLs
        classLoaderForResultClassesAndMethods - the ClassLoader containing the context
        Returns:
        an instance of AnnotationScanner scanning all classes of the provided URLClassLoader (parent excluded)
      • getClassesWithAnnotation

        public java.util.Set<java.lang.Class<?>> getClassesWithAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        Get all classes annotated by the provided Annotation
        Parameters:
        annotationClass -
        Returns:
        the Set of classes annotated by the provided Annotation
      • getMethodsWithAnnotation

        public java.util.Set<java.lang.reflect.Method> getMethodsWithAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        Get all methods annotated by the provided Annotation
        Parameters:
        annotationClass -
        Returns:
        the Set of methods annotated by the provided Annotation
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable