-
[Spring] 간소화된 Advisor프로그래밍 공부/Spring 2021. 5. 5. 17:00
뉴렉처 강사님의 동영상 강의를 정리한 글입니다.
간소화된 Advisor
: point cut과 advisor를 합친 것. 따로 생성 해줄 필요 없이 한 번에 생성 가능
NameMatchMethodPointcutAdvisor
<bean id="classicBeforeAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor"> <property name="advice" ref="logBeforeAdvice"/> <property name="mappedNames"> <list> <value>total</value> <value>avg</value> </list> </property> </bean>
mappedNames를 이용하여 weaving 하고 싶은 메서드를 여러 개 줄 수 있음.
<property name="mappedName" value="total"/>도 가능함
RegexpMethodPointcutAdvisor
<bean id="classicBeforeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice" ref="logBeforeAdvice"/> <property name="patterns"> <list> <value>.*to.*</value> </list> </property> </bean>
정규식을 이용하여 메서드 이름을 전달 할 수 있음
'프로그래밍 공부 > Spring' 카테고리의 다른 글
[Spring] Point Cut (0) 2021.05.05 [Spring] After Returning / Throwing Advice (0) 2021.05.05 [Spring] BeforeAdvice 구현하기 (0) 2021.05.05 [Spring] 스프링 AOP 구현해보기 - AroundAdvice (0) 2021.05.05 [Spring] AOP 코드 구현하기 (0) 2021.05.05