[Spring AOP] 포인트컷 표현식 - bean
목차 [Spring AOP] 포인트컷 표현식 - this, target [Spring AOP] 포인트컷 표현식 - Advice 에 매게변수 전달 [Spring AOP] 포인트컷 표현식 - bean [Spring AOP] 포인트컷 표현식 - @args [Spring AOP] 포인트컷 표현식 - @annotation [Spring AOP] 포인트컷 표현식 - @target, @within [Spring AOP] 포인트컷 표현식 - args [Spring AOP] 포인트컷 표현식 - within [Spring AOP] 포인트컷 표현식 - execution [Spring AOP] 포인트컷 beanbean 표현식은 스프링에서만 사용한 포인트컷 지시자로 Bean 이름으로 Advice 적용 여부를 판단합니다. @Slf4j@Import(BeanTest.BeanAspect.class)@SpringBootTestpublic class BeanTest { @Autowired OrderService orderService; @Test void success(){ orderService.orderItem("itemA"); } @Aspect static class BeanAspect{ // orderService 빈과 Repository 로 끝나는 빈들에 Advice 를 적용합니다. @Around("bean(orderService) || bean(*Repository)") public Object doLog(ProceedingJoinPoint joinPoint) throws Throwable { log.info("[bean] {}", joinPoint.getSignature()); return joinPoint.proceed(); } }} 2021-12-21 00:13:43.463 INFO 35836 --- [ Test worker] com.example.aop.pointcut.BeanTest : [bean] void com.example.aop.order.OrderService.orderItem(String)2021-12-21 00:13:43.474 INFO 35836 --- [ Test worker] com.example.aop.order.OrderService : [orderService] 실행2021-12-21 00:13:43.475 INFO 35836 --- [ Test worker] com.example.aop.pointcut.BeanTest : [bean] String com.example.aop.order.OrderRepository.save(String)2021-12-21 00:13:43.480 INFO 35836 --- [ Test worker] com.example.aop.order.OrderRepository : [orderRepository] 실행