From 12c47adff2b86dba0bc338dc6c83a44a70b56817 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 3 Aug 2021 15:24:44 +0300 Subject: [PATCH] Ensure various non-bean JAX-RS components work in native Fixes: #16211 --- .../deployment/ResteasyReactiveCDIProcessor.java | 14 +++++++++++--- .../ResteasyReactiveScanningProcessor.java | 13 +++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveCDIProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveCDIProcessor.java index ba5865a8355eb..f77f6038623fa 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveCDIProcessor.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveCDIProcessor.java @@ -21,6 +21,7 @@ import io.quarkus.arc.processor.DotNames; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.resteasy.reactive.common.deployment.ResourceScanningResultBuildItem; import io.quarkus.resteasy.reactive.server.runtime.QuarkusContextProducers; import io.quarkus.resteasy.reactive.spi.DynamicFeatureBuildItem; @@ -84,6 +85,7 @@ void pathInterfaceImpls(Optional resourceScanni @BuildStep void additionalBeans(List additionalDynamicFeatures, + BuildProducer reflectiveClassBuildItemBuildProducer, List featureBuildItems, BuildProducer additionalBean) { @@ -91,11 +93,17 @@ void additionalBeans(List additionalDynamicFeatures, for (DynamicFeatureBuildItem dynamicFeature : additionalDynamicFeatures) { if (dynamicFeature.isRegisterAsBean()) { additionalProviders.addBeanClass(dynamicFeature.getClassName()); + } else { + reflectiveClassBuildItemBuildProducer + .produce(new ReflectiveClassBuildItem(true, false, false, dynamicFeature.getClassName())); } } - for (JaxrsFeatureBuildItem dynamicFeature : featureBuildItems) { - if (dynamicFeature.isRegisterAsBean()) { - additionalProviders.addBeanClass(dynamicFeature.getClassName()); + for (JaxrsFeatureBuildItem feature : featureBuildItems) { + if (feature.isRegisterAsBean()) { + additionalProviders.addBeanClass(feature.getClassName()); + } else { + reflectiveClassBuildItemBuildProducer + .produce(new ReflectiveClassBuildItem(true, false, false, feature.getClassName())); } } additionalBean.produce(additionalProviders.setUnremovable().setDefaultScope(DotNames.SINGLETON).build()); diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java index f7a319579e7a9..cd937d6ce8da1 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java @@ -51,6 +51,7 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.index.IndexingUtil; import io.quarkus.resteasy.reactive.common.deployment.ApplicationResultBuildItem; import io.quarkus.resteasy.reactive.common.deployment.ResourceInterceptorsContributorBuildItem; @@ -99,6 +100,7 @@ public void accept(ResourceInterceptors interceptors) { public ExceptionMappersBuildItem scanForExceptionMappers(CombinedIndexBuildItem combinedIndexBuildItem, ApplicationResultBuildItem applicationResultBuildItem, BuildProducer additionalBeanBuildItemBuildProducer, + BuildProducer reflectiveClassBuildItemBuildProducer, List mappers, Capabilities capabilities) { AdditionalBeanBuildItem.Builder beanBuilder = AdditionalBeanBuildItem.builder().setUnremovable(); ExceptionMapping exceptions = ResteasyReactiveExceptionMappingScanner @@ -118,6 +120,9 @@ public ExceptionMappersBuildItem scanForExceptionMappers(CombinedIndexBuildItem for (ExceptionMapperBuildItem additionalExceptionMapper : mappers) { if (additionalExceptionMapper.isRegisterAsBean()) { beanBuilder.addBeanClass(additionalExceptionMapper.getClassName()); + } else { + reflectiveClassBuildItemBuildProducer + .produce(new ReflectiveClassBuildItem(true, false, false, additionalExceptionMapper.getClassName())); } int priority = Priorities.USER; if (additionalExceptionMapper.getPriority() != null) { @@ -141,6 +146,7 @@ public ExceptionMappersBuildItem scanForExceptionMappers(CombinedIndexBuildItem @BuildStep public ParamConverterProvidersBuildItem scanForParamConverters(CombinedIndexBuildItem combinedIndexBuildItem, BuildProducer additionalBeanBuildItemBuildProducer, + BuildProducer reflectiveClassBuildItemBuildProducer, ApplicationResultBuildItem applicationResultBuildItem, List paramConverterBuildItems) { @@ -153,6 +159,9 @@ public ParamConverterProvidersBuildItem scanForParamConverters(CombinedIndexBuil for (ParamConverterBuildItem additionalParamConverter : paramConverterBuildItems) { if (additionalParamConverter.isRegisterAsBean()) { beanBuilder.addBeanClass(additionalParamConverter.getClassName()); + } else { + reflectiveClassBuildItemBuildProducer + .produce(new ReflectiveClassBuildItem(true, false, false, additionalParamConverter.getClassName())); } int priority = Priorities.USER; if (additionalParamConverter.getPriority() != null) { @@ -197,6 +206,7 @@ public void scanForFeatures(CombinedIndexBuildItem combinedIndexBuildItem, public ContextResolversBuildItem scanForContextResolvers(CombinedIndexBuildItem combinedIndexBuildItem, ApplicationResultBuildItem applicationResultBuildItem, BuildProducer additionalBeanBuildItemBuildProducer, + BuildProducer reflectiveClassBuildItemBuildProducer, List additionalResolvers) { IndexView index = combinedIndexBuildItem.getComputingIndex(); AdditionalBeanBuildItem.Builder beanBuilder = AdditionalBeanBuildItem.builder().setUnremovable(); @@ -210,6 +220,9 @@ public ContextResolversBuildItem scanForContextResolvers(CombinedIndexBuildItem for (ContextResolverBuildItem i : additionalResolvers) { if (i.isRegisterAsBean()) { beanBuilder.addBeanClass(i.getClassName()); + } else { + reflectiveClassBuildItemBuildProducer + .produce(new ReflectiveClassBuildItem(true, false, false, i.getClassName())); } ResourceContextResolver resolver = new ResourceContextResolver(); resolver.setClassName(i.getClassName());