From 75a008cea216ff3feaeed59fc2ac176bded20170 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Wed, 31 Aug 2022 17:20:25 +0200 Subject: [PATCH] Adjust ArC code to CDI 4.0.1 (cherry picked from commit c16cfd127010f223fe249702cb5fc6d035a47d2c) (cherry picked from commit 2bc4516b7882f0b79be48bf6bf6a43275989a10f) --- .../main/java/io/quarkus/arc/InstanceHandle.java | 3 ++- .../java/io/quarkus/arc/impl/ArcCDIProvider.java | 10 ++++++++++ .../io/quarkus/arc/impl/BeanManagerImpl.java | 16 ---------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InstanceHandle.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InstanceHandle.java index e3845a27ba81a..c03ba183b3dfc 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InstanceHandle.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InstanceHandle.java @@ -2,6 +2,7 @@ import jakarta.enterprise.context.Dependent; import jakarta.enterprise.context.spi.AlterableContext; +import jakarta.enterprise.inject.Instance; /** * Represents an instance handle. @@ -10,7 +11,7 @@ * * @param */ -public interface InstanceHandle extends AutoCloseable { +public interface InstanceHandle extends AutoCloseable, Instance.Handle { /** * diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcCDIProvider.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcCDIProvider.java index 97712f0ae7295..33681ba9b6fee 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcCDIProvider.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcCDIProvider.java @@ -71,6 +71,16 @@ public void destroy(Object instance) { this.instanceDelegate.destroy(instance); } + @Override + public Handle getHandle() { + return this.instanceDelegate.getHandle(); + } + + @Override + public Iterable> handles() { + return this.instanceDelegate.handles(); + } + @Override public Iterator iterator() { return instanceDelegate.iterator(); diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java index 7bf4d3166a9c9..1e7d8b31bfa22 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java @@ -3,7 +3,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -31,7 +30,6 @@ import jakarta.enterprise.inject.spi.Decorator; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.InjectionPoint; -import jakarta.enterprise.inject.spi.InjectionTarget; import jakarta.enterprise.inject.spi.InjectionTargetFactory; import jakarta.enterprise.inject.spi.InterceptionFactory; import jakarta.enterprise.inject.spi.InterceptionType; @@ -117,14 +115,6 @@ public void validate(InjectionPoint injectionPoint) { throw new UnsupportedOperationException(); } - // Deprecated method which can be safely removed once we use CDI 4.0+ - @Deprecated - public void fireEvent(Object event, Annotation... qualifiers) { - Set eventQualifiers = new HashSet<>(); - Collections.addAll(eventQualifiers, qualifiers); - new EventImpl(event.getClass(), eventQualifiers).fire(event); - } - @Override public Set> resolveObserverMethods(T event, Annotation... qualifiers) { Type eventType = Types.getCanonicalType(event.getClass()); @@ -238,12 +228,6 @@ public AnnotatedType createAnnotatedType(Class type) { throw new UnsupportedOperationException(); } - // Deprecated method which can be safely removed once we use CDI 4.0+ - @Deprecated - public InjectionTarget createInjectionTarget(AnnotatedType type) { - throw new UnsupportedOperationException(); - } - @Override public InjectionTargetFactory getInjectionTargetFactory(AnnotatedType annotatedType) { throw new UnsupportedOperationException();