Files
springboot-demo/target/classes/com/example/demo/controller/AopEventController.class

15 lines
5.5 KiB
Plaintext
Raw Normal View History

<EFBFBD><EFBFBD><EFBFBD><EFBFBD>=<00>
 java/lang/Object<init>()Vjava/util/HashMap
 message Spring Boot 学习中心   java/util/Mapput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;topicsjava/lang/StringAOP 切面编程 事件机制Bean 生命周期 endpoints!%GET /aop - AOP 概念说明#!GET /aop/stats - 性能统计%'GET /aop/event - 事件机制说明',POST /aop/event/publish - 发布用户事件),GET /aop/event/history - 查看事件历史+%GET /aop/ratelimit - 限流测试-title/concepts1/Aspect切面: 横切关注点的模块化32JoinPoint连接点: 程序执行的某个点54Pointcut切入点: 匹配连接点的表达式7/Advice通知: 在连接点执行的动作93Weaving织入: 将切面应用到目标对象; adviceTypes=@Before - 方法执行前?3@After - 方法执行后(无论成功或异常)A'@AfterReturning - 方法成功返回后C&@AfterThrowing - 方法抛出异常后E%@Around - 环绕通知(最强大)GuseCasesI 日志记录K 性能监控M 事务管理O 权限检查Q 限流控制S方法性能统计U descriptionW"由 PerformanceAspect 自动收集Y
statistics [\] ^_.com/example/demo/controller/AopEventControllerperformanceAspect(Lcom/example/demo/aop/PerformanceAspect;
abc de&com/example/demo/aop/PerformanceAspect getStatistics()Ljava/util/Map;gSpring 事件机制i+ApplicationEventPublisher - 事件发布者k @EventListener - 事件监听器m@Async - 异步处理事件ocondition - 条件过滤qbenefitss*解耦:发布者和监听者互不依赖u-扩展:新增监听器无需修改发布者w'异步:耗时操作不阻塞主流程y$测试:更容易进行单元测试{
eventTypes}CREATED - 用户创建UPDATED - 用户更新<00>DELETED - 用户删除<00>LOGIN - 用户登录 [<00> <00><00>eventPublisher+Lcom/example/demo/event/UserEventPublisher;
<00><00><00> <00><00>)com/example/demo/event/UserEventPublisherpublishUserLogin%(Ljava/lang/Long;Ljava/lang/String;)V<00>事件已发布<00> eventType<00>userId<00>userName<00>事件历史记录<00>note<00>"由 UserEventListener 自动记录<00> 请求成功<00>使用 @RateLimited 注解<00>rateLimitStatus [<00> <00><00>rateLimitAspect&Lcom/example/demo/aop/RateLimitAspect;
<00><00><00> <00>e$com/example/demo/aop/RateLimitAspectgetRateLimitStatus userService&Lcom/example/demo/service/UserService;RuntimeVisibleAnnotations8Lorg/springframework/beans/factory/annotation/Autowired;CodeLineNumberTableLocalVariableTablethis0Lcom/example/demo/controller/AopEventController;indexinfoLjava/util/Map;LocalVariableTypeTable5Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>; Signature7()Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;4Lorg/springframework/web/bind/annotation/GetMapping;aopInfovalue/aopgetPerformanceStatsresult
/aop/stats eventInfo/event publishEventE(Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;)Ljava/util/Map;Ljava/lang/Long;Ljava/lang/String;MethodParametersk(Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;)Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;5Lorg/springframework/web/bind/annotation/PostMapping;/event/publish"RuntimeVisibleParameterAnnotations6Lorg/springframework/web/bind/annotation/RequestParam; defaultValueLOGINgetEventHistory/event/history testRateLimit
/ratelimit"Lcom/example/demo/aop/RateLimited;
#测试限流每分钟最多10次
SourceFileAopEventController.java8Lorg/springframework/web/bind/annotation/RestController;8Lorg/springframework/web/bind/annotation/RequestMapping;![<00><00><00><00><00><00><00><00>^_<00><00><00><00><00><00><00>/*<2A><01><00><00> <00><00><00>e<00><00>]<5D>Y<> L+
 <0C>W+<06>YSYSYS<>W+<06>Y SY"SY$SY&SY(SY*S<>W+<2B><00>()*//[7<00>]<00><00>U<00><00><00> U<00><00><00><00><00><00><00>e<00><00><00><>Y<> L+,<18>W+.<08>Y0SY2SY4SY6SY8S<38>W+:<08>Y<SY>SY@SYBSYDS<44>W+F<08>YHSYJSYLSYNSYPS<50>W+<2B><00>ABC9J_Q<00>X<00><00><00><00><00><00><00> <00><00><00><00><00><00><00>[s<00><00>e<00><00>0<>Y<> L+,R<>W+TV<>W+X*<2A>Z<>`<60>W+<2B><00>`abc.d<00>0<00><00>(<00><00><00> (<00><00><00><00><00><00><00>[s<00><00>e<00><00>x<>Y<> L+,f<>W+.<07>YhSYjSYlSYnS<6E>W+p<07>YrSYtSYvSYxS<78>W+z<07>Y|SY~SY<12>SY<12>S<EFBFBD>W+<2B><00>nop4vU|v<00><00>x<00><00>p<00><00><00> p<00><00><00><00><00><00><00>[s<00><00><00><00><00>B*<2A><00>+,<2C><00><>Y<> :
<12><>W<12>-<2D>W<12>+<2B>W<12>,<2C>W<04><00><00> <00><00><00>)<00>4<00>?<00><00>4B<00><00>B<00><00>B<00><00>B<00><00>0<00><00><00> 0<00><00><00> <00><00><00><00><00><00><00><00>[s<00><00><00><00><00><00>s<00><00>e<00>r <20>Y<> L+,<12><>W+<12><12><>W+<2B><00><00><00><00><00><00> <00><00><00><00><00> <00><00><00><00><00><00><00>[s<00><00>e<00><00>0<>Y<> L+
<12><>W+<12><12><>W+<12>*<2A><00><><00><>W+<2B><00><00><00><00><00>.<00><00>0<00><00>(<00><00><00> (<00><00><00><00><00><00><00>[s<00><00><00>J<00> s<00><00><00><00><00><00><00>[s<00>