Spring IOC and Spring AOP achieve

IOC inversion control container to control the relationship between program objects , rather than the traditional implementation, the control codes between a program, known as dependency injection . ALL class is created, destroyed by the Spring to control the control object that is not a reference to lifecycle his object, but Spring. For an object, before his control other objects, all objects are now controlled Spring, this is the inversion of control.

Dependency Injection idea is achieved through reflection. When instantiating a class, he will be saved in advance in the class attribute in hashmap injected into the category set by the reflection method call class.

Dependency injection: during operation by the dependency is injected into the container assembly is in the operation period, set by the setter method spring according to the profile set by the introduction of other objects will be provided.

Inversion of Control: the transfer of control of the component object, the program code itself is transferred to the outer container, and the assembly is achieved through the container management object assembly.

Spring achieve AOP: the JDK dynamic proxy, cglib dynamic proxies

JDK dynamic proxy : its proxy object must implement an interface, he is on target to complete the proxy object by creating a class that implements the interface during operation. There are core classes: InnovactionHandler, Proxy
** Cgib dynamic agent: * JDK dynamic proxy implementation principle is similar to, but he generated during the operation of the proxy object for the target class is a subclass of expansion. MerhodInterceptor.

Guess you like

Origin blog.csdn.net/weixin_39940206/article/details/95204539