spring operating mechanism

The core of the internal is IOC, 
dynamic injection, so that an object can be created automatically without new, which is actually the use of reflection in java to 
dynamically create and call objects at runtime. Spring is in At runtime, 
the object is dynamically created with the xml Spring configuration file, and the methods in the object are called. 
  Another core of Spring is AOP, which is aspect-oriented programming, which can supervise and control a certain type of object (that is 
, call the module you specify before and after calling the specific method of this type of object), so as to achieve the expansion of a module. Function. These are achieved through 
configuration classes. 
  The purpose of Spring is to make the relationship between objects and objects (modules and modules) not associated with code, but managed through configuration class descriptions 
(Spring dynamically assembles objects through reflection according to these configurations). 
  Remember: Spring It is a container, and all objects in the container will have these services and functions provided by Spring. 
One of the most classic design patterns used in Spring is the template method pattern. (I will not introduce it here, it is a very common design pattern) 
  There are many configurations in Spring, and it is difficult to remember them all, but the essence of Spring is nothing more than the above two points, understand the above two points Basically, I have mastered Spring.

Spring AOP and IOC
1. IoC (Inversion of control): Inversion of Control 
1. IoC: 
Concept: control is transferred from the object itself to the container; the container creates instances according to the configuration file and creates each instance dependencies between 
Core: bean factory; in Spring, each instance created by the bean factory is called bean 
2. AOP (Aspect-Oriented Programming): Aspect-Oriented Programming 
1. Two ways of proxy: 
static proxy: 
 Write separately for each specific class Proxy class; 
 Write a proxy class for an interface; 
dynamic proxy: 
write an InvocationHandler for an aspect, and then use the Proxy class in the JDK reflection package to dynamically generate corresponding proxy classes for various interfaces

 

Reprinted from http://www.iteye.com/problems/102393

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326503052&siteId=291194637