AOP

Hayoung Kim·2020년 7월 9일
0

SpringFramework

목록 보기
5/9

Aspect Oriented Programming
관점 지향 프로그래밍
원하는 위치에서 제어할 수 있게해준다.

@Component, @Aspect annotation을 통해 선언한다.
@pointcut("") //spring.document에 따른다.

	@Pointcut("within(com.study.controller.*)")
	public void sutdyPointcut() {}
	
	@Before("studyPointcut()")
	public void beforeStudyAspect(JoinPoint jp) throws Exception{
		System.out.println("beforeStudyAspect");
	}
	@Around("studyPointcut()")
	public Object aroundStudyAspect(ProceedingJoinPoint pjp) throws Throwable{
		System.out.println("aroundStudyAspect");
		return pjp.proceed();
	}
	@After("studyPointcut()")
	public void afterStudyAspect(JoinPoint jp) throws Exception{
		System.out.println("afterStudyAspect");
		
	}

pointCut

문의 위치를 지정해준다.(문은 원하는 위치로 지정하면된다. Controller, service, repository등)
* within : 들어오는 요청에 해당 url이 포함되면 필터링한다.

JoinPoint

막 들어오거나 나가기 직전

ProceedingJoinPoint

request 정보를 보고 처리가 가능함.

0개의 댓글