【Quarkus】基于CDI和拦截器实现AOP功能

在 Quarkus 中实现 AOP(面向切面编程)功能,通常通过使用 CDI(Contexts and Dependency Injection)和拦截器来实现。Quarkus 支持使用标准的 CDI 注解和拦截器机制来进行 AOP 编程。

CDI简介

CDI全称:CONTEXTS AND DEPENDENCY INJECTION

Quarkus DI 解决方案(也称为 ArC)基于 Jakarta 上下文和依赖注入 4.1 规范。它实现了 CDI Lite 规范,并进行了选定的改进,并通过了 CDI Lite TCK。它不实现 CDI Full。另请参阅支持的功能和限制列表

Quarkus DI solution (also called ArC) is based on the Jakarta Contexts and Dependency Injection 4.1 specification. It implements the CDI Lite specification, with selected improvements on top, and passes the CDI Lite TCK. It does not implement CDI Full. See also the list of supported features and limitations.

拦截器简介

拦截器用于将横切关注点与业务逻辑分开。有一个单独的规范 - Java 拦截器 - 定义了基本的编程模型和语义。

Interceptors are used to separate cross-cutting concerns from business logic. There is a separate specification - Java Interceptors - that defines the basic programming model and semantics.

实现步骤

  1. 创建自定义注解
  2. 创建拦截器
  3. 应用拦截器
创建自定义注解

Simple Interceptor Binding Example

import java.lang.annotation.ElementType;
import java.lang.annotation.<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张小洛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值