Understanding Application Contexts in Spring Framework!

I will want to remember these!

The Spring Framework container comes in the form of one or more ApplicationContexts, represented by the org.springframework.context.ApplicationContext interface.

An Application Context manages a set of beans, Java objects that perform business logic, execute tasks, persist and retrieve persisted data, respond to HTTP requests, and more.

A Spring application always has at least one Application Context, and sometimes that’s all it needs.

However, it can also have a hierarchy of multiple Application Contexts. In such a hierarchy, any Spring-managed beans have access to beans in the same Application Context, in the parent Application Context, in the parent’s parent Application Context, and so forth. They do not have access to beans in sibling or child Application Contexts. This is useful for defining a set of shared Application Components while isolating other application components from each other.

There are a number of interfaces that extend and classes that implement ApplicationContext:

The ConfigurableApplicationContext interface is, as the name implies, configurable, whereas the base ApplicationContext is only readable.

The WebApplicationContext and ConfigurableWebApplicationContext interfaces are intended for Java EE web applications running in Servlet containers and provide access to the underlying ServletContext and, if applicable, ServletConfig.

Implementations ClassPathXmlApplicationContext and FileSystemXmlApplicationContext are designed to load the Spring configuration from XML files in a standalone application, whereas the XmlWebApplicationContext achieves the same within Java EE web applications.

AnnotationConfigApplicationContext and AnnotationConfigWebApplicationContext are for programmatically configuring Spring using Java instead of XML.