Spring Aop
来源:互联网 发布:网络流行语英语怎么说 编辑:程序博客网 时间:2024/05/16 05:07
package com.test;
public class PersonServiceBean
{
public String getPersonName(Integer id) {
System.out.println("我是getPersonName()方法");
return "XXX";
}
public void save(String name) {
System.out.println("我是save()方法");
}
public void update(String name, Integer id) {
System.out.println("我是update()方法");
}
}
package com.test;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class MyInterceptor {
@Pointcut("execution (* com.test.PersonServiceBean.*(..))")
private void anyMethod() {}
@Before("anyMethod()")
public void doAccessCheck() {
System.out.println("前置通知");
}
}
package com.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringAOPTest
{
public static void main(String[] args)
{
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
PersonServiceBean personService = (PersonServiceBean)ctx.getBean("personService");
personService.save("xxx");
}
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<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"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<bean id="myInterceptor" class="com.test.MyInterceptor" />
<bean id="personService" class="com.test.PersonServiceBean" />
</beans>
- AOP、Spring的AOP
- AOP--Spring AOP
- Spring AOP 嵌套AOP
- spring AOP
- Spring AOP
- Spring AOP
- spring aop
- Spring AOP
- spring AOP
- spring aop
- Spring aop
- Spring-AOP
- Spring AOP
- spring aop
- spring aop
- Spring AOP
- Spring AOP
- Spring Aop
- 转:编译Python源代码
- ZOJ 1027 Human Gene Functions
- EasyEclipse for PHP软件中php程序文件中文注释乱码
- Linux开发基础(2010.7.11-2010.7.14)——学习笔记
- 一点感想
- Spring Aop
- 单链表的创建 头插法 Java数据结构与算法
- csdn的blackberry论坛开了
- Rave 报表入门
- Windows下去SVN版本管理的注册表文件
- 一篇文章的宿命
- 设备驱动安装程序设计(一)
- vs2008成功远程调试qt for wince程序
- java swing实现手写板电子签名系统