Class ApplicationContextUtils

java.lang.Object
io.microsphere.spring.context.ApplicationContextUtils
All Implemented Interfaces:
io.microsphere.util.Utils

public abstract class ApplicationContextUtils extends Object implements io.microsphere.util.Utils
ApplicationContext Utilities
Since:
1.0.0
Author:
Mercy
  • Field Details

    • APPLICATION_CONTEXT_AWARE_PROCESSOR_CLASS_NAME

      public static final String APPLICATION_CONTEXT_AWARE_PROCESSOR_CLASS_NAME
      The ApplicationContextAwareProcessor Class Name (Internal).
      See Also:
    • APPLICATION_CONTEXT_AWARE_PROCESSOR_CLASS

      @Nullable public static final Class<?> APPLICATION_CONTEXT_AWARE_PROCESSOR_CLASS
      The ApplicationContextAwareProcessor Class (Internal).
      See Also:
      • ApplicationContextAwareProcessor
  • Method Details

    • asConfigurableApplicationContext

      public static org.springframework.context.ConfigurableApplicationContext asConfigurableApplicationContext(org.springframework.context.ApplicationContext context)
      Casts the given ApplicationContext to a ConfigurableApplicationContext if possible.

      Example Usage

      
         GenericApplicationContext context = new GenericApplicationContext();
         ConfigurableApplicationContext configurableContext = asConfigurableApplicationContext(context);
         assertSame(context, configurableContext);
       
      Parameters:
      context - the ApplicationContext to cast
      Returns:
      the ConfigurableApplicationContext, or null if the cast is not possible
    • asConfigurableApplicationContext

      public static org.springframework.context.ConfigurableApplicationContext asConfigurableApplicationContext(Object object)
      Casts the given object to a ConfigurableApplicationContext if possible.

      Example Usage

      
         ResourceLoader resourceLoader = context; // context is a GenericApplicationContext
         ConfigurableApplicationContext configurableContext =
             asConfigurableApplicationContext(resourceLoader);
         assertSame(context, configurableContext);
       
      Parameters:
      object - the object to cast
      Returns:
      the ConfigurableApplicationContext, or null if the cast is not possible
    • asApplicationContext

      public static org.springframework.context.ApplicationContext asApplicationContext(org.springframework.beans.factory.BeanFactory beanFactory)
      Casts the given BeanFactory to an ApplicationContext if possible.

      Example Usage

      
         GenericApplicationContext context = new GenericApplicationContext();
         ApplicationContext applicationContext = asApplicationContext(context);
         assertSame(context, applicationContext);
       
      Parameters:
      beanFactory - the BeanFactory to cast
      Returns:
      the ApplicationContext, or null if the cast is not possible
    • getApplicationContextAwareProcessor

      @Nonnull public static org.springframework.beans.factory.config.BeanPostProcessor getApplicationContextAwareProcessor(org.springframework.context.ConfigurableApplicationContext context)
      Get the ApplicationContextAwareProcessor
      Returns:
      the ApplicationContextAwareProcessor
    • getApplicationContextAwareProcessor

      @Nullable public static org.springframework.beans.factory.config.BeanPostProcessor getApplicationContextAwareProcessor(org.springframework.beans.factory.BeanFactory beanFactory)
      Get the ApplicationContextAwareProcessor
      Returns:
      the ApplicationContextAwareProcessor
    • isApplicationContextAwareProcessor

      public static boolean isApplicationContextAwareProcessor(Object instance)
      Is the specified BeanPostProcessor is ApplicationContextAwareProcessor
      Parameters:
      instance - the specified BeanPostProcessor
      Returns:
      if the specified BeanPostProcessor is ApplicationContextAwareProcessor, return true, or false