Skip to content

Commit

Permalink
Ensure various non-bean JAX-RS components work in native
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Aug 3, 2021
1 parent 9aa9a5a commit 12c47ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,18 +85,25 @@ void pathInterfaceImpls(Optional<ResourceScanningResultBuildItem> resourceScanni

@BuildStep
void additionalBeans(List<DynamicFeatureBuildItem> additionalDynamicFeatures,
BuildProducer<ReflectiveClassBuildItem> reflectiveClassBuildItemBuildProducer,
List<JaxrsFeatureBuildItem> featureBuildItems,
BuildProducer<AdditionalBeanBuildItem> additionalBean) {

AdditionalBeanBuildItem.Builder additionalProviders = AdditionalBeanBuildItem.builder();
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,6 +100,7 @@ public void accept(ResourceInterceptors interceptors) {
public ExceptionMappersBuildItem scanForExceptionMappers(CombinedIndexBuildItem combinedIndexBuildItem,
ApplicationResultBuildItem applicationResultBuildItem,
BuildProducer<AdditionalBeanBuildItem> additionalBeanBuildItemBuildProducer,
BuildProducer<ReflectiveClassBuildItem> reflectiveClassBuildItemBuildProducer,
List<ExceptionMapperBuildItem> mappers, Capabilities capabilities) {
AdditionalBeanBuildItem.Builder beanBuilder = AdditionalBeanBuildItem.builder().setUnremovable();
ExceptionMapping exceptions = ResteasyReactiveExceptionMappingScanner
Expand All @@ -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) {
Expand All @@ -141,6 +146,7 @@ public ExceptionMappersBuildItem scanForExceptionMappers(CombinedIndexBuildItem
@BuildStep
public ParamConverterProvidersBuildItem scanForParamConverters(CombinedIndexBuildItem combinedIndexBuildItem,
BuildProducer<AdditionalBeanBuildItem> additionalBeanBuildItemBuildProducer,
BuildProducer<ReflectiveClassBuildItem> reflectiveClassBuildItemBuildProducer,
ApplicationResultBuildItem applicationResultBuildItem,
List<ParamConverterBuildItem> paramConverterBuildItems) {

Expand All @@ -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) {
Expand Down Expand Up @@ -197,6 +206,7 @@ public void scanForFeatures(CombinedIndexBuildItem combinedIndexBuildItem,
public ContextResolversBuildItem scanForContextResolvers(CombinedIndexBuildItem combinedIndexBuildItem,
ApplicationResultBuildItem applicationResultBuildItem,
BuildProducer<AdditionalBeanBuildItem> additionalBeanBuildItemBuildProducer,
BuildProducer<ReflectiveClassBuildItem> reflectiveClassBuildItemBuildProducer,
List<ContextResolverBuildItem> additionalResolvers) {
IndexView index = combinedIndexBuildItem.getComputingIndex();
AdditionalBeanBuildItem.Builder beanBuilder = AdditionalBeanBuildItem.builder().setUnremovable();
Expand All @@ -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());
Expand Down

0 comments on commit 12c47ad

Please sign in to comment.