基于aspectj的aop操作
来源:互联网 发布:a5淘宝客 编辑:程序博客网 时间:2024/06/14 01:57
xml文件的配置:
<?xml version="1.0" encoding="UTF-8"?><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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!--1. 配置对象 --><bean id="book" class="webdemo.Book"></bean><bean id="mybook" class="webdemo.MyBook"></bean><!-- 2.配置aop操作 --><aop:config><!-- 2.1配置切入点 --><aop:pointcut expression="execution(* webdemo.Book.*(..))" id="pointcut1"/><!-- 2.2配置切面 --><aop:aspect ref="mybook"><aop:before method="before" pointcut-ref="pointcut1"/></aop:aspect></aop:config></beans>
创建代理类和被代理类
package webdemo;public class Book {public void demo1(){System.out.println("haha...");}}
package webdemo;public class MyBook{public void before(){System.out.println("前置通知!");}}
创建测试类:
package webdemo;import javax.transaction.Transactional;import org.junit.Test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class TestDemo { @Testpublic void test2(){ ApplicationContext ap=new ClassPathXmlApplicationContext("applicationContext.xml"); Book book=(Book) ap.getBean("book"); book.demo1();}}
测试输出:
前置通知!
haha...
阅读全文
0 0
- 基于aspectj的aop操作
- day3_Spring_02_基于aspectj的注解aop操作
- 基于@AspectJ的AOP
- 基于@AspectJ的AOP
- Aspectj的AOP操作
- 基于aspectj的注解aop
- Spring-AOP:基于AspectJ注解的AOP
- Spring的基于AspectJ的AOP开发
- 基于@AspectJ的AOP的使用
- Spring基于annotation的AOP(AspectJ)
- Spring基于注解@AspectJ的AOP
- Spring基于注解@AspectJ的AOP
- Spring详解------------基于@ASpectJ的AOP
- 6.基于@AspectJ和Schema的AOP
- 使用AspectJ基于注解的Aop
- spring基于AspectJ的AOP编程
- 9.4.Spring 中基于 AOP 的 @AspectJ
- 基于Aspectj的注解操作
- 实现一个Android锁屏App的难点总结
- Consst 用法
- 存储空间(Bucket)
- jquery 对 select 中option进行赋值,取值,append,remove操作
- Caffe学习:Forward and Backward
- 基于aspectj的aop操作
- 2017多校联合第五场1011/hdu6095Rikka with Competition(排序)
- ansible之patterns
- hpu暑假训练 B
- 【技术贴】ArcGIS Runtime for Xamarin 使用SPK构建逼真的三维场景
- spring声明式事务
- javaweb学习总结(十三)——JSP原理
- 属性的设置和获取
- mysql出现不开放远程访问权限