Introduction to Spring Containers

Source: Internet
Author: User

Spring is a Bean-oriented programming (Bop,bean oriented programming) that provides an IOC container to manage dependencies between objects through configuration files or annotations.

The basic concept of control reversal mode (also known as dependency intervention) is that you do not create objects, but describe how they are created. the code does not directly connect to objects and services, but describes in the configuration file which component requires which service. Containers (which are IOC containers in the Spring framework) are responsible for linking these together.

In a typical IOC scenario, the container creates all the objects and sets the necessary properties to connect them together, deciding when to invoke the method.

Aspect-oriented programming, AOP, is a programming technique that allows programmers to modularize the behavior of crosscutting concerns or crosscutting typical lines of responsibility, such as logging and transaction management . The core structure of AOP is the facet, which encapsulates behaviors that affect multiple classes into reusable modules.

AOP and IOC are complementary technologies that use a modular approach to solve complex problems in enterprise application development. The functionality of AOP is fully integrated into the context of Spring transaction management, logging, and various other features.

IOC container

By reading the instructions provided by the configuration metadata, the container knows which objects are instantiated, configured, and assembled. Configuration metadata can be represented by Xml,java annotations or Java code. The Spring IoC container leverages Java's POJO class and configuration metadata to generate fully configured and executable systems or applications.

Spring provides two different kinds of containers. In a resource-valuable mobile device or applet-based application, beanfactory is preferred. Otherwise, the general use is ApplicationContext, unless you have better reasons to choose Beanfactory.

Beanfactory container

The simplest container. This container interface is defined in Org.springframework.beans.factory.BeanFactorys . Beanfactory and related interfaces, such as Beanfactoryaware, Disposablebean, and Initializingbean, remain in Spring, with the main purpose of backwards compatibility with existing and those A third-party framework in which Spring is integrated.

ApplicationContext container

Application Context is a higher-level container in spring. Similar to beanfactory, it can load the beans defined in the configuration file, centralize all the beans, and allocate the bean when requested. In addition, it increases the functionality required by the enterprise, such as parsing textual information from a property file and passing events to the listener you specify. This container is defined in the org.springframework.context.ApplicationContext interface.

Resources

Http://blog.javachen.com/2014/09/29/spring-source-codes.html

Http://wiki.jikexueyuan.com/project/spring/ioc-containers.html

Introduction to Spring Containers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.