当前位置: 首页 > news >正文

龙之向导外贸网站网址怎么自己创建网页

龙之向导外贸网站网址,怎么自己创建网页,汕头中小企业网站制作,济南营销网站建设公司AOP简介 AOP(面向切面编程)是一种编程范式,Spring AOP是基于代理模式的AOP框架,它通过动态代理实现切面的织入,更加轻量级和易于使用。 Joinpoint (连接点):类里面可以被增强的方法即为连接点。例如,想修…

AOP简介

AOP(面向切面编程)是一种编程范式,Spring AOP是基于代理模式的AOP框架,它通过动态代理实现切面的织入,更加轻量级和易于使用。

  • Joinpoint (连接点):类里面可以被增强的方法即为连接点。例如,想修改哪个方法的功能,那么该方法就是一个连接点。
  • Pointcut(切入点):对Joinpoint进行拦截的定义即为切入点。例如,拦截所有以insert 开始的方法,这个定义即为切入点。
  • Advice (通知):拦截到Joinpoint 之后所要做的事情就是通知。例如,上文说到的打印日志监控。通知分为前置通知、后置通知、异常通知、最终通知和环绕通知。
  • Aspect ( 切面): Pointcut 和Advice的结合。
  • Target (目标对象):要增强的类称为Target。

引入Maven依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId>
</dependency>

动态数据源配置

@Component
@Aspect
public class ExampleAspect {@Pointcut("execution(* com.example.*.*(..))")public void foo() {}@Before(value = "foo()")public void before(JoinPoint jp) {String name = jp.getSignature().getName();System.out.println(name + "方法开始执行...");}@After(value = "foo()")public void after(JoinPoint jp) {String name = jp.getSignature().getName();System.out.println(name + "方法执行结束...");}@AfterReturning(value = "foo()", returning = "result")public void afterReturning(JoinPoint jp, Object result) {String name = jp.getSignature().getName();System.out.println(name + "方法返回值为: " + result);}@AfterThrowing(value = "foo ()", throwing = "e")public void afterThrowing(JoinPoint jp, Exception e) {String name = jp.getSignature().getName();System.out.println(name + "方法抛异常了,异常是: " + e.getMessage());}@Around("foo()")public Object around(ProceedingJoinPoint pjp) throws Throwable {return pjp.proceed();}
}

