Class CachedAnnotationScanner


  • public class CachedAnnotationScanner
    extends Object
    This classes provides a list of static methods delegating annotation scanning to AnnotationScanner and caching its results. A cache entry for each combination of packagePrefix and ClassLoader will be created. Calling this class for non-bounded sets of combinations will cause memory issues. Please be therefore aware of what you're doing when using this class
    • Constructor Detail

      • CachedAnnotationScanner

        public CachedAnnotationScanner()
    • Method Detail

      • getClassesWithAnnotation

        public static Set<Class<?>> getClassesWithAnnotation​(Class<? extends Annotation> annotationClass)
        Parameters:
        annotationClass -
        Returns:
        a set of classes annotated by the provided annotation in the current context class loader. Warning: Results of this methods are cached. See Class comments for more details
      • getClassesWithAnnotation

        public static Set<Class<?>> getClassesWithAnnotation​(Class<? extends Annotation> annotationClass,
                                                             ClassLoader classloader)
        Parameters:
        annotationClass -
        classloader -
        Returns:
        a set of classes annotated by the provided annotation in the provided class loader. Warning: Results of this methods are cached. See Class comments for more details
      • getClassesWithAnnotation

        public static Set<Class<?>> getClassesWithAnnotation​(String packagePrefix,
                                                             Class<? extends Annotation> annotationClass,
                                                             ClassLoader classloader)
        Parameters:
        packagePrefix -
        annotationClass -
        classloader -
        Returns:
        a set of classes annotated by the provided annotation in the provided class loader and within the provided package. Warning: Results of this methods are cached. See Class comments for more details
      • getMethodsWithAnnotation

        public static Set<Method> getMethodsWithAnnotation​(Class<? extends Annotation> annotationClass)
        Parameters:
        annotationClass -
        Returns:
        a set of methods annotated by the provided annotation in the current context class loader. Warning: Results of this methods are cached. See Class comments for more details
      • getMethodsWithAnnotation

        public static Set<Method> getMethodsWithAnnotation​(Class<? extends Annotation> annotationClass,
                                                           ClassLoader classloader)
        Parameters:
        annotationClass -
        classloader -
        Returns:
        a set of methods annotated by the provided annotation in the provided class loader. Warning: Results of this methods are cached. See Class comments for more details
      • getMethodsWithAnnotation

        public static Set<Method> getMethodsWithAnnotation​(String packagePrefix,
                                                           Class<? extends Annotation> annotationClass,
                                                           ClassLoader classloader)
        Parameters:
        packagePrefix -
        annotationClass -
        classloader -
        Returns:
        a set of classes annotated by the provided annotation in the provided class loader and within the provided package. Warning: Results of this methods are cached. See Class comments for more details
      • clearCache

        public static void clearCache()