0
나는 봄 보안 프로젝트를 사용하여 OAuth2 서버 구현을 시도하고있다. 나는 https://github.com/SpringSource/spring-security-oauth에서 자식 프로젝트를 복제했다.기존 프로젝트에 AspectJ 추가하기
예제는 문서화 된대로 작동합니다. 이제 플로우를 추적하기 위해 기존 코드에 AOP를 사용하여 함수 입력/종료를 추가하려고합니다.
- 추가 클래스 "Watcher.java"(아래 코드)의 pom.xml에
추가 AspectJ의 종속성
<dependency> <groupId>aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.5.3</version> </dependency> <dependency> <groupId>aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.5.3</version> </dependency>
프로젝트 빌드 및
실행이 들어 나는 다음과 같은 변경을 수행 한- 각 기능에 대한 AspectJ 아이콘이 보이지 않음
원본 코드를 많이 변경하지 않고이 방법으로 함수 입력/종료 로깅을 추가 할 수 있습니까?
Watcher.java는 :
package org.springframework.security.oauth.examples.sparklr;
import java.util.Arrays;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@Aspect
public class Watcher {
@Pointcut("execution(* *(..))")
public void watch() {
}
@Before("watch()")
public void preWatch(JoinPoint joinPoint) {
if (joinPoint.getArgs().length > 0) {
String[] args = new String[joinPoint.getArgs().length];
System.arraycopy(joinPoint.getArgs(), 0, args, 0,
joinPoint.getArgs().length);
System.out.println("-> " + joinPoint.toShortString()
+ Arrays.toString(joinPoint.getArgs()));
} else {
System.out.println("-> " + joinPoint.toShortString());
}
System.out.println("Args: " + joinPoint.getArgs().length);
}
@AfterReturning("watch()")
public void postWatch(JoinPoint joinPoint) {
System.out.println("<- " + joinPoint.toShortString());
}
}