Class AdapterSpringContextProvider

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

    @Component
    @Scope("singleton")
    public class AdapterSpringContextProvider
    extends Object
    implements org.springframework.context.ApplicationContextAware
    This class provides access to spring beans for classes not managed by Spring IOC container.
    • Constructor Detail

      • AdapterSpringContextProvider

        public AdapterSpringContextProvider()
    • Method Detail

      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
      • getBean

        public static <T> T getBean​(Class<T> beanClass)
        Get a Spring bean by type.
        Type Parameters:
        T - the type of the bean class
        Parameters:
        beanClass - the class of the bean
        Returns:
        the bean
      • getBean

        public static Object getBean​(String beanName)
        Get a Spring bean by name.
        Parameters:
        beanName - the name of the bean
        Returns:
        the bean