首页 文章 精选 留言 我的

精选列表

搜索[测试ROI],共10000篇文章
优秀的个人博客,低调大师

测试AOP五种切面通知的优先级次序

通知类型 在基于Spring AOP编程的过程中,基于AspectJ框架标准,spring中定义了五种类型的通知,它们分别是: 前置通知 (@Before) 。 返回通知 (@AfterReturning) 。 异常通知 (@AfterThrowing) 。 后置通知 (@After)。 环绕通知 (@Around) :(优先级最高) 通知执行顺序 将上面的所有通知类型写入同一个切面中,它的执行顺序为: 代码展示 package com.cy.pj.common.aspect; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; @Aspect @Component public class SysTimeAspect { /** * 切入点 */ @Pointcut("bean(sysMenuServiceImpl)") public void doTime(){} @Before("doTime()") public void doBefore(JoinPoint jp){ System.out.println("time doBefore()"); } @After("doTime()") public void doAfter(){//类似于finally{}代码块 System.out.println("time doAfter()"); } /**核心业务正常结束时执行 * 说明:假如有after,先执行after,再执行returning*/ @AfterReturning("doTime()") public void doAfterReturning(){ System.out.println("time doAfterReturning"); } /**核心业务出现异常时执行 * 说明:假如有after,先执行after,再执行Throwing*/ @AfterThrowing("doTime()") public void doAfterThrowing(){ System.out.println("time doAfterThrowing"); } @Around("doTime()") public Object doAround(ProceedingJoinPoint jp) throws Throwable{ System.out.println("doAround.before"); try { Object obj=jp.proceed(); return obj; }catch(Throwable e) { System.out.println("doAround.error-->"+e.getMessage()); throw e; }finally { System.out.println("doAround.after"); } } } 代码正常结束 代码出现异常

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码