Springioc and Di

Source: Internet
Author: User
Tags ip number

Concept of 1.Spring

Spring's green Grass (I.)

Spring
Lightweight framework, Java EE Spring, current mainstream framework
Goal
Make existing technologies easier to use and advance coding best practices
Content
IOC container
AOP implementations
Data access Support
Simplified Jdbc/orm Framework
Declarative transactions
Web integration

Spring's Green Grass (ii)

Spring Design Concept
Spring is a bean-oriented programming
Spring Two Core Technologies
Controlled inversion (ioc:inversion of Control)/dependency injection (Di:dependency injection)
Plane-oriented programming (Aop:aspect oriented programming)

Spring Benefits

The advantages of Spring
Low-intrusive design
Separate from various application servers
Dependency Injection features transparency of component relationships and reduced coupling
Polygon-oriented programming features allow centralized processing of common tasks
Good integration with third-party frameworks

About the father of spring

Rod Johnson,springframework founder, Interface21 CEO

Rich background in the C + + context, rich financial industry backgrounds
1996 begins to focus on Java server-side technology
Servlet2.4 and JDO2.0 expert team member
2002 wrote "Expoert ONE-ON-ONEJ2EE design and development", changing the Java World
Technical proposition: Practical-oriented technology, PhD in musicology

The concept of the IOC and DI

IOC (Control inversion)

Control inversion (inversion of CONTROL,IOC), also known as Dependency injection (Dependency Lnjection,di), is a design concept for object-oriented programming to reduce the coupling of program code.
This is the core of spring, throughout. The so-called IOC, for the spring framework, is the responsibility of spring to control the object's life cycle and the relationship between objects. What does that mean, for example, how do we find a girlfriend? The common situation is that we go everywhere to see where there is a beautiful body and good mm, and then inquire about their interests, QQ number, telephone number, IP number, IQ number ..., find ways to know them, give them what they want, then hey ... The process is complex and profound, and we have to design and face each link ourselves. The same is true of traditional program development, in an object, if you want to use another object, you have to get it (your own new one, or a query from Jndi), after the use of the object will be destroyed (such as connection, etc.), the object will always and other interfaces or classes together.
So how does the IOC do it? It's kind of like finding a girlfriend through a dating agency, introducing a third party between me and my girlfriend: the Marriage Institute. Matchmaking management of a lot of men and women's information, I can give a list of matchmaking, tell it I want to find a girlfriend, such as like Michelle Reis, figure like Lin Xire, singing like Jay Chou, speed like Carlos, technology like Zidane, and then the matchmaking will be according to our requirements, provide a mm, We just have to go to love her and get married. As simple as it is, if a matchmaking person doesn't meet our requirements, we'll throw an exception. The whole process is no longer controlled by myself, but by a similar container-like institution that has a matchmaking system. This is how spring advocates for development, and all classes are registered in the spring container, telling spring what you are, what you need, and then spring will give you what you want when the system runs to the right time, as well as handing you over to other things that need you. All classes are created and destroyed by spring, which means that the object that controls the lifetime of the object is no longer a reference to it, but spring. For a specific object, it was previously controlled by other objects, and now all objects are controlled by spring, so this is called control inversion.

DI (Dependency injection)

Dependency Injection (Dependency lnjection,di)
A key point of the IOC is to dynamically provide the other objects it needs to an object during the system's operation. This is achieved through DI (Dependency injection, Dependency injection). For example, object A needs to manipulate the database, before we always have to write code in a to get a connection object, with spring we just need to tell spring,a need a connection, as for this connection how to construct, when to construct , a does not need to know. When the system is running, Spring creates a connection at the right time, and then, like an injection, it injects into a, which completes the control of the relationship between the various objects. A relies on connection to function properly, and this connection is injected into a by spring, and the name of the dependency injection comes in. So how is di implemented? An important feature after Java 1.3 is reflection (reflection), which allows the program to dynamically generate objects, execute methods of objects, and change the properties of objects when it is run, and spring is injected through reflection.

Springioc and Di

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.