Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 루테란 떠돌이상인
- 페이튼 떠돌이상인
- HWP
- 유튜브
- SSL
- SE
- 홈페이지제작견적
- 베른 떠돌이상인
- 슈샤이어 떠돌이상인
- zoom
- 로헨델 떠돌이상인
- sm
- 파푸니카 떠돌이상인
- 욘 떠돌이상인
- 아르데타인 떠돌이상인
- 가로세로세팅
- https
- IT용어
- 애니츠 떠돌이상인
- 한글
- SI
- 3
- PIP모드
- 이름바꾸기
- 특정페이지가로로
- 작은화면
- 토토이크 떠돌이상인
Archives
- Today
- Total
도담도담
AOP(Aspect Oriented Programming) 본문
스프링에서 AOP를 활용하려면 pom.xml에서 <dependency> ~~~ 를 추가해 주어야한다.
(추가되었는지는 maven dependency에 가서 aspectjrt 와 aspectjweaver가 있는지 확인!)
핵심관심 메서드와 횡단관심 메서드 사이에서 소스상을 결합은 절대 발생하지 않는다!!
AOP 용어
조인 포인트(포괄적)
- 클라이언트가 호출하는 모든 비즈니스 메서드
포인트컷(일부 메서드를 지정)
- 필터링된 조인포인트
어드바이스 동작 시점
before
after
after-returning
after-throwing
around
위빙 - 메서드가 삽입되는 과정
- 스프링프레임워크는 런타임 중에서만 가능
애스펙트/어드바이저
- 포인트컷과 어드바이스의 결합 - 어떤 어스바이스를 어떤 시점에서 사용할지 정해준다
AOP를 사용하기 위해서 필요한거
pom.xml
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.8</version>
</dependency>
applicationContext.xml
<beans xmlns:aop="http://www.springframework.org/schema/aop"
<!-- AOP -->
<bean id="log" class="com.lsj.biz.common.LogAdvice"></bean>
<aop:config>
<aop:pointcut expression="execution(* com.lsj.biz..*Impl.*(..))" id="allPointcut"/>
<aop:pointcut expression="execution(* com.lsj.biz..*Impl.get*(..))" id="getPointcut"/>
<aop:aspect ref="log">
<aop:after method="printLog" pointcut-ref="getPointcut" />
</aop:aspect>
</aop:config>
<aop:config> <!-- AOP 설정 -->
<aop:pointcut ~~/> <!-- 비지니스로직 메서드 설정 -->
<aop:aspect ~~/> <!-- 어드바이스 메서드 실행 시점 -->
</aop:config>
<aop:pointcut ~~/> <!-- 비지니스로직 메서드 설정 -->
id속성="유일한이름" , expression속성="execution()"
execution(리턴 패키지..클래스명.메서드명(..)
* com.test.biz..*impl.*(..)
* com.test.biz..Board*.get*(..)
<aop:aspect ref="어드바이스객체" /> <!-- 어드바이스 메서드 실행 시점 -->
포인트컷 메서드와 어드바이스 메서드를 결합 : 실행 시점
<aop:실행시점 pointcut-ref="포인트컷id" method="어드바이스메서드명" />
</aop:aspect>
<aop:config>
<aop: advisor ~~~ /> <!-- 트렌잭션과 같은 특수한 경우에 사용 -->
<aop:config>
</beans>
'IT 공부 > KH 정보교육원' 카테고리의 다른 글
스프링 트랙젝션(Transaction) (0) | 2021.06.21 |
---|---|
어노테이션을 이용한 MVC (0) | 2021.06.18 |
어노테이션 (annotation) (0) | 2021.06.16 |
의존성 주입 (DI : Dependency Injection) (0) | 2021.06.16 |
Spring 사용방법 (개념) (0) | 2021.06.15 |
Comments