Notice: Constant WP_MEMORY_LIMIT already defined in /home/javawith/public_html/codesjava.com/wp-config.php on line 107

Notice: Constant WP_MAX_MEMORY_LIMIT already defined in /home/javawith/public_html/codesjava.com/wp-config.php on line 108
Spring ioc container types, classes - CodesJava

CodesJava

Easy learning with example program codes

spring IoC container types


Notice: Undefined variable: footnotelist in /home/javawith/public_html/codesjava.com/wp-content/plugins/latex2html/inc/core.php on line 475

Spring IoC container is responsible for create, wire, configure and manage objects during their complete life cycle. It uses configuration metadata for create, configure and manage objects. Configuration metadata can be represented by spring configuration xml file or annotations.

Types of Spring IoC container:

    1. BeanFactory
    2. ApplicationContext

BeanFactory:

BeanFactory org.springframework.beans.factory.BeanFactory is the interface and XmlBeanFactory is an implementation class of it. It is a simple container which provides the basic support for dependency injection.

Syntax to use BeanFactory:

Resource resource = new ClassPathResource(“spring configuration file”);
BeanFactory beanFactory = new XmlBeanFactory(resource);

ApplicationContext:

ApplicationContext org.springframework.context.ApplicationContext is the interface and ClassPathXmlApplicationContext is an implementation class of it. ApplicationContext container includes all functionality of the BeanFactory container with some extra functionality like internationalization, event listeners etc.

Syntax to use ApplicationContext:

ApplicationContext applicationContext  =  
         new ClassPathXmlApplicationContext("spring configuration file");

Note: As ApplicationContext provides extra functionality including all given by BeanFactory it is better to use ApplicationContext container.
 

Please follow and like us:
error

Spring Tutorial








Copyright © 2019 CodesJava DMCA.com Protection Status