Skip to content

io microsphere spring context ApplicationContextUtils

github-actions[bot] edited this page Jun 18, 2026 · 18 revisions

ApplicationContextUtils

Type: Class | Module: microsphere-spring-context | Package: io.microsphere.spring.context | Since: 1.0.0

Source: microsphere-spring-context/src/main/java/io/microsphere/spring/context/ApplicationContextUtils.java

Overview

ApplicationContext Utilities

Declaration

public abstract class ApplicationContextUtils implements Utils

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.27-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Method Examples

asConfigurableApplicationContext

GenericApplicationContext context = new GenericApplicationContext();
  ConfigurableApplicationContext configurableContext = asConfigurableApplicationContext(context);
  assertSame(context, configurableContext);

asConfigurableApplicationContext

ResourceLoader resourceLoader = context; // context is a GenericApplicationContext
  ConfigurableApplicationContext configurableContext =
      asConfigurableApplicationContext(resourceLoader);
  assertSame(context, configurableContext);

asApplicationContext

GenericApplicationContext context = new GenericApplicationContext();
  ApplicationContext applicationContext = asApplicationContext(context);
  assertSame(context, applicationContext);

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-context</artifactId>
    <version>${microsphere-spring.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.context.ApplicationContextUtils;

API Reference

Public Methods

Method Description
asConfigurableApplicationContext The org.springframework.context.support.ApplicationContextAwareProcessor Class Name (Internal).
asConfigurableApplicationContext Casts the given object to a ConfigurableApplicationContext if possible.
asApplicationContext Casts the given BeanFactory to an ApplicationContext if possible.
getApplicationContextAwareProcessor Get the org.springframework.context.support.ApplicationContextAwareProcessor
getApplicationContextAwareProcessor Get the org.springframework.context.support.ApplicationContextAwareProcessor
isApplicationContextAwareProcessor Is the specified BeanPostProcessor is

Method Details

asConfigurableApplicationContext

public static ConfigurableApplicationContext asConfigurableApplicationContext(ApplicationContext context)

The org.springframework.context.support.ApplicationContextAwareProcessor Class Name (Internal).

asConfigurableApplicationContext

public static 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);
`

asApplicationContext

public static ApplicationContext asApplicationContext(BeanFactory beanFactory)

Casts the given BeanFactory to an ApplicationContext if possible.

Example Usage

`GenericApplicationContext context = new GenericApplicationContext();
  ApplicationContext applicationContext = asApplicationContext(context);
  assertSame(context, applicationContext);
`

getApplicationContextAwareProcessor

public static BeanPostProcessor getApplicationContextAwareProcessor(ConfigurableApplicationContext context)

Get the org.springframework.context.support.ApplicationContextAwareProcessor

getApplicationContextAwareProcessor

public static BeanPostProcessor getApplicationContextAwareProcessor(BeanFactory beanFactory)

Get the org.springframework.context.support.ApplicationContextAwareProcessor

isApplicationContextAwareProcessor

public static boolean isApplicationContextAwareProcessor(Object instance)

Is the specified BeanPostProcessor is org.springframework.context.support.ApplicationContextAwareProcessor


This documentation was auto-generated from the source code of microsphere-spring.

Home

spring-context

spring-guice

spring-jdbc

spring-test

spring-web

spring-webflux

spring-webmvc

Clone this wiki locally