Package io.microsphere.spring.context
Class ApplicationContextUtils
java.lang.Object
io.microsphere.spring.context.ApplicationContextUtils
- All Implemented Interfaces:
io.microsphere.util.Utils
ApplicationContext Utilities- Since:
- 1.0.0
- Author:
- Mercy
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.context.ApplicationContextasApplicationContext(org.springframework.beans.factory.BeanFactory beanFactory) Casts the givenBeanFactoryto anApplicationContextif possible.static org.springframework.context.ConfigurableApplicationContextCasts the given object to aConfigurableApplicationContextif possible.static org.springframework.context.ConfigurableApplicationContextasConfigurableApplicationContext(org.springframework.context.ApplicationContext context) Casts the givenApplicationContextto aConfigurableApplicationContextif possible.static org.springframework.beans.factory.config.BeanPostProcessorgetApplicationContextAwareProcessor(org.springframework.beans.factory.BeanFactory beanFactory) Get theApplicationContextAwareProcessorstatic org.springframework.beans.factory.config.BeanPostProcessorgetApplicationContextAwareProcessor(org.springframework.context.ConfigurableApplicationContext context) Get theApplicationContextAwareProcessorstatic booleanisApplicationContextAwareProcessor(Object instance) Is the specifiedBeanPostProcessorisApplicationContextAwareProcessor
-
Field Details
-
APPLICATION_CONTEXT_AWARE_PROCESSOR_CLASS_NAME
TheApplicationContextAwareProcessorClass Name (Internal).- See Also:
-
ApplicationContextAwareProcessor- Constant Field Values
-
APPLICATION_CONTEXT_AWARE_PROCESSOR_CLASS
TheApplicationContextAwareProcessorClass (Internal).- See Also:
-
ApplicationContextAwareProcessor
-
-
Method Details
-
asConfigurableApplicationContext
public static org.springframework.context.ConfigurableApplicationContext asConfigurableApplicationContext(org.springframework.context.ApplicationContext context) Casts the givenApplicationContextto aConfigurableApplicationContextif possible.Example Usage
GenericApplicationContext context = new GenericApplicationContext(); ConfigurableApplicationContext configurableContext = asConfigurableApplicationContext(context); assertSame(context, configurableContext);- Parameters:
context- theApplicationContextto cast- Returns:
- the
ConfigurableApplicationContext, ornullif the cast is not possible
-
asConfigurableApplicationContext
public static org.springframework.context.ConfigurableApplicationContext asConfigurableApplicationContext(Object object) Casts the given object to aConfigurableApplicationContextif 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, ornullif the cast is not possible
-
asApplicationContext
public static org.springframework.context.ApplicationContext asApplicationContext(org.springframework.beans.factory.BeanFactory beanFactory) Casts the givenBeanFactoryto anApplicationContextif possible.Example Usage
GenericApplicationContext context = new GenericApplicationContext(); ApplicationContext applicationContext = asApplicationContext(context); assertSame(context, applicationContext);- Parameters:
beanFactory- theBeanFactoryto cast- Returns:
- the
ApplicationContext, ornullif the cast is not possible
-
getApplicationContextAwareProcessor
@Nonnull public static org.springframework.beans.factory.config.BeanPostProcessor getApplicationContextAwareProcessor(org.springframework.context.ConfigurableApplicationContext context) Get theApplicationContextAwareProcessor- Returns:
- the
ApplicationContextAwareProcessor
-
getApplicationContextAwareProcessor
@Nullable public static org.springframework.beans.factory.config.BeanPostProcessor getApplicationContextAwareProcessor(org.springframework.beans.factory.BeanFactory beanFactory) Get theApplicationContextAwareProcessor- Returns:
- the
ApplicationContextAwareProcessor
-
isApplicationContextAwareProcessor
Is the specifiedBeanPostProcessorisApplicationContextAwareProcessor- Parameters:
instance- the specifiedBeanPostProcessor- Returns:
- if the specified
BeanPostProcessorisApplicationContextAwareProcessor, returntrue, orfalse
-