관리 메뉴

개발용

[Spring] AOP 본문

개발/WEB

[Spring] AOP

DeP 2017. 1. 24. 17:24

*pom.xml

+)

<dependency>

<groupId>org.aspectj</groupId>

<artifactId>aspectjweaver</artifactId>

<version>1.8.8</version>

</dependency>

 

 

 

*AOP 표현식 : execution(    [RETURN_TYPE]    [PACKAGE_PATH]    [CLASS_NAME]    [METHOD_NAME]([PARAMETERS])    )

Ex)execution( *  com.springbook.bin..  *Impl.  *(..) )

 

-(..) : 매개변수 상관 없음

-(*) : 매개변수 오직 1개인 메소드

-(Integer,..)  : 한 개 이상의 매개변수 중 첫 번째 매개변수가 Integer인 메소드

 

 

*동작 시점

-before : 비즈니스 메소드 실행 전

-after : 비즈니스 메소드 실행 후(무조건)

-after returning : 성공적으로 리턴 후

-after throwing : 실행 중 예외 발생 시

-around : 메소드 호출 자체를 가로채어 실행 전후에 처리

 

 

 

*Ex

<aop:config>

<aop:pointcut expression="execution( *  com.springbook.bin..  *Impl.  *(..) )" id="[POINTCUT_NAME]"/>

 

<aop:aspect ref="[REF_KEY]">

<aop:[동작시점] pointcut-ref="[POINTCUT_NAME]" method="[METHOD_NAME]"/>

<aop:aspect>

</aop:config>

 

 

- : JOIN POINT

- : POINT CUT

 

 

'개발 > WEB' 카테고리의 다른 글

[Spring] 어노테이션 기반 설정  (0) 2017.01.24
[Spring] DI(의존성 주입)  (0) 2017.01.24
[Spring] IoC  (0) 2017.01.24
Bean factory  (0) 2017.01.24