這兩天學習JSF / AspectJ / Refactoring

這幾天在學習JSF / AspectJ / Refactoring, 以及在eclipse下的使用。

AspectJ中的四個概念:

Pointcuts  - 切入點(類似於一個動作,一件事情,甚至一組動作或事情等等),具體可以是一個或者幾個方法,實例化,賦值(set,get),異常,block ... 具體有一下這些(後面幾個我的理解也是模糊的,那位高手可以準確這些概念,謝謝先):
Methods and Constructors
call(Signature)every call to any method or constructor matching Signature at the call site
execution(Signature)every execution of any method or constructor matching Signature
Fields
get(Signature)every reference to any field matching Signature
set(Signature)every assignment to any field matching Signature. The assigned value can be exposed with an args pointcut
Exception Handlers
handler(TypePattern)every exception handler for any Throwable type in TypePattern. The exception value can be exposed with an args pointcut
Advice
adviceexecution()every execution of any piece of advice
Initialization
staticinitialization(TypePattern)every execution of a static initializer for any type in TypePattern
initialization(Signature)every initialization of an object when the first constructor called in the type matches Signature, encompassing the return from the super constructor call to the return of the first-called constructor
preinitialization(Signature)every pre-initialization of an object when the first constructor called in the type matches Signature, encompassing the entry of the first-called constructor to the call to the super constructor
Lexical
within(TypePattern)every join point from code defined in a type in TypePattern
withincode(Signature)every join point from code defined in a method or constructor matching Signature
Instanceof checks and context exposurethis(Type or Id)every join point when the currently executing object is an instance of Type or Id's type target(Type or Id)every join point when the target executing object is an instance of Type or Id's type args(Type or Id, ...)every join point when the arguments are instances of Types or the types of the Ids Control Flowcflow(Pointcut)every join point in the control flow of each join point P picked out by Pointcut, including P itself cflowbelow(Pointcut)every join point below the control flow of each join point P picked out by Pointcut; does not include P itself Conditionalif(Expression)every join point when the boolean Expression is trueCombination! Pointcutevery join point not picked out by PointcutPointcut0 && Pointcut1each join point picked out by both Pointcut0 and Pointcut1Pointcut0 || Pointcut1each join point picked out by either Pointcut0 or Pointcut1( Pointcut )

each join point picked out by Pointcut

Type Patterns
TypeNamePatternall types in TypeNamePattern
SubtypePatternall types in SubtypePattern, a pattern with a +.
ArrayTypePatternall types in ArrayTypePattern, a pattern with one or more []s.
!TypePatternall types not in TypePattern
TypePattern0 && TypePattern1all types in both TypePattern0 and TypePattern1
TypePattern0 || TypePattern1all types in either TypePattern0 or TypePattern1
( TypePattern )

all types in TypePattern

Advice
before( Formals )
runs before each join point
after( Formals ) returning [ ( Formal ) ]
runs after each join point that returns normally. The optional formal gives access to the returned value
after( Formals ) throwing [ ( Formal ) ]
runs after each join point that throws a Throwable. If the optional formal is present, runs only after each join point that throws a Throwable of the type of Formal, and Formal gives access to the Throwable exception value
after( Formals )
runs after each join point regardless of whether it returns normally or throws a Throwable
Type around( Formals )
runs in place of each join point. The join point can be executed by calling proceed, which takes the same number and types of arguments as the around advice.
Inter-type member declarations

Each inter-type member is one of

Modifiers ReturnType OnType . Id ( Formals ) [ throws TypeList ] { Body }
a method on OnType.
abstract Modifiers ReturnType OnType . Id ( Formals ) [ throws TypeList ] ;
an abstract method on OnType.
Modifiers OnType . new ( Formals ) [ throws TypeList ] { Body }
a constructor on OnType.
Modifiers Type OnType . Id [ = Expression ] ;
a field on OnType.
發佈了34 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章