Spring learning record (II)

Time:2021-10-15

1. Principle of spring integrated web project

Underlying technology: ServletContext object; monitor;

Implementation principle: when the server starts, create a ServletContext object;
When creating an object, you can use the listener to listen to when to create a ServletContext object;
When listening to the creation of this object, the server will load the spring configuration file and create the object,
At the same time, put the object into the ServletContext domain object (setAttribute method);
When getting the object, get it from the ServletContext domain object (getattribute method);

2. Annotation creation object
@component
@Controller web layer
@Service business layer
@Repository persistence layer
The functions of the four annotations are the same. They all create objects.

3. Annotation injection attribute
@Autowired auto assembly
@Resource(value=“uesrDao”)

4. AOP aspect oriented programming

Underlying principle: using dynamic proxy mode

When there is an interface, create a dynamic proxy object of the interface and add methods horizontally. (JDK dynamic agent)
When there is no interface, create a proxy object of a class subclass to enhance functions. (cglib dynamic proxy)

5. Common terms of AOP
Join points: methods that can be enhanced in a class; (method only)
Entry point: the method actually enhanced is the entry point;
Advance: the added function is an enhancement; (pre, post, final, exception, surround notification)
Section: apply enhancement to specific methods, and the process is section;