spring aop

切面:要织入目标对象的抽象
切入点: 对连接点的定义(在切面里面的)
连接点: 要拦截方法

@Aspect
class interceptorHandler{ //拦截器处理类
@pointcut("execution(* add*(..))") //目标类中的方法称为连接点
private void addMethodPointCut(){}; //切入点:连接点在切面类里面的定义

@Before("addMethodPointCut()") //前置型的通知
private void checkSecurity(){ //通知
//安全检查
}

@After("addMethodPointCut()") //前置型的通知
private void log(){ //通知
//做完了之后记日志
}
}

 

 

基于接口的代理:JDK反射的方式
基于类的代理:CGLIB
代理对象会放到IOC容器中
@Resource 从IOC容器中获取实例,并且通过属性注入进来
@Component 加入到Ioc容器中

posted on 2017-03-22 19:49  豆沙包没有肉  阅读(112)  评论(0编辑  收藏  举报

导航