日期:2014-05-17 浏览次数:20940 次
aspectj的核心包 | http://eclipse.org/aspectj/downloads.php | 下载后解压缩,在目录中有aspectjrt.jar,aspectjweaver.jar(还有一些其他的,我们暂时只用这两个) |
eclipse插件(ajdt) | http://www.eclipse.org/ajdt/downloads/ | 下载与eclipse相配的ajdt |
-javaagent:"C:\JAVA\APPServer\Tomcat\apache-tomcat-6.0.18\lib\aspectjweaver.jar"
<?xml version="1.0" encoding="UTF-8"?> <aspectj> <aspects> <concrete-aspect name="com.test.framework.aspect._Smsf_Aspect" extends="com.test.framework.aspect.AbstractAspect"> <pointcut name="runAccess" expression=" execution(* com.test.framework.web.action.*.*(..)) || execution(* com.test.demo.web.handle.*.*(..)) || execution(* com.test.demo.dao.impl.*.*(..))"/> </concrete-aspect> </aspects> </aspectj>
@Aspect public abstract class AbstractAspect { // abstract pointcut: no expression is defined @Pointcut abstract void runAccess(); @Before("runAccess()") public void before(JoinPoint jp) { LogLogic.writeMethodStartlog(jp); } @After("runAccess()") public void after(JoinPoint jp) { LogLogic.writeMethodEndlog(jp); } }
更改catalina.bat文件的JAVA_OPTS属性: set JAVA_OPTS=%JAVA_OPTS% -javaagent:"C:\JAVA\APPServer\Tomcat\apache-tomcat-6.0.18\lib\aspectjweaver.jar"