ioc:控制反转,不需要new 对象,由ioc容器来实例化对象(包括创建,依赖注入)
aop:把和业务无关,诸如日志记录这些功能封装起来,提高代码的复用性
aop使用情景:
@Before("execution(* chapter04.concert.Performance.perform(..))")
public void takeSeats() {
System.out.println("Taking seats");
}
@Before("execution(* chapter04.concert.Performance.perform(..))")
public void silenceCellPhones() {
System.out.println("Silencing cell phones");
}
可以定义可复用的切点表达式
@Pointcut("execution(* chapter04.concert.Performance.perform(..))")
public void perform() {
}
@autowired 注入 by Type , @resource 注入 by name
ioc实现:反射,依赖注入
aop实现:动态代理
浙公网安备 33010602011771号