Class SpringClassFinder


  • public class SpringClassFinder
    extends DocumentationUtility
    This utility class reads all java files in the main source tree and collects a list of spring beans. The beans defined in the configuration classes are added as well The result is listed in a hierarchical levels:
    • Maven module
    • player
    • Configuration
    • Scope
    • init method
    Author:
    Andi Hotz, (c) Sahits GmbH, 2014 Created on Mar 02, 2014
    • Field Detail

      • validAnnotations

        private java.util.List<java.lang.String> validAnnotations
      • moduleBeanDefinitionMap

        private com.google.common.collect.Multimap<java.lang.String,​BeanDefinition> moduleBeanDefinitionMap
      • configurations

        private com.google.common.collect.Multimap<java.lang.String,​ConfigurationDefinition> configurations
    • Constructor Detail

      • SpringClassFinder

        private SpringClassFinder()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • addWarnings

        private void addWarnings​(java.lang.StringBuilder sb)
      • addBeanDefinitionTable

        private void addBeanDefinitionTable​(java.lang.StringBuilder sb,
                                            EScope scope)
      • checkUnmappedBeans

        private void checkUnmappedBeans()
        Check if there are beans that are not picked up.
      • mapClasspathScanning

        private void mapClasspathScanning()
        Update the bean definitions with the instantiation reference if they are picked up by configuration definition.
      • updateClasspathScanning

        private void updateClasspathScanning​(java.lang.String confModule,
                                             ConfigurationDefinition definition,
                                             java.lang.String packageName)
        Update the bean definitions with the instantiation reference if they are picked up by definition.
        Parameters:
        confModule - maven module the configuration belongs to
        definition - configuration definition
        packageName - player name for which all beans are updated.
      • findAnnotations

        private java.util.List<java.lang.String> findAnnotations​(java.io.File file)
                                                          throws java.io.IOException
        Find all annotations in a file.
        Parameters:
        file - to check for annotations
        Returns:
        List of found annotations
        Throws:
        java.io.IOException - if file cannot be read
      • filterConfiguration

        private java.util.List<java.io.File> filterConfiguration​(java.util.List<java.io.File> javaFiles)
                                                          throws java.io.IOException
        Filter out the configuration classes
        Parameters:
        javaFiles - list of Java files
        Returns:
        List of Java files annotated with configuration
        Throws:
        java.io.IOException - if file could not be read.
      • specialHandling

        private java.lang.String specialHandling​(java.lang.String match,
                                                 java.lang.String line)
      • createBeanDefinition

        private BeanDefinition createBeanDefinition​(int length,
                                                    java.io.File javaFile,
                                                    java.util.List<java.lang.String> annotations)
      • getBeanDefinition

        private BeanDefinition getBeanDefinition​(java.util.List<java.lang.String> annotations,
                                                 java.lang.String type)
      • createConfigurationDefinition

        private ConfigurationDefinition createConfigurationDefinition​(java.io.File javaFile,
                                                                      int length)
                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • findPackages

        private java.util.Set<java.lang.String> findPackages​(java.util.Set<java.lang.String> componentClassNames,
                                                             java.util.List<java.lang.String> imports)
      • parseCoponentNames

        private java.util.Set<java.lang.String> parseCoponentNames​(java.lang.String componentScanCLOB)
      • getSubPackages

        private java.util.List<java.lang.String> getSubPackages​(java.io.File javaFile)
        Find all sub packages of a file which can be a java file or a package.
        Parameters:
        javaFile - to check
        Returns:
        List of sub package name.
      • toPackageName

        private java.lang.String toPackageName​(java.io.File subFile)