Class ClassPathBeanDefinitionScannerAgent


  • public class ClassPathBeanDefinitionScannerAgent
    extends java.lang.Object
    Registers
    Author:
    Jiri Bubnik
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean reloadFlag
      Flag to check reload status.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void defineBean​(org.springframework.beans.factory.config.BeanDefinition candidate)
      Resolve candidate to a bean definition and (re)load in Spring.
      static ClassPathBeanDefinitionScannerAgent getInstance​(java.lang.String basePackage)
      Find scanner agent by base package.
      static ClassPathBeanDefinitionScannerAgent getInstance​(org.springframework.context.annotation.ClassPathBeanDefinitionScanner scanner)
      Return an agent instance for a scanner.
      static void refreshClass​(java.lang.String basePackage, byte[] classDefinition)
      Called by a reflection command from SpringPlugin transformer.
      void registerBasePackage​(java.lang.String basePackage)
      Initialize base package from ClassPathBeanDefinitionScanner.scan() (hooked by a Transformer)
      org.springframework.beans.factory.config.BeanDefinition resolveBeanDefinition​(byte[] bytes)
      Resolve bean definition from class definition if applicable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • reloadFlag

        public static boolean reloadFlag
        Flag to check reload status. In unit test we need to wait for reload finish before the test can continue. Set flag to true in the test class and wait until the flag is false again.
    • Method Detail

      • getInstance

        public static ClassPathBeanDefinitionScannerAgent getInstance​(org.springframework.context.annotation.ClassPathBeanDefinitionScanner scanner)
        Return an agent instance for a scanner. If the instance does not exists yet, it is created.
        Parameters:
        scanner - the scanner
        Returns:
        agent instance
      • getInstance

        public static ClassPathBeanDefinitionScannerAgent getInstance​(java.lang.String basePackage)
        Find scanner agent by base package.
        Parameters:
        basePackage - the scanner agent or null if no such agent exists
        Returns:
        the agent
      • registerBasePackage

        public void registerBasePackage​(java.lang.String basePackage)
        Initialize base package from ClassPathBeanDefinitionScanner.scan() (hooked by a Transformer)
        Parameters:
        basePackage - package that Spring will scan
      • refreshClass

        public static void refreshClass​(java.lang.String basePackage,
                                        byte[] classDefinition)
                                 throws java.io.IOException
        Called by a reflection command from SpringPlugin transformer.
        Parameters:
        basePackage - base package on witch the transformer was registered, used to obtain associated scanner.
        classDefinition - new class definition
        Throws:
        java.io.IOException - error working with classDefinition
      • defineBean

        public void defineBean​(org.springframework.beans.factory.config.BeanDefinition candidate)
        Resolve candidate to a bean definition and (re)load in Spring. Synchronize to avoid parallel bean definition - usually on reload the beans are interrelated and parallel load will cause concurrent modification exception.
        Parameters:
        candidate - the candidate to reload
      • resolveBeanDefinition

        public org.springframework.beans.factory.config.BeanDefinition resolveBeanDefinition​(byte[] bytes)
                                                                                      throws java.io.IOException
        Resolve bean definition from class definition if applicable.
        Parameters:
        bytes - class definition.
        Returns:
        the definition or null if not a spring bean
        Throws:
        java.io.IOException