Spring Aspect-Oriented Programming -- Spring's Support for AOP

Spring provides 4 types of AOP support:

        1. Classic Spring AOP based on proxy

        2. Pure POJO aspect

        3. @AspectJ annotation-driven aspect

        4. Injected AspectJ (applicable to all versions of Spring)

        The first three are all variants of Spring AOP implementation. Spring AOP is built on the basis of dynamic proxy. Therefore, Spring's support for AOP is limited to method interception.


Spring notifications are written in Java:

        The notifications created by Spring are written in standard Java classes.


Spring notifies objects at runtime:

        Advice wraps aspects in proxy classes, and Spring weaves aspects into Spring-managed beans at runtime.

        The proxy class encapsulates the target class, intercepts the call of the notified method, and forwards the call to the real target bean. When the proxy intercepts the method call, the aspect logic is executed before the target bean method is called.

        Spring does not create proxy objects until the application needs the proxied bean. Therefore, the Spring runtime does not create proxy objects.


Spring only supports method-level join points:

        Because Spring is based on dynamic proxies, Spring only supports method join points. Method interception can meet most needs. If you need join point interception functions other than method interception, then we can use Aspect to complement Spring AOP functions.

        

Guess you like

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