diff --git a/extensions/amazon-lambda-resteasy/deployment/src/main/java/io/quarkus/amazon/lambda/resteasy/deployment/AmazonLambdaResteasyProcessor.java b/extensions/amazon-lambda-resteasy/deployment/src/main/java/io/quarkus/amazon/lambda/resteasy/deployment/AmazonLambdaResteasyProcessor.java index 1494a3901ac96..109fe2992ab53 100755 --- a/extensions/amazon-lambda-resteasy/deployment/src/main/java/io/quarkus/amazon/lambda/resteasy/deployment/AmazonLambdaResteasyProcessor.java +++ b/extensions/amazon-lambda-resteasy/deployment/src/main/java/io/quarkus/amazon/lambda/resteasy/deployment/AmazonLambdaResteasyProcessor.java @@ -7,7 +7,7 @@ import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.resteasy.server.common.deployment.ResteasyInjectionReadyBuildItem; +import io.quarkus.resteasy.common.deployment.ResteasyInjectionReadyBuildItem; import io.quarkus.resteasy.server.common.deployment.ResteasyServerConfigBuildItem; public class AmazonLambdaResteasyProcessor { diff --git a/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java b/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java index 996c738d634d0..cf4edf4b39de6 100644 --- a/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java +++ b/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java @@ -69,6 +69,7 @@ import io.quarkus.restclient.runtime.RestClientRecorder; import io.quarkus.resteasy.common.deployment.JaxrsProvidersToRegisterBuildItem; import io.quarkus.resteasy.common.deployment.ResteasyDotNames; +import io.quarkus.resteasy.common.deployment.ResteasyInjectionReadyBuildItem; class RestClientProcessor { private static final Logger log = Logger.getLogger(RestClientProcessor.class); @@ -284,8 +285,11 @@ private String getBaseUri(ClassInfo classInfo) { void registerProviders(BuildProducer reflectiveClass, JaxrsProvidersToRegisterBuildItem jaxrsProvidersToRegisterBuildItem, CombinedIndexBuildItem combinedIndexBuildItem, + ResteasyInjectionReadyBuildItem injectorFactory, RestClientRecorder restClientRecorder) { - restClientRecorder.initializeResteasyProviderFactory(jaxrsProvidersToRegisterBuildItem.useBuiltIn(), + + restClientRecorder.initializeResteasyProviderFactory(injectorFactory.getInjectorFactory(), + jaxrsProvidersToRegisterBuildItem.useBuiltIn(), jaxrsProvidersToRegisterBuildItem.getProviders(), jaxrsProvidersToRegisterBuildItem.getContributedProviders()); // register the providers for reflection diff --git a/extensions/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientRecorder.java b/extensions/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientRecorder.java index 25c119b4b9086..2ecf17c874fbd 100644 --- a/extensions/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientRecorder.java +++ b/extensions/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientRecorder.java @@ -10,8 +10,10 @@ import org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl; import org.jboss.resteasy.microprofile.client.RestClientBuilderImpl; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; +import org.jboss.resteasy.spi.InjectorFactory; import org.jboss.resteasy.spi.ResteasyProviderFactory; +import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.annotations.Recorder; @Recorder @@ -24,7 +26,8 @@ public void setSslEnabled(boolean sslEnabled) { RestClientBuilderImpl.setSslEnabled(sslEnabled); } - public void initializeResteasyProviderFactory(boolean useBuiltIn, Set providersToRegister, + public void initializeResteasyProviderFactory(RuntimeValue injectorFactory, boolean useBuiltIn, + Set providersToRegister, Set contributedProviders) { ResteasyProviderFactory clientProviderFactory = new ResteasyProviderFactoryImpl(null, true) { @Override @@ -37,6 +40,11 @@ protected void initializeUtils() { clientHelper = new ClientHelper(this); serverHelper = NOOPServerHelper.INSTANCE; } + + @Override + public InjectorFactory getInjectorFactory() { + return injectorFactory.getValue(); + } }; if (useBuiltIn) { diff --git a/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java b/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java index 6c123101f925a..25b9c3868658f 100644 --- a/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java +++ b/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java @@ -1,10 +1,14 @@ package io.quarkus.resteasy.common.deployment; +import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT; + +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Function; import javax.ws.rs.Consumes; import javax.ws.rs.Produces; @@ -26,15 +30,21 @@ import org.jboss.resteasy.plugins.interceptors.GZIPDecodingInterceptor; import org.jboss.resteasy.plugins.interceptors.GZIPEncodingInterceptor; import org.jboss.resteasy.plugins.providers.StringTextStar; +import org.jboss.resteasy.spi.InjectorFactory; import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem; +import io.quarkus.arc.deployment.BeanContainerBuildItem; import io.quarkus.deployment.Capabilities; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.ProxyUnwrapperBuildItem; import io.quarkus.deployment.builditem.substrate.ReflectiveClassBuildItem; import io.quarkus.deployment.util.ServiceUtil; +import io.quarkus.resteasy.common.runtime.ResteasyInjectorFactoryRecorder; import io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem; +import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigRoot; @@ -90,6 +100,19 @@ void setupGzipProviders(BuildProducer providers) } } + @Record(STATIC_INIT) + @BuildStep + ResteasyInjectionReadyBuildItem setupResteasyInjection(List proxyUnwrappers, + BeanContainerBuildItem beanContainerBuildItem, + ResteasyInjectorFactoryRecorder recorder) { + List> unwrappers = new ArrayList<>(); + for (ProxyUnwrapperBuildItem i : proxyUnwrappers) { + unwrappers.add(i.getUnwrapper()); + } + RuntimeValue injectorFactory = recorder.setup(beanContainerBuildItem.getValue(), unwrappers); + return new ResteasyInjectionReadyBuildItem(injectorFactory); + } + @BuildStep JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer reflectiveClass, CombinedIndexBuildItem indexBuildItem, diff --git a/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyInjectionReadyBuildItem.java b/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyInjectionReadyBuildItem.java new file mode 100644 index 0000000000000..09f400b54a79b --- /dev/null +++ b/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyInjectionReadyBuildItem.java @@ -0,0 +1,23 @@ +package io.quarkus.resteasy.common.deployment; + +import org.jboss.resteasy.spi.InjectorFactory; + +import io.quarkus.builder.item.SimpleBuildItem; +import io.quarkus.runtime.RuntimeValue; + +/** + * Gives access to the configured {@link InjectorFactory} + * Can also be used as a marker that RESTEasy has been properly setup and is ready for use + */ +public final class ResteasyInjectionReadyBuildItem extends SimpleBuildItem { + + private final RuntimeValue injectorFactory; + + public ResteasyInjectionReadyBuildItem(RuntimeValue injectorFactory) { + this.injectorFactory = injectorFactory; + } + + public RuntimeValue getInjectorFactory() { + return injectorFactory; + } +} diff --git a/extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/QuarkusConstructorInjector.java b/extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusConstructorInjector.java similarity index 97% rename from extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/QuarkusConstructorInjector.java rename to extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusConstructorInjector.java index 9ceea776644c9..ac822c808f824 100644 --- a/extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/QuarkusConstructorInjector.java +++ b/extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusConstructorInjector.java @@ -1,4 +1,4 @@ -package io.quarkus.resteasy.server.common.runtime; +package io.quarkus.resteasy.common.runtime; import java.lang.reflect.Constructor; import java.util.concurrent.CompletableFuture; diff --git a/extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/QuarkusInjectorFactory.java b/extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusInjectorFactory.java similarity index 98% rename from extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/QuarkusInjectorFactory.java rename to extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusInjectorFactory.java index 51abfdd627151..fb97f71771354 100644 --- a/extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/QuarkusInjectorFactory.java +++ b/extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/QuarkusInjectorFactory.java @@ -1,4 +1,4 @@ -package io.quarkus.resteasy.server.common.runtime; +package io.quarkus.resteasy.common.runtime; import java.lang.reflect.Constructor; import java.util.concurrent.CompletionStage; diff --git a/extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/ResteasyServerCommonRecorder.java b/extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyInjectorFactoryRecorder.java similarity index 61% rename from extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/ResteasyServerCommonRecorder.java rename to extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyInjectorFactoryRecorder.java index 59d03742e1abd..f3c56f7068d5f 100644 --- a/extensions/resteasy-server-common/runtime/src/main/java/io/quarkus/resteasy/server/common/runtime/ResteasyServerCommonRecorder.java +++ b/extensions/resteasy-common/runtime/src/main/java/io/quarkus/resteasy/common/runtime/ResteasyInjectorFactoryRecorder.java @@ -1,15 +1,18 @@ -package io.quarkus.resteasy.server.common.runtime; +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 ResteasyServerCommonRecorder { +public class ResteasyInjectorFactoryRecorder { - public void setupIntegration(BeanContainer container, List> propertyUnwrappers) { + public RuntimeValue setup(BeanContainer container, List> propertyUnwrappers) { QuarkusInjectorFactory.CONTAINER = container; QuarkusInjectorFactory.PROXY_UNWRAPPER = new Function() { @Override @@ -21,5 +24,6 @@ public Object apply(Object o) { return res; } }; + return new RuntimeValue<>(new QuarkusInjectorFactory()); } } diff --git a/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyInjectionReadyBuildItem.java b/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyInjectionReadyBuildItem.java deleted file mode 100644 index 61ec8778bac17..0000000000000 --- a/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyInjectionReadyBuildItem.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.quarkus.resteasy.server.common.deployment; - -import io.quarkus.builder.item.SimpleBuildItem; - -/** - * Simple build item marker indicating the RESTEasy injection has been properly set up. - */ -public final class ResteasyInjectionReadyBuildItem extends SimpleBuildItem { - -} diff --git a/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java b/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java index 4eedd22e9367a..9b8ee579d5a6c 100755 --- a/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java +++ b/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java @@ -1,6 +1,5 @@ package io.quarkus.resteasy.server.common.deployment; -import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT; import static io.quarkus.runtime.annotations.ConfigPhase.BUILD_TIME; import java.lang.reflect.Modifier; @@ -14,7 +13,6 @@ import java.util.Map; import java.util.Set; import java.util.function.BiFunction; -import java.util.function.Function; import java.util.stream.Collectors; import org.jboss.jandex.AnnotationInstance; @@ -45,7 +43,6 @@ import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem; import io.quarkus.arc.deployment.AutoInjectAnnotationBuildItem; import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem; -import io.quarkus.arc.deployment.BeanContainerBuildItem; import io.quarkus.arc.deployment.BeanDefiningAnnotationBuildItem; import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.arc.deployment.UnremovableBeanBuildItem.BeanClassNameExclusion; @@ -55,10 +52,8 @@ import io.quarkus.arc.processor.Transformation; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem; import io.quarkus.deployment.builditem.CombinedIndexBuildItem; -import io.quarkus.deployment.builditem.ProxyUnwrapperBuildItem; import io.quarkus.deployment.builditem.substrate.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.substrate.ReflectiveHierarchyBuildItem; import io.quarkus.deployment.builditem.substrate.RuntimeInitializedClassBuildItem; @@ -69,8 +64,7 @@ import io.quarkus.resteasy.common.deployment.JaxrsProvidersToRegisterBuildItem; import io.quarkus.resteasy.common.deployment.ResteasyCommonProcessor.ResteasyCommonConfig; import io.quarkus.resteasy.common.deployment.ResteasyDotNames; -import io.quarkus.resteasy.server.common.runtime.QuarkusInjectorFactory; -import io.quarkus.resteasy.server.common.runtime.ResteasyServerCommonRecorder; +import io.quarkus.resteasy.common.runtime.QuarkusInjectorFactory; import io.quarkus.resteasy.server.common.spi.AdditionalJaxRsResourceDefiningAnnotationBuildItem; import io.quarkus.resteasy.server.common.spi.AdditionalJaxRsResourceMethodAnnotationsBuildItem; import io.quarkus.resteasy.server.common.spi.AdditionalJaxRsResourceMethodParamAnnotations; @@ -390,20 +384,6 @@ void processPathInterfaceImplementors(CombinedIndexBuildItem combinedIndexBuildI } } - @Record(STATIC_INIT) - @BuildStep - ResteasyInjectionReadyBuildItem setupInjection(ResteasyServerCommonRecorder recorder, - BeanContainerBuildItem beanContainerBuildItem, - List proxyUnwrappers) { - List> unwrappers = new ArrayList<>(); - for (ProxyUnwrapperBuildItem i : proxyUnwrappers) { - unwrappers.add(i.getUnwrapper()); - } - recorder.setupIntegration(beanContainerBuildItem.getValue(), unwrappers); - - return new ResteasyInjectionReadyBuildItem(); - } - @BuildStep void beanDefiningAnnotations(BuildProducer beanDefiningAnnotations) { beanDefiningAnnotations diff --git a/extensions/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyServletProcessor.java b/extensions/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyServletProcessor.java index bc8f7f4957793..4cb9667510149 100644 --- a/extensions/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyServletProcessor.java +++ b/extensions/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyServletProcessor.java @@ -23,9 +23,9 @@ import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.substrate.ReflectiveClassBuildItem; +import io.quarkus.resteasy.common.deployment.ResteasyInjectionReadyBuildItem; import io.quarkus.resteasy.runtime.ExceptionMapperRecorder; import io.quarkus.resteasy.runtime.ResteasyFilter; -import io.quarkus.resteasy.server.common.deployment.ResteasyInjectionReadyBuildItem; import io.quarkus.resteasy.server.common.deployment.ResteasyServerConfigBuildItem; import io.quarkus.undertow.deployment.FilterBuildItem; import io.quarkus.undertow.deployment.ServletBuildItem; diff --git a/extensions/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java b/extensions/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java index 65f99f6a6d35e..e2a95a1fd0482 100644 --- a/extensions/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java +++ b/extensions/resteasy/deployment/src/main/java/io/quarkus/resteasy/deployment/ResteasyStandaloneBuildStep.java @@ -21,9 +21,9 @@ import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.ShutdownContextBuildItem; +import io.quarkus.resteasy.common.deployment.ResteasyInjectionReadyBuildItem; import io.quarkus.resteasy.runtime.standalone.ResteasyStandaloneRecorder; import io.quarkus.resteasy.server.common.deployment.ResteasyDeploymentBuildItem; -import io.quarkus.resteasy.server.common.deployment.ResteasyInjectionReadyBuildItem; import io.quarkus.undertow.deployment.KnownPathsBuildItem; import io.quarkus.undertow.deployment.StaticResourceFilesBuildItem; import io.quarkus.vertx.core.deployment.InternalWebVertxBuildItem;