[Spring 학습 노트] Spring Aop 자세하게 말 해 주세요.

2015 단어 스프링 베이스
AOP (Aspect Oriented Programming) 절단면 프로 그래 밍
개술
AOP (Aspect Oriented Programming) 의 절단면 프로 그래 밍 은 Spring 이 코드 결합 도 를 낮 추기 위해 디자인 한 방식 이다.저 희 는 실제 응용 에서 로그, 업무 차단기, 통계 업무 데이터 등 을 인쇄 하기 위해 서 입 니 다.
Spring Aop 자세히 말 해 봐.
Aop 에는 전문 명사, 절단면 (Aspect), 알림 (Advice), 연결 점 (Join Point), 접점 (Point Cut), 도입 (Introduction), 직물 (Weaving) 이 많 습 니 다.사실 우리 가 개발 할 때 주로 쓰 는 것 은 바로 통지 이다. 왜냐하면 절단면 과 연결 점, 그리고 절 점 은 프로젝트 가 막 시작 되 었 을 때 이미 충분히 정의 되 었 기 때문이다. 큰 변화 가 없 으 면 평소에 변 하지 않 을 것 이다.다음은 작은 데 모 를 주면 어떻게 된 일 인지 알 수 있 을 거 야.
첫 번 째, 절단면 정의
package com.example.readingli.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;
/**
 * Spring-aop  
 * @author liugd
 *
 */
@Aspect//            
@Configuration
public class AopTest {

} 

두 번 째 정의 접점
package com.example.readingli.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;
/**
 * Spring-aop  
 * @author liugd
 *
 */
@Aspect
@Configuration
public class AopTest {
	/**
	 *   
	 */
	@Pointcut("execution(* com.example.readingli.web.*.*(..))")//  com.example.readingli.web           ,        
	public void pointCut(){
		
	}
}

@ Pointcut 에 따 르 면 이 방법 은 절 점 (차단 이 필요 한 모든 방법 에 적합 한 방법 입 니 다. 알림 (advice) 에 이 절 점 을 설정 하면 모든 연결 점 을 차단 할 수 있 습 니 다. (차단 되 는 방법)
세 번 째 단 계 는 알림 을 작성 합 니 다.
주: 알림 에 사 용 된 클래스 가 용기 에 없 으 면 (이 클래스 에 주 해 를 추가 할 수 없습니다 @ Component) 자바 설정 방식 을 사용 할 수 없습니다. xml 설정 을 사용 해 야 합 니 다.

좋은 웹페이지 즐겨찾기