Spring – IoC Containers | Code Factory


Donate : Link

Medium Blog : Link

Applications : Link

This image has an empty alt attribute; its file name is image-1.png

Spring Tutorial Index Page: Link

* In IOC we have 3 container. These 3 are interfaces.

1. Core (BeanFactory (I) -> XmlBeanFactory (C))

  • BeanFactory b = new XmlBeanFactory();

2. J2EE (ApplicationContext (I) -> ConfigurableApplicationContext (I) -> ClasspathXmlApplicationContext (C))

  • ApplicationContext a = new ClasspathXmlApplicationContext();
  • ConfigurableApplicationContext = new ClasspathXmlApplicationContext(“”);

3. Web (WebApplicationContext (I) -> WebApplicationContextUtil (Factory Class)) (It is in Spring MVC)

  • WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());

* What Container do?

  1. Read xml file
  2. Create instances for pojo classes
  3. Manage lifecycle of pojo classes
  4. Into pojo classes we can do DI
  • IOC internally use SAX parser.
  • While loading it will check xml (Ex. spring.xml) document. If it will find any invalid tag or unformed tag (tag opened but not closed) then this parser will throw parsing exception.
  • * IOC create instance in JVM on first user request (BeanFactory) or while loading (ApplicationContext) when scope is singleton. If scope is not singleton then ApplicationContext not create objects on loading.

Leave a comment