### aspect的定義
1. 定義一個切面: \[關鍵字aspect\] 這定義Java類的語法類似;例:public aspect HelloAspect
2. 定義pointcut: [修飾符\(public,protected.....\)] pointcut poincutName\(\) : 表達式;
3. 定義advice: 通知類型\(\) : pointcut名字\(\){ 處理邏輯}
示例:
```
package com.aspectj.demo.aspect;
public aspect HelloAspect {
pointcut HelloWorldPointCut() : execution(* main(..));
before() : HelloWorldPointCut(){
System.out.println("all cut====>");
}
}
```
### aspect通知類型
* before 目標方法執行前執行,前置通知
* after 目標方法執行后執行,后置通知
* after returning 目標方法返回時執行 ,后置返回通知
* after throwing 目標方法拋出異常時執行 異常通知
* around 在目標函數執行中執行,可控制目標函數是否執行,環繞通知
示例:
```
/**
* 定義前置通知
*
* before(參數):連接點函數{
* 函數體
* }
*/
before():authCheck(){
System.out.println("sayHello方法執行前驗證權限");
}
/**
* 定義后置通知
* after(參數):連接點函數{
* 函數體
* }
*/
after():recordLog(){
System.out.println("sayHello方法執行后記錄日志");
}
/**
* 定義后置通知帶返回值
* after(參數)returning(返回值類型):連接點函數{
* 函數體
* }
*/
after()returning(int x): get(){
System.out.println("返回值為:"+x);
}
/**
* 異常通知
* after(參數) throwing(返回值類型):連接點函數{
* 函數體
* }
*/
after() throwing(Exception e):sayHello2(){
System.out.println("拋出異常:"+e.toString());
}
/**
* 環繞通知 可通過proceed()控制目標函數是否執行
* Object around(參數):連接點函數{
* 函數體
* Object result=proceed();//執行目標函數
* return result;
* }
*/
Object around():aroundAdvice(){
System.out.println("sayAround 執行前執行");
Object result=proceed();//執行目標函數
System.out.println("sayAround 執行后執行");
return result;
}
```
- java演變
- JDK各個版本的新特性
- JDK1.5新特性
- JDK1.6新特性
- JDK1.7新特性
- JDK1.8新特性
- JAVA基礎
- 面向對象特性
- 多態
- 方法重載
- 方法重寫
- class
- 常量
- 訪問修飾符
- 類加載路徑
- java-equals
- 局部類
- java-hashCode
- Java類初始化順序
- java-clone方法
- JAVA對象實例化的方法
- 基礎部分
- JAVA基礎特性
- JAVA關鍵字
- javabean
- static
- 日期相關
- final
- interface
- 函數式接口
- JAVA異常
- 異常屏蔽
- try-with-resource資源泄露
- JAVA引用
- WeakReference
- SoftReference
- PhantomReference
- 位運算符
- try-with-resource語法糖
- JDK冷知識
- JAVA包裝類
- JAVA基本類型與包裝類
- java.lang.Boolean
- java.lang.Integer
- java.lang.Byte
- java.lang.Short
- java.lang.Long
- java.lang.Float
- java.lang.Double
- java.lang.Character
- 日期相關
- TemporalAdjusters
- String
- 字符串常量池
- String拼接
- String編譯期優化
- StringBuilder&StringBuffer
- intern
- 注解
- java標準注解
- 內置注解
- 元注解
- 自定義注解
- 注解處理器
- JVM注解
- Java8 Annotation新特性
- 反射-Reflective
- Reflection
- Class
- Constructor
- Method
- javabean-property
- MethodHandles
- 泛型
- 類型擦除
- bridge-method
- Accessor&Mutator方法
- enum
- JAVA數組
- finalize方法
- JAR文件
- JAVA高級編程
- CORBA
- JMX
- SPI
- Java SPI使用約定
- ServiceLoader
- 實際應用
- IO
- 工具類
- JDK常用工具類
- Objects
- System
- Optional
- Throwable
- Collections
- Array
- Arrays
- System
- Unsafe
- Number
- ClassLoader
- Runtime
- Object
- Comparator
- VarHandle
- 數據結構
- 棧-Stack
- 隊列(Queue)
- Deque
- PriorityQueue
- BlockingQueue
- SynchronousQueue
- ArrayBlockingQueue
- LinkedBlockingQueue
- PriorityBlockingQueue
- ConcurrentLinkedQueue
- 列表
- 迭代器
- KV鍵值對數據類型
- HashMap
- TreeMap
- Hash沖突
- ConcurrentHashMap
- JDK1.7 ConcurrentHashMap結構
- jdk7&jdk8區別
- 集合
- Vector
- Stack
- HashSet
- TreeSet
- ArrayList
- LinkedList
- ArrayList && LinkedList相互轉換
- 線程安全的集合類
- 集合類遍歷性能
- 并發容器
- CopyOnWriteArrayList
- ConcurrentHashMap
- 同步容器
- BitMap
- BloomFilter
- SkipList
- 設計模式
- 設計模式六大原則
- 單例模式
- 代理模式
- 靜態代理
- 動態代理
- JDK動態代理
- cglib動態代理
- spring aop
- 策略模式
- SpringAOP策略模式的運用
- 生產者消費者模式
- 迭代器模式
- 函數式編程
- 方法引用
- 性能問題
- Lambda
- Lambda類型檢查
- Stream
- findFirst和findAny
- reduce
- 原始類型流特化
- 無限流
- 收集器
- 并行流
- AOP
- 靜態織入
- aspect
- aspect的定義
- AspectJ與SpringAOP
- 動態織入
- 靜態代理
- 動態代理
- JDK動態代理
- CGLib動態代理
- Spring AOP
- SpringAOP五種通知類型
- @Before
- @AfterReturning
- @AfterThrowing
- @After
- @Around
- Aspect優先級
- SpringAOP切點表達式
- within
- execution
- 嵌套調用
- 系統優化與重構
- 重疊構造器模式
- 工具類構造器優化
- 常見面試題
- new Object()到底占用幾個字節
- 訪問修飾符
- cloneable接口實現原理
- 異常分類以及處理機制
- wait和sleep的區別
- 數組在內存中如何分配
- 類加載為什么要使用雙親委派模式,有沒有什么場景是打破了這個模式
- 類的實例化順序
- 附錄
- JAVA術語
- FAQ
- 墨菲定律
- 康威定律
- 軟件設計原則
- 阿姆達爾定律
- 字節碼工具
- OSGI