본문 바로가기

Back-end/Spring

[Spring] pointCut 적용 - controller, restController

pointcut 지정 어노테이션 @Pointcut

 

AOP 안에 pointcut class 생성

 

@Aspect

@Componet

public class HobiPointCut {
    @Before("execution(* kr.hobi.controller.*RestController.*(..))")
    public void checkRestController(JoinPoint joinPoint) {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
 
 .......

        if (체크 진행) {
            throw new HobiAuthenticationException("Invalid Access");
        }
    }

}