“application-context” in spring means nothing but it is core component of spring container in spring framework. Ideally we can say “application-context” one of the Spring Container in Spring Framework and other container is “bean-factory”. The configuration for “application-context” is loaded by the one of concrete implementation of ApplicationContext interface.
The ApplicationContext is the central interface within a Spring Application for providing configuration information to the application. It is read-only at run time , but can be reloaded if necessary and supported by the application.
Major Responsibilities of “application-context” container
Creating one “application-context“
ApplicationContext context = new AnnotationConfigApplicationContext(JavaConfig.class;
ApplicationContext context = new AnnotationConfigWebApplicationContext(JavaWebConfig.class;
ApplicationContext context = new ClassPathXMLApplicationContext("spingConfig.xml");
ApplicationContext context = new FileSystemXMLApplicationContext("c:/spingConfig.xml");
ApplicationContext context = new XMLWebApplicationContext("/WEB-INF/config/spingConfig.xml");
Accessing Application Context in the other classes:
You could also access the “application-context” container into other classes. You can implement ApplicationContextAware as in the following example:
public class AnotherClass implements ApplicationContextAware { private ApplicationContext applicationContext; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } }
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…