diff --git a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java index 4d0c9e6baeec0..bf4654c1a36ed 100644 --- a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java +++ b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java @@ -49,10 +49,10 @@ import io.quarkus.deployment.Capability; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.Consume; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.AdditionalStaticInitConfigSourceProviderBuildItem; import io.quarkus.deployment.builditem.CombinedIndexBuildItem; -import io.quarkus.deployment.builditem.ProxyUnwrapperBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.util.ServiceUtil; import io.quarkus.resteasy.common.runtime.ResteasyInjectorFactoryRecorder; @@ -148,16 +148,11 @@ void setupGzipProviders(BuildProducer providers) } @Record(STATIC_INIT) + @Consume(BeanContainerBuildItem.class) @BuildStep - ResteasyInjectionReadyBuildItem setupResteasyInjection(List proxyUnwrappers, - BeanContainerBuildItem beanContainerBuildItem, - Capabilities capabilities, + ResteasyInjectionReadyBuildItem setupResteasyInjection( ResteasyInjectorFactoryRecorder recorder) { - List> unwrappers = new ArrayList<>(); - for (ProxyUnwrapperBuildItem i : proxyUnwrappers) { - unwrappers.add(i.getUnwrapper()); - } - RuntimeValue injectorFactory = recorder.setup(beanContainerBuildItem.getValue(), unwrappers); + RuntimeValue injectorFactory = recorder.setup(); return new ResteasyInjectionReadyBuildItem(injectorFactory); } diff --git a/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusConstructorInjector.java b/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusConstructorInjector.java index 88723b3295d55..218b5e6a3d6ef 100644 --- a/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusConstructorInjector.java +++ b/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusConstructorInjector.java @@ -1,6 +1,7 @@ package io.quarkus.resteasy.common.runtime; import java.lang.reflect.Constructor; +import java.util.function.Supplier; import javax.ws.rs.WebApplicationException; @@ -10,11 +11,12 @@ import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.HttpResponse; -import io.quarkus.arc.runtime.BeanContainer; +import io.quarkus.arc.Arc; +import io.quarkus.arc.InstanceHandle; public class QuarkusConstructorInjector implements ConstructorInjector { - private volatile BeanContainer.Factory factory; + private volatile Supplier> factory; private final ConstructorInjector delegate; @@ -27,31 +29,27 @@ public QuarkusConstructorInjector(Constructor ctor, ConstructorInjector deleg @Override public Object construct(boolean unwrapAsync) { - if (QuarkusInjectorFactory.CONTAINER == null) { - return this.delegate.construct(unwrapAsync); - } - if (factory == null) { - factory = QuarkusInjectorFactory.CONTAINER.instanceFactory(this.ctor.getDeclaringClass()); + if (factory != null) { + return factory.get().get(); } + factory = Arc.container().instanceSupplier(this.ctor.getDeclaringClass()); if (factory == null) { return delegate.construct(unwrapAsync); } - return factory.create().get(); + return factory.get().get(); } @Override public Object construct(HttpRequest request, HttpResponse response, boolean unwrapAsync) throws Failure, WebApplicationException, ApplicationException { - if (QuarkusInjectorFactory.CONTAINER == null) { - return delegate.construct(request, response, unwrapAsync); - } - if (factory == null) { - factory = QuarkusInjectorFactory.CONTAINER.instanceFactory(this.ctor.getDeclaringClass()); + if (factory != null) { + return factory.get().get(); } + factory = Arc.container().instanceSupplier(this.ctor.getDeclaringClass()); if (factory == null) { return delegate.construct(request, response, unwrapAsync); } - return factory.create().get(); + return factory.get().get(); } @Override diff --git a/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusInjectorFactory.java b/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusInjectorFactory.java index fb97f71771354..cc4bf24082679 100644 --- a/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusInjectorFactory.java +++ b/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusInjectorFactory.java @@ -18,13 +18,12 @@ import org.jboss.resteasy.spi.metadata.ResourceClass; import org.jboss.resteasy.spi.metadata.ResourceConstructor; -import io.quarkus.arc.runtime.BeanContainer; +import io.quarkus.arc.runtime.ClientProxyUnwrapper; public class QuarkusInjectorFactory extends InjectorFactoryImpl { private static final Logger log = Logger.getLogger("io.quarkus.resteasy.runtime"); - static volatile BeanContainer CONTAINER = null; - static volatile Function PROXY_UNWRAPPER; + static final Function PROXY_UNWRAPPER = new ClientProxyUnwrapper(); @SuppressWarnings("rawtypes") @Override diff --git a/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyInjectorFactoryRecorder.java b/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyInjectorFactoryRecorder.java index f3c56f7068d5f..a8552f9f4eaaa 100644 --- a/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyInjectorFactoryRecorder.java +++ b/extensions/resteasy-classic/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyInjectorFactoryRecorder.java @@ -1,29 +1,14 @@ package io.quarkus.resteasy.common.runtime; -import java.util.List; -import java.util.function.Function; - import org.jboss.resteasy.spi.InjectorFactory; -import io.quarkus.arc.runtime.BeanContainer; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.annotations.Recorder; @Recorder public class ResteasyInjectorFactoryRecorder { - public RuntimeValue setup(BeanContainer container, List> propertyUnwrappers) { - QuarkusInjectorFactory.CONTAINER = container; - QuarkusInjectorFactory.PROXY_UNWRAPPER = new Function() { - @Override - public Object apply(Object o) { - Object res = o; - for (Function i : propertyUnwrappers) { - res = i.apply(res); - } - return res; - } - }; + public RuntimeValue setup() { return new RuntimeValue<>(new QuarkusInjectorFactory()); } }