いくつかのメッセージのログを取るためには、あるメソッド(または今のところすべてのメソッド)の前に、Aspectのメソッドを呼び出す必要があります。私のアプリケーションは正常に動作していますが、Aspectクラスのメソッドは呼び出されません。ZKでAOPを設定してメソッドを傍受する
ローカルアプリケーションで同じフォルダ構造で同じカットポイントを試しましたが、ZKに含めるときに問題があります。また、AOPをサポートするように私のapplication-context.xml
を修正しました。
これは私のアスペクトクラスです:
package com.mypckg.services.impl;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class MyIntercpeter {
@Pointcut("execution(* com.mypckg.services.impl.MyService.getStudents(..))")
public void performance() {
}
@Before("performance()")
public void doSomethingBeforeExecution() {
System.out.println("Before execution method called...");
}
@AfterReturning("performance()")
public void doSomethingAfterExecution() {
System.out.println("After execution method called...");
}
}
私はapplication-context.xml
で行った変更は、私が何かを
<beans .........
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
..........
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
.....
<aop:aspectj-autoproxy />
<context:annotation-config />
をしないのですされていますか?前もって感謝します。
私は春の設定ファイルですべての豆を宣言しました。私は春のアプリケーションコンテキストファイルの変更部分だけを与えました。私たちはSpring 2.5を使用しています –
言及するだけで:パフォーマンスを測定するために注釈と注釈プロセッサをすでに持っているperf4jを使用することができます。 [http://perf4j.codehaus.org/devguide.html#Unobtrusive_Logging_with_Profiled_and_AOP](http://perf4j.codehaus.org/devguide.html#Unobtrusive_Logging_with_Profiled_and_AOP)。 –
zk.xml設定でspring beanリゾルバを設定しましたか? –