implementation

Implemented based on Spring AOP

Returns an object generated by a dynamic proxy

public static Object newProxyInstance(ClassLoader loader, Class[] interfaces, InvocationHandler h) ;
Copy the code

Dynamic proxies are divided into JDK proxies and Cglib proxies

  • Interface-based proxy (JDK proxy)

    • Based on the interface proxy, methods of a class that are not public or that use the static keyword cannot be enhanced by Spring AOP
  • CGLib based proxy (subclass proxy)

    • Based on the subclass proxy, methods of any class that use private, static, and final decorations cannot be enhanced by Spring AOP

harvest

  • If no transaction method in the same object accesses a transaction method, the transaction will be invalidated

  • Spring has Transaction propagation, which can be specified by a property in @Transaction, which by default adds all the methods invoked to the same Transaction