Class ClassScanner


  • public class ClassScanner
    extends Object
    A helper class to scan classes on the classpath
    • Constructor Detail

      • ClassScanner

        public ClassScanner​(ClassLoader... classLoaders)
    • Method Detail

      • clearCache

        public void clearCache()
      • setClassLoaderProvider

        public void setClassLoaderProvider​(String id,
                                           ClassLoaderProvider classLoaderProvider)
        Registers a named class loader provider or removes it if the classLoaderProvider is null
      • findClassNames

        public SortedSet<String> findClassNames​(String search,
                                                Integer limit)
        Searches for the available class names given the text search
        Returns:
        all the class names found on the current classpath using the given text search filter
      • findClassNamesMethodsAnnotatedWith

        public SortedSet<String> findClassNamesMethodsAnnotatedWith​(String annotationClassName)
      • findClassNamesInDirectoryWithMethodAnnotatedWith

        public SortedSet<String> findClassNamesInDirectoryWithMethodAnnotatedWith​(File dir,
                                                                                  String annotationClassName)
      • addClassNamesInDirectoryWithMethodsAnnotatedWith

        protected void addClassNamesInDirectoryWithMethodsAnnotatedWith​(SortedSet<String> answer,
                                                                        File dir,
                                                                        Class<? extends Annotation> annotationClass,
                                                                        String packageName)
      • optionallyFindAnnotationClass

        protected Class<? extends Annotation> optionallyFindAnnotationClass​(String annotationClassName)
      • getAllClassesMap

        public SortedMap<String,​Class<?>> getAllClassesMap()
        Returns all the classes found in a sorted map
      • getClassesMap

        public SortedMap<String,​Class<?>> getClassesMap​(Package... packages)
        Returns all the classes found in a sorted map for the given list of packages
      • optionallyFindClass

        public Class<?> optionallyFindClass​(String className)
        Returns the given class or null if it cannot be loaded
      • optionallyFindClasses

        public List<Class<?>> optionallyFindClasses​(Iterable<String> classNames)
        Tries to find as many of the class names on the class loaders as possible and return them
      • getIgnorePackages

        public Set<String> getIgnorePackages()
      • setIgnorePackages

        public void setIgnorePackages​(Set<String> ignorePackages)
      • processDirectoryClassNames

        protected void processDirectoryClassNames​(File directory,
                                                  String packageName,
                                                  Set<String> classes)
      • processJarClassNames

        protected void processJarClassNames​(ClassResource classResource,
                                            Set<String> classes)
      • getJavaResourceKey

        protected String getJavaResourceKey​(URL resource)
      • tryFindClass

        protected Class<?> tryFindClass​(String className,
                                        String filter)
      • classNameMatches

        protected boolean classNameMatches​(String className,
                                           String search)
        Returns true if the given class name matches the filter search
      • getPackageRelativePath

        protected String getPackageRelativePath​(String packageName)
      • withinLimit

        protected boolean withinLimit​(Integer limit,
                                      Collection<?> collection)
        Returns true if we are within the limit value for the number of results in the collection