1:Eclipse安装aspectj
http://www.eclipse.org/ajdt/downloads/这个里面有对应版本,可以选择url更新。
2:选中已有工程 aspectj tools添加aspectj jar
3:小例子
public aspect LogAj {
pointcut beforeMsg() : execution(* com.jz.dao.impl.*.save*(..));
pointcut afterMsg() : execution(* com.jz.dao.impl.*.save*(..));
pointcut aroundMsg() : execution(* com.jz.dao.impl.*.save*(..));
before() : beforeMsg() {
System.out.println("before aspectj");
}
Object around() : aroundMsg() {
System.out.println("around aspectj");
Object result = proceed();
return result;
}
after() : afterMsg() {
System.out.println("after aspectj");
}
}
例子很简单,就是对dao里的save操作切点,打印点相关信息。
让我奇怪的是before after around的顺序有关系,把around放在after下会直接导致编译不过去,此外around与其它的优点区别proceed(),这我感觉有点点跟filter里的chain类似。
分享到:
相关推荐
aspectj
aspectj-1.7.0.jar aspectj的包
许多开发人员都对aop感兴趣 —— 特别是对aspectj感兴趣,这个java编程语言的开源扩展明确支持aop方法。然而,尽管aspectj纳入在eclipse这个日益流行的java开源ide之内,但是找到一种实用、非理论的方式来学习这种...
精通AspectJ(面向方面的java编程指南)一书的示例代码。
aspectj-1.9.5.jar 官网下载地址:https://www.eclipse.org/aspectj/downloads.php
Aspect-Oriented Programming with AspectJ
This book is an introduction to AOP with AspectJ and Eclipse and shows how to create a productive AO development environment by using the AspectJ Development Tools for Eclipse (AJDT). Tools have an ...
Spring AOP的AspectJ支持jar包; 包括: com.springsource.net.sf.cglib-2.2.0.jar com.srpingsource.org.aopalliance-1.0.0.jar com.srpingsource.org.aspectj.weaver-1.68.RELEASE.jar
AspectJ shows its real power when combined with Spring. This new edition focuses on Spring-AspectJ integration, which is a major feature of Spring 2.5. Readers will find this edition immensely helpful...
Manning.AspectJ.in.Action.2nd.Edition.Sep.2009.eBook-BBL 书名:AspectJ.in.Action.2nd.Edition《AspectJ实战第2版》 作者: Ramnivas Laddad, Rod Johnson 出版商:Manning. 发行日期:2009年9月28日 ISBN:...
aspectj-1.9.1.jar和aspectj-1.9.1.src.jar包。用于切面编程。 aspectj-1.9.1.jar和aspectj-1.9.1.src.jar包。用于切面编程。 aspectj-1.9.1.jar和aspectj-1.9.1.src.jar包。用于切面编程。 原来积分太高,我现在...
aspectj.weaver最新的185版本
Aspectj开发指南 博文链接:https://g007n.iteye.com/blog/249602
org.aspectj,aspectj项目库(org.aspectj).zip,建筑物
aspectj-1.7.1.jar
Spring 使用AspectJ 实现 AOP(基于xml文件、基于注解)
Aop之AspectJ解读demo,主要是讲解Aspectj使用框架以及使用场景入门实例
学习aspectJ,帮助学习面向方面的知识。
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
aspectj架包,版本号:aspectj-1.6.9.jar