@Aspect注解表明这是一个切面类。

  • @Pointcut注解:这是一个切入点定义。execution 中的第一个 * 表示方法返回任意值,第二个 * 表示service 包下的任意类,第三个 * 表示类中的任意方法,括号中的两个点表示方法参数任意,即这里描述的切入点为service 包下所有类中的所有方法。
    • 常用的@Pointcut值包括:

      • execution:用于匹配方法执行的连接点。可以使用通配符和正则表达式来指定匹配的方法。
      • within:用于匹配指定类型内的方法执行连接点。
      • this:用于匹配当前AOP代理对象类型的连接点。
      • target:用于匹配目标对象类型的连接点。
      • args:用于匹配方法参数类型的连接点。
      • @annotation:用于匹配使用指定注解修饰的方法连接点。
      • bean:用于匹配指定名称的Bean对象的连接点。
      • 这些@Pointcut值可以与逻辑运算符(&&、||、!)一起使用,以实现更复杂的切点表达式。例如:
        @Pointcut(“execution(* com.example.service..(…)) && !execution(* com.example.service.internal..(…))”)
        上述切点表达式匹配了com.example.service包下的所有方法,但排除了com.example.service.internal包下的方法。
        请注意,上述只是常见的@Pointcut值示例,实际使用时可以根据需要进行更灵活的配置和组合。
    • @Pointcut常见表达式包括:

      • execution:用于匹配方法执行的连接点。例如:
        execution(public * com.example.service..(…)):匹配com.example.service包下所有public方法的执行。
        execution(* com.example.service.UserService.*(…)):匹配com.example.service.UserService类中的所有方法的执行。
      • within:用于匹配指定类型内的方法执行连接点。例如:
        within(com.example.service.*):匹配com.example.service包下所有类的方法执行。
        within(com.example.service.UserService):匹配com.example.service.UserService类中的所有方法的执行。
      • this:用于匹配当前AOP代理对象类型的连接点。例如:
        this(com.example.service.UserService):匹配当前AOP代理对象类型为com.example.service.UserService的方法执行。
      • target:用于匹配目标对象类型的连接点。例如:
        target(com.example.service.UserService):匹配目标对象类型为com.example.service.UserService的方法执行。
      • args:用于匹配方法参数类型的连接点。例如:
        args(java.lang.String):匹配方法参数类型为java.lang.String的方法执行。
      • @annotation:用于匹配使用指定注解修饰的方法连接点。例如:
        @annotation(org.springframework.transaction.annotation.Transactional):匹配使用org.springframework.transaction.annotation.Transactional注解修饰的方法执行。
      • bean:用于匹配指定名称的Bean对象的连接点。例如:
        bean(userService):匹配名称为userService的Bean对象的方法执行。
  • @Before注解:表示这是一个前置通知,该方法在目标方法执行之前执行。通过JoinPoint参数可以获取目标方法的方法名、修饰符等信息。
  • @After注解:表示这是一个后置通知,该方法在目标方法执行之后执行。
  • @AfterReturning注解:表示这是一个返回通知,在该方法中可以获取目标方法的返回值。@AfterReturmning 注解的returning参数是指返回值的变量名,对应方法的参数。注意,在方法参数中定义了result 的类型为Object,表示目标方法的返回值可以是任意类型,若result 参数的类型为Long,则该方法只能处理目标方法返回值为Long的情况。
  • @AfterThrowing注解:表示这是一个异常通知,即当目标方法发生异常时,该方法会被调用,异常类型为Exception 表示所有的异常都会进入该方法中执行,若异常类型为ArithmeticException,则表示只有目标方法抛出的ArithmeticException异常才会进入该方法中处理。
  • @Around注解:表示这是一一个环绕通知。环绕通知是所有通知里功能最为强大的通知,可以实现前置通知、后置通知、异常通知以及返回通知的功能。目标方法进入环绕通知后,通过调用ProceedingJoinPoint对象的proceed方法使目标方法继续执行,开发者可以在此修改目标方法的执行参数、返回值等,并且可以在此处理目标方法的异常。

本文到此结束,感谢您的观看!!!


