1、 直入检查
declare error : <pointcut> : <message>;编译器如果发现error,将会打印message,然后停止编译
declare warning : <pointcut> : <message>;产生编译警告,但不会停止编译
2、Aspect类中可以有构造方法,但是必须要有空参数的构造方法,以便系统实例化之。
3、抽象的Aspect:
4、Aspect可以继承的抽象Aspect类或者Java类,或者实现Aspect接口或者java接口
5、Aspect不能直接实例化,系统在适当的时候实例化Aspect,而不是我们手动的new实例化
6、Aspect不能继承具体的Aspect类
7、Per-type关联和Per-Object区别在于:Aspect实例类与Class关联,而 Per-Object中Aspect实例类与Object关联。就行类的静态变量和实例变量
8、优先级:declare precedence : Auth*, PoolingAspect, LoggingAspect;declare precedence : AuthenticationAspect, *;declare precedence : *, CachingAspect;
declare precedence : Auth*, PoolingAspect, AuthenticationAspect;会产生编译错误
子Aspect比父Aspect优先级要高Because only concrete aspects in the declare
precedence clause are designated for precedence ordering, declaring a base aspect
(which is always abstract) to have higher precedence over subaspects has no effect.
In other words, there is no way to declare higher precedence for base aspects.
9、advice的顺序跟他们在Aspect中的顺序一样
10、特权Aspect: privileged public aspect PrivilegeTestAspect {创建的Aspect可以访问其他类的私有属性
11、注解的Aspect使用Aspects.aspectOf()获取Aspect实例
12、注解的Aspect在类上使用@DeclarePrecedence限制优先顺序(必须使用类的全限定名称,除非这个类在Aspect声明的包下)
13、@Pointcut("if()")
public static boolean debugEnabled() {
return logLevel >= DEBUG;
}if的使用:必须是public和static修饰
@Pointcut("if() && execution(* *(..))")
public static boolean returnsPrimitive(JoinPoint.StaticPart jp) {
return ((MethodSignature)jp.getSignature())
.getReturnType().isPrimitive();
}
if the pointcut logic needs to utilize a join point object equivalent to this-
JoinPoint, thisJoinPointStaticPart, or thisEnclosingJoinPointStaticPart, it
must declare a parameter of the corresponding types (JoinPoint, JoinPoint.StaticPart,
or JoinPoint.EnclosingStaticPart) and use it inside the method body. For
example, the following pointcut selects the execution of join points whose return type
is a primitive:
14、@DeclareMixin("ajia.banking.domain.*")
public Serializable serializableMixin() {
return null;
}