IOC And AOP yes Spring The core of the game ;IOC It's control reversal ,AOP It's object-oriented programming ,IOC The factory design mode is adopted ,AOP The agent design pattern is adopted .
one ,IOC
IOC It's control reversal , Control reversal is an idea , and DI It's dependency injection , Dependency injection and inversion of control are different descriptions of the same thing , In a way , It's just that they describe things from different angles ,DI Structural injection , Property injection ( Set point injection )( Annotation based or annotation based XML The way ). In the project procedure , Create objects manually frequently ,new Object makes code coupling too large , and Spring A container is provided , Generally speaking : You don't need to know how the object is created , Just get the results from it ; The creation of objects, the relationship between objects, and the destruction of objects are handed over to the Spring Container management , In the actual code, there is no need to go manually new
object , Just from Spring Use the object directly in the container , That's it IOC Control reversal ;Spring Through reflection and XML Manage objects in the form of configuration maps or annotations .
IOC and DI The difference between
1. They are spring Description of different aspects of the core idea .
2. Dependency injection and inversion of control are different descriptions of the same thing , In a way , It's just that they describe things from different angles .
Dependency injection is described from the perspective of application , The dependency injection can be described as a complete point : The application relies on the container to create and inject the external resources it needs ;
The inversion of control is described from the perspective of container , Describe the whole point : Container control application , The container reversely injects the external resources needed by the application .
two ,AOP
AOP It's aspect oriented programming , It's also right OOP Supplement of object oriented programming ;AOP The core of the implementation principle is dynamic proxy ; We know object-oriented
Technology