当前位置:网站首页>Extraction of the same pointcut
Extraction of the same pointcut
2022-07-03 16:16:00 【No development, no work】
1. Extraction of the same entry point
Before extraction :
package com.spring.spring5.annotaion;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
// Enhanced classes
@Aspect// Represents the generation of proxy objects
@Component
public class UserProxy {
// Pre notice
@Before(value = "execution(* com.spring.spring5.annotaion.User.add(..))")// As a pre notification
public void before(){
System.out.println("Before......");
}
// Final notice , Execute after the method with or without exceptions
@After(value = "execution(* com.spring.spring5.annotaion.User.add(..))")
public void after(){
System.out.println("After......");
}
// The rear notice ( Return to inform ), Execute when the method ends without exception
@AfterReturning(value = "execution(* com.spring.spring5.annotaion.User.add(..))")
public void afterReturning(){
System.out.println("AfterReturning......");
}
// Abnormal notice ,add() Only when there are exceptions
@AfterThrowing(value = "execution(* com.spring.spring5.annotaion.User.add(..))")
public void afterThrowing(){
System.out.println("AfterThrowing......");
}
// Surrounding the notification , Execute before and after method
@Around("execution(* com.spring.spring5.annotaion.User.add(..))")
public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
System.out.println("Around Before ......");
proceedingJoinPoint.proceed();
System.out.println("Around after ......");
}
}
After extraction :
package com.spring.spring5.annotaion;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
// Enhanced classes
@Aspect// Represents the generation of proxy objects
@Component
public class UserProxy {
// Extracting the same entry point
@Pointcut("execution(* com.spring.spring5.annotaion.User.add(..))")
public void pointdemo() {
}
// Pre notice
@Before(value = "pointdemo()")// As a pre notification
public void before(){
System.out.println("Before......");
}
// Final notice , Execute after the method with or without exceptions
@After(value = "pointdemo()")
public void after(){
System.out.println("After......");
}
// The rear notice ( Return to inform ), Execute when the method ends without exception
@AfterReturning(value = "pointdemo()")
public void afterReturning(){
System.out.println("AfterReturning......");
}
// Abnormal notice ,add() Only when there are exceptions
@AfterThrowing(value = "pointdemo()")
public void afterThrowing(){
System.out.println("AfterThrowing......");
}
// Surrounding the notification , Execute before and after method
@Around("pointdemo()")
public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
System.out.println("Around Before ......");
proceedingJoinPoint.proceed();
System.out.println("Around after ......");
}
}
The two have the same effect
边栏推荐
- Microservice - fuse hystrix
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (III)
- nifi从入门到实战(保姆级教程)——flow
- Redis高可用与持久化
- Getting started with Message Oriented Middleware
- “用Android复刻Apple产品UI”(2)——丝滑的AppStore卡片转场动画
- [redis foundation] understand redis master-slave architecture, sentinel mode and cluster together (Demo detailed explanation)
- Is it safe to open an account with flush?
- pycharm错Error updating package list: connect timed out
- Microservices - load balancing ribbon
猜你喜欢
Microservice - declarative interface call openfeign
Function introduction of JMeter thread group
几种常见IO模型的原理
面试官:JVM如何分配和回收堆外内存
探索Cassandra的去中心化分布式架构
MB10M-ASEMI整流桥MB10M
Microservice - Nacos registration center and configuration center
Distributed task scheduling XXL job
How to use AAB to APK and APK to AAB of Google play apps on the shelves
Stm32f103c8t6 firmware library lighting
随机推荐
Shell script import and export data
程序猿如何快速成长
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
坚持输出需要不断学习
From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
How to thicken the brush in the graphical interface
用同花顺炒股开户安全吗?
Why does the std:: string operation perform poorly- Why do std::string operations perform poorly?
【Proteus仿真】8×8LED点阵屏仿电梯数字滚动显示
About text selection in web pages and counting the length of selected text
工资3000,靠“视频剪辑”月入40000:会赚钱的人,从不靠拼命!
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
Go language self-study series | if else if statement in golang
Persisting in output requires continuous learning
Distributed task scheduling XXL job
EditText request focus - EditText request focus
Initial test of scikit learn Library
几种常见IO模型的原理
[200 opencv routines] 217 Mouse interaction to obtain polygon area (ROI)
TCP拥塞控制详解 | 3. 设计空间