나는 여러개의 플러그인을 가지고있는 rcp 프로젝트를 개발 중이며, 어플리케이션에서 로깅 목적으로 AJDT aspectJ를 사용하고있다. 정보 로깅과 예외 로깅을위한 두 가지 측면을 각각의 plugin.Aspect에서 만들었습니다. 기본 플러그인은 제대로 작동하지만 다른 플러그인에서는 작동하지 않습니다.이클립스 RCP 프로젝트에서 여러 플러그인을위한 aspect 생성하기
내가 구현 위에 관한 몇 가지 질의를 데 :
- 하면이 각 플러그인에 대한 측면을 정의하는 올바른 방법 또는 패키지 이름이 동일하면 우리는 모든 플러그인에 대한 한 측면
- 를 만들 수 있습니다 각 플러그인마다 seprate aspect를 만드는 동안 다른 플러그인이 문제가됩니다.
- 정상적인 로깅 및 예외 로깅을 위해 하나의 애스펙트를 만들려고했지만 저에게 맞지 않았습니다. 정상적인 애스펙트 및 예외 애스펙트에 샘플 첨부.
- 패키지 이름을 제공하지 않고 애스펙트를 정의 할 수있는 방법이 있습니까? 저는 pointcut에서 패키지 이름을 언급하면서 문제가 발생한다고 생각합니다. 플러그인 에 로그 예외에 대한 정보 MSG에게
public aspect RvsFrameworkAspect { public pointcut scope(): within(com.tsystems.rvs.client.gui.framework.*); before() : scope(){ Signature sig=thisJoinPointStaticPart.getSignature(); String infoFormat="Entering ["+sig.getDeclaringType().getName()+"."+sig.getName(); logTrace(infoFormat, thisJoinPointStaticPart, thisEnclosingJoinPointStaticPart); } after() : scope(){ Signature sig=thisJoinPointStaticPart.getSignature(); String infoFormat="Leaving ["+sig.getDeclaringType().getName()+"."+sig.getName()+"]"; logTrace(infoFormat, thisJoinPointStaticPart, thisEnclosingJoinPointStaticPart); } protected synchronized void logTrace(String info, StaticPart location, StaticPart enclosing) { Signature signature = location.getSignature(); String source = signature.getDeclaringTypeName() + ":" + (enclosing.getSourceLocation().getLine()); LoggerMode.getInstance().logInfo(" " + source + " - " + info); } }
코드를 기록하는 데 사용되는 일반적인 측면에 대한
Caused by: org.aspectj.lang.NoAspectBoundException: com_tsystems_rvs_client_gui_user_RvsUserAspect at com.tsystems.rvs.client.gui.user.RvsUserAspect.aspectOf(RvsUserAspect.aj:1) at com.tsystems.rvs.client.gui.user.RvsUserAspect.<clinit>(RvsUserAspect.aj:27)
코드 :
나는 각 플러그인의 한 측면을 가진 경우 오류가 아래에 무엇입니까
public aspect RvsFrameworkExceptionAspect {
public pointcut scope(): within(com.tsystems.rvs..*);
private Map<Throwable, String> loggedThrowables = new WeakHashMap<Throwable, String>();
after() throwing(Throwable t): scope() {
logThrowable(t, thisJoinPointStaticPart,
thisEnclosingJoinPointStaticPart);
}
before (Throwable t): handler(Exception+) && args(t) && scope() {
logThrowable(t, thisJoinPointStaticPart,
thisEnclosingJoinPointStaticPart);
}
protected synchronized void logThrowable(Throwable t, StaticPart location,
StaticPart enclosing) {
if (!loggedThrowables.containsKey(t)) {
loggedThrowables.put(t, null);
Signature signature = location.getSignature();
String source = signature.getDeclaringTypeName() + ":"
+ (enclosing.getSourceLocation().getLine());
LoggerMode.getInstance().logError(" " + source + " - " + t.toString(), t);
}
}
}
내 구현에서 잘못된 일을 도와주세요.
몇 가지 예를 들어 안내해주세요. – Gaurav
답변을 편집하여 도움이되기를 바랍니다. – kriegaex