It is a process whereas objects define their
dependencies. Hare spring container responsible to injects those
dependencies when it creates the bean. This process is fundamentally the
inverse, hence the name Inversion of Control (IoC).
- The
org.springframework.beans
andorg.springframework.context
packages are the basis for Spring Framework's IoC container. - The
BeanFactory
interface provides an advanced configuration mechanism capable of managing any type of object.ApplicationContext
is a sub-interface ofBeanFactory.
It adds easier integration with Spring's AOP features; message resource handling (for use in internationalization), event publication; and application-layer specific contexts such as theWebApplicationContext
for use in web applications. - The interface
org.springframework.context.ApplicationContext
represents the Spring IoC container and is responsible for instantiating, configuring, and assembling the aforementioned beans. - Your
application classes are combined with configuration metadata so that after
the
ApplicationContext
is created and initialized, you have a fully configured and executable system or application. - Instantiating a Spring IoC container is straightforward. The
location path or paths supplied to an
ApplicationContext
constructor are actually resource strings that allow the container to load configuration metadata from a variety of external resources such as the local file system, from the JavaCLASSPATH
, and so on.
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"services.xml", "daos.xml"});
The
ApplicationContext
is the interface for an advanced factory capable of maintaining a registry of different beans and their dependencies. Using the methodt.getBean(String name, Class<T> requiredType)
you can retrieve instances of your beans.
No comments:
Post a Comment