我按照Spring in action书上的例子做切面的自动代理@Aspect
public class Audience { public Audience(){
}
@Pointcut("execution(* *.perform(..))")//匹配任意类的perform()方法
public void performance(){
}
@Before("performance()")
public void takeSeat(){
System.out.println("takeSeat");
}
@Before("performance()")
public void turnoffCellPhones(){
System.out.println("turnoffCellPhones");
}
@AfterReturning("performance()")
public void applaud(){
System.out.println("applaud");
}
@AfterThrowing("performance()")
public void demandRefund(){
System.out.println("demandRefund");
}
}配置文件是:
<!-- 创建自动代理 -->
<aop:aspectj-autoproxy />
<bean id="audience" class="aoptest.Audience"/>
<!-- 目标Bean -->
<bean id="duke" class="aoptest.Duke"/>如果正确的话,应该在调用任何对象的perform()方法的时候会调用切面里的那些方法啊
可是我在调用duke这个bean里的perform()方法时没有
而且我仔细看了书上的内容,好像就只有这俩步啊
难道我漏了哪里?
public class Audience { public Audience(){
}
@Pointcut("execution(* *.perform(..))")//匹配任意类的perform()方法
public void performance(){
}
@Before("performance()")
public void takeSeat(){
System.out.println("takeSeat");
}
@Before("performance()")
public void turnoffCellPhones(){
System.out.println("turnoffCellPhones");
}
@AfterReturning("performance()")
public void applaud(){
System.out.println("applaud");
}
@AfterThrowing("performance()")
public void demandRefund(){
System.out.println("demandRefund");
}
}配置文件是:
<!-- 创建自动代理 -->
<aop:aspectj-autoproxy />
<bean id="audience" class="aoptest.Audience"/>
<!-- 目标Bean -->
<bean id="duke" class="aoptest.Duke"/>如果正确的话,应该在调用任何对象的perform()方法的时候会调用切面里的那些方法啊
可是我在调用duke这个bean里的perform()方法时没有
而且我仔细看了书上的内容,好像就只有这俩步啊
难道我漏了哪里?
解决方案 »
- struts1安装的时候重启tomcat时候出错
- 什么叫数据库的增量更新?
- 散分:自己开发中的几个源代码程序共享
- 为什么oracle运行一段时间后,会自动断开连接报12560错误,重启电脑后又可以连接了
- 求助:架构 :strus+spring 总是应用一段之后报错
- 字符串简单问题求助~
- JVM和JDK有什么区别!!!!
- 好东西大家享,大量oreilly的电子书java+mysql,喜欢的话顶,其他很多方面不断增加,www.icuc.cn
- 跪求好心的高手进来,也许你的一句话就能使我不再浪费时间了
- jbuilder7+weblogic7详细配置文档(官方文档翻译)下载地址
- 怎么在我的页面上实现邮件登陆(比如163,sina,yahoo等等)
- 关于spring httpInvoker 创建服务端实例的问题,请各位高手赐教!
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<aop:aspectj-autoproxy proxy-target-class="true"/>
<bean id="audience" class="aoptest.Audience"/> <!-- 目标Bean -->
<bean id="duke" class="aoptest.Duke"/>
</beans>试一下这样配置