Class RootAutowireLoader

java.lang.Object
de.bytestore.hostinger.RootAutowireLoader
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Component("rootAutowireLoader") @Order(-2147483648) public class RootAutowireLoader extends Object implements org.springframework.context.ApplicationContextAware
RootAutowireLoader is a utility class that provides access to Spring beans managed by the Spring Application Context. This class is marked as a Spring Component, allowing it to be automatically detected through classpath scanning. Implements ApplicationContextAware to gain awareness of the ApplicationContext and provide a static method to fetch beans by their class type.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    getBean(Class<T> beanClass)
    Retrieves a bean from the Spring Application Context based on its class type.
    void
    onApplicationContextRefreshed(org.springframework.context.event.ContextRefreshedEvent event)
    Handles the ContextRefreshedEvent triggered when the Spring ApplicationContext has been refreshed.
    void
    onApplicationStarted(org.springframework.boot.context.event.ApplicationStartedEvent event)
    Handles the ApplicationStartedEvent triggered when the Spring application context has been fully refreshed and the application has started.
    void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
    Sets the ApplicationContext that this object runs in.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RootAutowireLoader

      public RootAutowireLoader()
  • Method Details

    • onApplicationStarted

      @EventListener @Order(-2147483648) public void onApplicationStarted(org.springframework.boot.context.event.ApplicationStartedEvent event)
      Handles the ApplicationStartedEvent triggered when the Spring application context has been fully refreshed and the application has started.
      Parameters:
      event - the event indicating that the application has started, containing the ApplicationContext and other initialization details
    • onApplicationContextRefreshed

      @EventListener @Order(-2147483648) public void onApplicationContextRefreshed(org.springframework.context.event.ContextRefreshedEvent event)
      Handles the ContextRefreshedEvent triggered when the Spring ApplicationContext has been refreshed. This method updates the static application context reference with the refreshed ApplicationContext, which can be used to fetch beans or perform additional context-dependent operations.
      Parameters:
      event - the event indicating that the ApplicationContext has been refreshed, providing access to the refreshed ApplicationContext
    • setApplicationContext

      @Order(-2147483648) public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Sets the ApplicationContext that this object runs in.
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Parameters:
      applicationContext - the ApplicationContext object to be used by this class, must not be null
      Throws:
      org.springframework.beans.BeansException - if context is not set properly
    • getBean

      public static <T> T getBean(Class<T> beanClass)
      Retrieves a bean from the Spring Application Context based on its class type.
      Type Parameters:
      T - the type of the bean to retrieve
      Parameters:
      beanClass - the class object of the bean to retrieve
      Returns:
      the bean instance of the specified type