1. 程式人生 > >Spring Aop總結

Spring Aop總結

join spring容器 其他 新的 conf 註解 基於 prop 參數


一.Spring介紹
Spring它是一個一站式的分層輕量級框架
1.Spring體系結構
1.core container
a) beans與core他們提供sping框架最基本的功能,它包含ioc於di
b)context 上下文對象,基於beans與cores
c)spel它是sping提供的一個表達式語言
2.Data access/integration
# 二.IOC與DI (重點掌握)★★★★★
ioc:inversion of Controller 控制反轉 把對象的創建的權利交給了spring容器來管理
IOC是原來由我們自己實例化的對象交給spring容器
di: 依賴註入 spring在創建bean 對象是,動態的將屬性註入到bean對象中
# 4.初始化方式: 三種(★★★

無參的構造器,靜態工廠,實例工廠)
5.BeanFactory和ApplicationContext接口的區別?
#6.bean的作用域(重點掌握)★★★★ scope:singleton prptotype
singleton : 單例 代表在 spring ioc容器中只有一個Bean實例(默認的scope)
prototype :多例每次從spring容器獲取時,都會返回一個新的實例
7.生命周期,自定義初始化和銷毀操作
三,Bean獲取與實例化
1.註入方式:構造器註入和setter方法註入
構造器註入: <construct-arg index="參數的所有" type="參數類型" value=“賦值”
# ★★★★★
setter: <property name="屬性名稱" value="賦值" ref="引用其它的bean的id(name)">
集合: list,map,set,properties
2. c和p名稱空間: c是簡化了構造器 p:setter方法簡化
3. spel :它可以提供在程序運行時構造復雜表達式來完成對象屬性存儲及方法調用等
# ★★★★★4. bean @component @repository 持久層 @service 業務層 @controller控制層
# ★★★★★5. 屬性註解: 簡化類型 和引用類型
@value("賦值")
根據類型 : @autowired
根據名稱:@[email protected]
/* */(‘名稱‘) @Resource(name="名稱")
開啟註解:<context:component-scan-package="">
其他註解: @scope("singleton") @postConstruct @perDestroy
6.集成 junit
1)jar包
2)@runwith() @contextConfiguration
# ★★★7,web中集成spring框架
1)web包
2)ContextLicaderListener
3)指定配置文件的路徑 contextConfigLication

# -------------------day02-----Spring AOP--------------- #
AOP(Aspect切面 Oriented面向 Programming編程) 面向切面編程

1.aop簡介(日誌記錄,性能統計,安全控制,事物處理,異常處理)
#2.aop相關術語★★★★★
目標對象(target):指的是需要被增強的對象
連接點(join point):目標對象中的方法
切入點(pointcut):表示一組 joint point 通過連接點判斷要具體攔截的方法
通知(advice) : 切入點中做的增強
切面(aspect) : 切入點+通知
織入(weaving) : 目標對象產生代理的過程
代理對象 : 目標對象增強後產生的做增強功能的代理類
#3.AOP底層實現?★★★
AOP分為靜態AOP和動態AOP
Spring的AOP為動態AOP,實現的技術為: JDK提供的動態代理技術 和 CGLIB(動態字節碼增強技術)
4.jdk動態代理和cglib動態代理
5.Spring的傳統aop編程
五種通知: 前置通知 ,後置通知, 環繞通知, 異常通知, 引介通知
導包 : aop與aop聯盟
<import resource=""/>
# 基於aspectJ切點傳統開發★★★★

#6.切點表達式寫法★★★★★
7.Spring整合aspectj框架實現的aop 通知類型?
#8.基於xml配置實現, 參數 ★★★★
增強的類需要實現其他接口嗎?
<aop:config>
<aop:aspect tef="?">
<aop:pointcut expression="execution(* *.del(..))" id="delProintCut"/>
<>

JoinPoint參數?
代理方式的選擇: proxy-target-class設置為?

關於代理方式選擇
在spring的aop中,

Spring Aop總結