Loading...
Spring Framework Reference Documentation 7.0.2의 Programmatic Creation of @AspectJ Proxies의 한국어 번역본입니다.
아래의 경우에 피드백에서 신고해주신다면 반영하겠습니다.
감사합니다 :)
<aop:config> 또는 <aop:aspectj-autoproxy>를 사용하여 설정에 aspects를 선언하는 것 외에도,
target 객체에 advice를 적용하는 프록시를 프로그래밍 방식으로 생성하는 것도 가능합니다.
Spring의 AOP API에 대한 전체 세부 내용은
next chapter를 참고하세요. 여기에서는 @AspectJ aspects를 사용하여
자동으로 프록시를 생성하는 기능에 초점을 맞춥니다.
org.springframework.aop.aspectj.annotation.AspectJProxyFactory 클래스를 사용하여
하나 이상의 @AspectJ aspects에 의해 advice가 적용되는 target 객체에 대한 프록시를
생성할 수 있습니다. 이 클래스의 기본적인 사용법은 다음 예제와 같이 매우 간단합니다:
1// create a factory that can generate a proxy for the given target object 2AspectJProxyFactory factory = new AspectJProxyFactory(targetObject); 3 4// add an aspect, the class must be an @AspectJ aspect 5// you can call this as many times as you need with different aspects 6factory.addAspect(SecurityManager.class); 7 8// you can also add existing aspect instances, the type of the object supplied 9// must be an @AspectJ aspect 10factory.addAspect(usageTracker); 11 12// now get the proxy object... 13MyInterfaceType proxy = factory.getProxy();Copied!
1// create a factory that can generate a proxy for the given target object 2val factory = AspectJProxyFactory(targetObject) 3 4// add an aspect, the class must be an @AspectJ aspect 5// you can call this as many times as you need with different aspects 6factory.addAspect(SecurityManager::class.java) 7 8// you can also add existing aspect instances, the type of the object supplied 9// must be an @AspectJ aspect 10factory.addAspect(usageTracker) 11 12// now get the proxy object... 13val proxy = factory.getProxy<Any>()Copied!
자세한 내용은 javadoc을 참고하세요.
Proxying Mechanisms
Using AspectJ with Spring Applications