AspectJ 连接点与切入点深度解析
1. AspectJ 连接点基础
1.1 thisJoinPointStaticPart 类方法
thisJoinPointStaticPart
类作为 thisJoinPoint
的辅助类,仅能访问上下文的静态部分。可通过 getStaticPart()
方法或 thisJoinPointStaticPart
对象来访问静态部分,其包含的方法如下:
- Signature getSignature()
:获取签名。
- SourceLocation getSourceLocation()
:获取源位置。
- String getKind()
:获取种类。
- String toString()
:转换为字符串。
- String toShortString()
:转换为短字符串。
- String toLongString()
:转换为长字符串。
这些方法的功能与 thisJoinPoint
部分列出的方法相同。
1.2 示例连接点
1.2.1 方法调用接收和执行
方法调用接收连接点基于对象关联的方法会被其他方法调用的假设。以 Stack
类为例: