Skip to content

Commit

Permalink
RESTEasy client - use our provider factory when accessed statically
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Oct 1, 2022
1 parent 38f4138 commit 2116ef3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void registerProviders(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
List<IgnoreClientProviderBuildItem> ignoreClientProviderBuildItems,
CombinedIndexBuildItem combinedIndexBuildItem,
ResteasyInjectionReadyBuildItem injectorFactory,
RestClientRecorder restClientRecorder) {
RestClientRecorder restClientRecorder, Capabilities capabilities) {

for (IgnoreClientProviderBuildItem item : ignoreClientProviderBuildItems) {
jaxrsProvidersToRegisterBuildItem.getProviders().remove(item.getProviderClassName());
Expand All @@ -465,6 +465,12 @@ void registerProviders(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
jaxrsProvidersToRegisterBuildItem.useBuiltIn(),
jaxrsProvidersToRegisterBuildItem.getProviders(), jaxrsProvidersToRegisterBuildItem.getContributedProviders());

if (!capabilities.isPresent(Capability.RESTEASY)) {
// ResteasyProviderFactory will use our implementation when accessing instance statically. That's not
// necessary when RESTEasy classic is present as then provider factory with correct provider classes is generated.
restClientRecorder.setResteasyProviderFactoryInstance();
}

// register the providers for reflection
for (String providerToRegister : jaxrsProvidersToRegisterBuildItem.getProviders()) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, providerToRegister));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public InjectorFactory getInjectorFactory() {
providerFactory = clientProviderFactory;
}

public void setResteasyProviderFactoryInstance() {
ResteasyProviderFactory.setInstance(providerFactory);
}

private static void registerProviders(ResteasyProviderFactory providerFactory, boolean useBuiltIn,
Set<String> providersToRegister,
Set<String> contributedProviders) {
Expand Down

0 comments on commit 2116ef3

Please sign in to comment.