Skip to content

Commit

Permalink
Merge pull request wildfly#17797 from jamezp/WFLY-19209
Browse files Browse the repository at this point in the history
[WFLY-19209] Do not attempt to use the RESTEasy MicroProfile Configur…
  • Loading branch information
bstansberry committed Apr 11, 2024
2 parents 46fee36 + 4d91636 commit 0aecb40
Showing 1 changed file with 16 additions and 1 deletion.
Expand Up @@ -45,6 +45,7 @@
import org.jboss.metadata.web.spec.ServletMappingMetaData;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher;
Expand Down Expand Up @@ -103,7 +104,7 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
if (module != null) {
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
final WildFlyConfigurationFactory configurationFactory = WildFlyConfigurationFactory.getInstance();
configurationFactory.register(module.getClassLoader(), support.hasCapability("org.wildfly.microprofile.config"));
configurationFactory.register(module.getClassLoader(), useMicroProfileConfig(module, support));
}

final List<ParamValueMetaData> params = webdata.getContextParams();
Expand Down Expand Up @@ -610,4 +611,18 @@ private String convertMapToString(ModelNode modelNode) {
}
return sb.toString();
}

private static boolean useMicroProfileConfig(final Module module, final CapabilityServiceSupport support) {
final boolean configSupported = support.hasCapability("org.wildfly.microprofile.config");
if (configSupported) {
// Can we load the org.jboss.resteasy.microprofile.config module? If so we can use the MicroProfile backed
// configuration in RESTEasy. Otherwise, we need to use the default.
try {
module.getModule("org.jboss.resteasy.microprofile.config");
return true;
} catch (ModuleLoadException ignore) {
}
}
return false;
}
}

0 comments on commit 0aecb40

Please sign in to comment.