[컴][웹] Spring 의 AOP

aop 호출 / 스프링 aop



stack

LoginServiceImpl.loginCheck(User) line: 20
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available  
AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: 307
ReflectiveMethodInvocation.invokeJoinpoint() line: 182
ReflectiveMethodInvocation.proceed() line: 149
ExposeInvocationInterceptor.invoke(MethodInvocation) line: 89
ReflectiveMethodInvocation.proceed() line: 171
JdkDynamicAopProxy.invoke(Object, Method, Object[]) line: 204    $Proxy5.loginCheck(User) line: not available LoginController.login(HttpServletRequest, HttpServletResponse) line: 78


Spring 의 AOP

스프링에서는 몇 가지 방식으로 AOP(Aspect oriented programming) 를 적용할 수 있도록 하고 있다.
공통기능을 갖는 class 를 Aspect class 라고 하자. 이 Aspect  class 를 작성한 이후에 Aspect 를 어떤 클래스의 어떤 method 에 적용할 지를 설정해 줘야 한다.


스프링은 proxy 를 이용하여 AOP 를 구현하고 있다. 스프링은 Aspect의 적용 대상(target) 이 되는 객체에 대한 프록시를 만들어 제공하며, 대상 객체를 사용하는 코드는 대상 객체를 직접 접근하기보다는 프록시를 통해서 간접적으로 접근하게 된다. 이 과정에서 프록시는 공통 기능을 실행한 뒤 대상 객체의 실제 메서드를 호출하거나 또는 대상 객체의 실제 메서드가 호출된 뒤 공통 기능을 실행하게 된다.


댓글 없음:

댓글 쓰기