From 8d6f46fefcb6a4fb47070f736fe27019c454acfc Mon Sep 17 00:00:00 2001 From: Markus Jung Date: Wed, 5 Jun 2024 16:37:05 +0200 Subject: [PATCH] TOMEE-4350 add qualifier for produced Jsonb --- .../tomee/microprofile/jwt/cdi/ClaimBean.java | 1 + .../tomee/microprofile/jwt/cdi/JsonbProducer.java | 2 +- .../tomee/microprofile/jwt/cdi/TomeeMpJwt.java | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/TomeeMpJwt.java diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java index 5ff9daa9940..aa826135dfe 100644 --- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java +++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java @@ -67,6 +67,7 @@ public class ClaimBean implements Bean, PassivationCapable { } @Inject + @TomeeMpJwt private Jsonb jsonb; private final BeanManager bm; diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/JsonbProducer.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/JsonbProducer.java index fc16202c596..c905b4fc6a3 100644 --- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/JsonbProducer.java +++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/JsonbProducer.java @@ -25,12 +25,12 @@ import java.util.logging.Logger; @ApplicationScoped -// todo add a qualifier here so we isolate our instance from what applications would do public class JsonbProducer { private static final Logger log = Logger.getLogger(MPJWTCDIExtension.class.getName()); @Produces + @TomeeMpJwt public Jsonb create() { return JsonbProvider.provider().create().build(); } diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/TomeeMpJwt.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/TomeeMpJwt.java new file mode 100644 index 00000000000..9eb42dbe4ff --- /dev/null +++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/TomeeMpJwt.java @@ -0,0 +1,14 @@ +package org.apache.tomee.microprofile.jwt.cdi; + +import jakarta.inject.Qualifier; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD }) +public @interface TomeeMpJwt { +}