您的位置:首页 > 编程语言

AOP 切面编程学习笔记

2016-01-23 19:10 141 查看
介绍: aop.aspect这个包里面放的是切面类,这是一个关注点(共同业务)的模块化,这个关注点可能会横切多个对象

    aop.service这个包里面放的是被切面横切的目标,EmpService Deptservice

    aop-beans是配置文件,里面有bean的配置,切入点(切入点里面有一个表达式,可以判断哪些方法需要切入)的配置,通知(判断切入到哪里,执行什么方法)等。

package test;

import he.bean.PersonAction;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import aop.service.DeptService;
import aop.service.DeptServiceImpl;
import aop.service.EmpService;

public class TestAll {

@Test
public void testPersonAction(){
AbstractApplicationContext ac = new ClassPathXmlApplicationContext("aop-beans.xml");
DeptService deptService =   (DeptService) ac.getBean("deptService");
deptService.save();
//EmpService empService =   (EmpService) ac.getBean("empService");
//empService.delete();
}

}


测试类
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: