Module bus.starter

Class AspectjJdbcProxy

java.lang.Object
org.miaixz.bus.starter.jdbc.AspectjJdbcProxy

@Order(-1) public class AspectjJdbcProxy extends Object
AOP aspect for dynamic datasource switching.

This aspect intercepts methods annotated with DataSource and manages the datasource context before and after method execution.

Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • AspectjJdbcProxy

      public AspectjJdbcProxy()
  • Method Details

    • before

      public void before(org.aspectj.lang.JoinPoint joinPoint, DataSource dataSource)
      Advice that runs before a method execution with DataSource annotation.

      Sets the datasource context based on the value specified in the annotation. If no datasource is specified, the default datasource will be used.

      Parameters:
      joinPoint - the join point representing the method execution
      dataSource - the datasource annotation on the method
    • after

      public void after(org.aspectj.lang.JoinPoint joinPoint, DataSource dataSource)
      Advice that runs after a method execution with DataSource annotation.

      Cleans up the datasource context based on the configuration in the annotation. If DataSource.clear() is true, the datasource context will be cleared. Otherwise, the datasource context will be maintained for subsequent operations.

      Parameters:
      joinPoint - the join point representing the method execution
      dataSource - the datasource annotation on the method