Skip to content

Commit

Permalink
fix: 스프링 스케줄러 & AOP 충돌 해결 (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
gusah009 authored May 4, 2024
1 parent 47db9ab commit 79b6c10
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.keeper.homepage.global.util.aop;

import java.lang.reflect.Proxy;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -18,16 +19,21 @@ public class ApiStatisticAop {

private final ApiStatistic apiStatistic;

/* TODO: Spring 스케줄러 메서드 실행이 안되서 주석 처리.
// TODO: Spring 스케줄러 메서드 실행이 안되서 주석 처리.
@Around("execution(* javax.sql.DataSource.getConnection())")
public Object getConnection(ProceedingJoinPoint joinPoint) throws Throwable {
Object connection = joinPoint.proceed();
// request scope가 아닌 경우 proxy를 타지 않고 바로 connection을 반환한다.
// ex) 스케쥴러
if (RequestContextHolder.getRequestAttributes() == null) {
return connection;
}
return Proxy.newProxyInstance(
connection.getClass().getClassLoader(),
connection.getClass().getInterfaces(),
new ConnectionProxyHandler(connection, apiStatistic)
);
}*/
}

@Around("within(@org.springframework.web.bind.annotation.RestController *)")
public Object calculateExecutionTime(final ProceedingJoinPoint joinPoint) throws Throwable {
Expand Down

0 comments on commit 79b6c10

Please sign in to comment.