package io.delphiplatform.api.aop;

import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;


@Configuration
@EnableAspectJAutoProxy
public class AopConfiguration {

    @Bean
    public AppPerformanceMonitorInterceptor performanceMonitorInterceptor() {
        return new AppPerformanceMonitorInterceptor();
    }

    @Bean
    public Advisor performanceMonitorAdvisor() {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression("io.delphiplatform.api.aop.AppArchitecture.delphiApiOperation()");
        return new DefaultPointcutAdvisor(pointcut, performanceMonitorInterceptor());
    }

}