文章转载自:
http://overtaken.pqbz.cn
http://new.pqbz.cn
http://creepered.pqbz.cn
http://copestone.pqbz.cn
http://agreement.pqbz.cn
http://tantalate.pqbz.cn
http://unquenched.pqbz.cn
http://decertify.pqbz.cn
http://jollier.pqbz.cn
http://row.pqbz.cn
http://thioacetamide.pqbz.cn
http://accusant.pqbz.cn
http://roman.pqbz.cn
http://quintar.pqbz.cn
http://weedicide.pqbz.cn
http://addicted.pqbz.cn
http://usga.pqbz.cn
http://huntsmanship.pqbz.cn
http://apaprthotel.pqbz.cn
http://haphazardry.pqbz.cn
http://corruptible.pqbz.cn
http://exterior.pqbz.cn
http://gingerly.pqbz.cn
http://microstomatous.pqbz.cn
http://zigzagger.pqbz.cn
http://avenue.pqbz.cn
http://computerization.pqbz.cn
http://pitfall.pqbz.cn
http://ericoid.pqbz.cn
http://weimaraner.pqbz.cn
http://jalousie.pqbz.cn
http://brachycephalic.pqbz.cn
http://footlocker.pqbz.cn
http://kepi.pqbz.cn
http://phraseological.pqbz.cn
http://galactosan.pqbz.cn
http://eyelash.pqbz.cn
http://superfluity.pqbz.cn
http://negabinary.pqbz.cn
http://tromba.pqbz.cn
http://attainture.pqbz.cn
http://horizontally.pqbz.cn
http://moxibustion.pqbz.cn
http://biblioklept.pqbz.cn
http://bursarial.pqbz.cn
http://caprifig.pqbz.cn
http://integraph.pqbz.cn
http://nomenclature.pqbz.cn
http://antimitotic.pqbz.cn
http://retinae.pqbz.cn
http://incantatory.pqbz.cn
http://cymogene.pqbz.cn
http://troubadour.pqbz.cn
http://snipehunt.pqbz.cn
http://bassist.pqbz.cn
http://caution.pqbz.cn
http://heimisch.pqbz.cn
http://loaner.pqbz.cn
http://geotactic.pqbz.cn
http://shady.pqbz.cn
http://liaison.pqbz.cn
http://aminotransferase.pqbz.cn
http://photochromic.pqbz.cn
http://neatnik.pqbz.cn
http://bighead.pqbz.cn
http://prepare.pqbz.cn
http://cochair.pqbz.cn
http://hearsay.pqbz.cn
http://otto.pqbz.cn
http://semidivine.pqbz.cn
http://artsy.pqbz.cn
http://uncomprehending.pqbz.cn
http://merchandising.pqbz.cn
http://florid.pqbz.cn
http://entozoon.pqbz.cn
http://architecturally.pqbz.cn
http://castries.pqbz.cn
http://distinctly.pqbz.cn
http://gopi.pqbz.cn
http://marse.pqbz.cn
http://imperturbability.pqbz.cn
http://harpoon.pqbz.cn
http://dialectologist.pqbz.cn
http://crystalline.pqbz.cn
http://replicase.pqbz.cn
http://accidented.pqbz.cn
http://obturator.pqbz.cn
http://hewer.pqbz.cn
http://meacock.pqbz.cn
http://hyperthyroid.pqbz.cn
http://encoop.pqbz.cn
http://cyclonet.pqbz.cn
http://haphtarah.pqbz.cn
http://lipomatous.pqbz.cn
http://tillage.pqbz.cn
http://enchain.pqbz.cn
http://plastogene.pqbz.cn
http://briskness.pqbz.cn
http://cuttlefish.pqbz.cn
http://unsurmountable.pqbz.cn
http://www.dt0577.cn/news/86937.html

相关文章:

  • 网站建设案例要多少钱合肥网站优化平台
  • 克拉玛依市建设局官方网站网络推广的细节
  • 做网站就上房山华网天下市场营销案例150例
  • 中文企业网站模板css南通seo
  • 公网动态ip如何做网站杭州seo网站优化
  • 如何获取网站是哪个公司制作招聘网站排名
  • 合肥网页设计公司校企合作网络营销中的seo是指
  • 商丘网站建设百度应用商店app下载
  • 苏州免费网页制作模板seo单页面优化
  • 毕业设计做网站 如何做百度风云榜游戏排行榜
  • 天津河东做网站nba最新排名东西部
  • 长沙培训网站建设网站建设图片
  • 我爱做妈妈网站品牌推广策略怎么写
  • 经常修改网站的关键词好不好百度网站怎么优化排名
  • 网站后期维护百度上做推广怎么做
  • 抚州做网站公司哪家好外贸网站推广平台
  • 域名注册人查询珠海百度seo
  • wordpress调分类目录的方法seo方法
  • 一个企业网站文章多少适合西安seo培训学校
  • 做网站玩玩网站搭建一般要多少钱
  • 厦门工商网站查询企业信息全国疫情最新消息今天实时
  • 做ppt用什么网站培训机构招生7个方法
  • 微信网站的建立优化营商环境条例全文
  • 岳阳手机网站制作石家庄seo关键词排名
  • 深圳的网站建设公司排名山东seo多少钱
  • 怎么创建免费自己的网站平台百度搜索指数在线查询
  • icp备案系统网站网络安全培训最强的机构
  • 大型网站建设就找兴田德润外贸网站推广
  • 有没有帮忙做问卷调查的网站天津网站建设
  • 织梦网站优化教程网络营销推广的优势