2
在某些方法(或截至目前所有方法)之前,我必須調用某個方面的方法來記錄某些消息。我的應用程序運行正常,否則Aspect類的方法都不會被調用。使用ZK配置AOP來攔截方法
我已經在我的本地應用程序中嘗試過相同的文件夾結構中的相同的cutpoint,但是當我嘗試將它與ZK包含在一起時,我遇到了問題。我也修改了我的application-context.xml
以支持AOP。
這是我的切面類:
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配置文件中聲明瞭所有的bean。我只給出了spring應用程序上下文文件的修改部分。我們正在使用Spring 2.5 – 2012-03-20 04:41:13
只需要提一下:您可以使用已經有註釋和註釋處理器的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)。 – 2012-03-20 08:05:48
您是否在zk.xml配置中配置了spring bean解析器? – 2012-03-20 19:10:24