The definition of the spring ApplicationContext
is very ambiguous, I almost finish a whole book of tutorial but still cannot understand what is the ApplicationContext
stand for.
According the Spring API, ApplicationContext
is:
Central interface to provide configuration for an application. This is read-only while the application is running, but may be reloaded if the implementation supports this.
The root interface for accessing a Spring bean container. This is the basic client view of a bean container.
From above, my questions are:
1) I keep seeing the book mentioned "container", what is the container refer to? One container does it mean one java process? or one container refer to one ApplicationContext
object?
2) If i instantiate two ApplicationContext
in one java application (both in main
body), are these two interfaces to one central container? Or two separate instances? See the code below, what is the difference between context1
and context2
? If there is a Singleton in Beans.xml
, it is invoked by context1
and context2
, are they two separated instances or the same instance?
ApplicationContext context1 = new ClassPathXmlApplicationContext("Beans.xml");
ApplicationContext context2 = new ClassPathXmlApplicationContext("Beans.xml");