示例需求:当我们调用fastjson里面的toJSONString方法时,我们在这个方法上加上环绕通知,众所周知,这个方法是第三方jar包fastjson里面提供的一个方法,我们要做的就是切到这个方法上,然后加环绕通知。步骤如下:
1、写一个服务,该服务使用了fastjson里面的toJSONString方法,代码如下:
public class JSONService {
public String parse2String(Object obj){
return JSON.toJSONString(obj);
}
}
2、写一个切面,并在该切面上配置环绕通知,代码如下:
@Aspect
public class JSONAspect {
<span style="color:#000099;">public static JSONAspect ajc$perSingletonInstance;
private static Throwable ajc$initFailureCause;
static {
try {
ajc$postClinit();
} catch (Throwable localThrowable) {
ajc$initFailureCause = localThrowable;
}
}
private static void ajc$postClinit() {
ajc$perSingletonInstance = new JSON