OnEnabledResourceChainCondition Class — spring-boot Architecture
Architecture documentation for the OnEnabledResourceChainCondition class in OnEnabledResourceChainCondition.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java lines 41–80
class OnEnabledResourceChainCondition extends SpringBootCondition {
private static final String WEBJAR_ASSET_LOCATOR = "org.webjars.WebJarAssetLocator";
private static final String WEBJAR_VERSION_LOCATOR = "org.webjars.WebJarVersionLocator";
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
boolean fixed = getEnabledProperty(environment, "strategy.fixed.", false);
boolean content = getEnabledProperty(environment, "strategy.content.", false);
Boolean chain = getEnabledProperty(environment, "", null);
Boolean match = Chain.getEnabled(fixed, content, chain);
ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnEnabledResourceChain.class);
if (match == null) {
if (ClassUtils.isPresent(WEBJAR_VERSION_LOCATOR, getClass().getClassLoader())) {
return ConditionOutcome.match(message.found("class").items(WEBJAR_VERSION_LOCATOR));
}
if (ClassUtils.isPresent(WEBJAR_ASSET_LOCATOR, getClass().getClassLoader())) {
return ConditionOutcome.match(message.found("class").items(WEBJAR_ASSET_LOCATOR));
}
return ConditionOutcome.noMatch(message.didNotFind("class").items(WEBJAR_VERSION_LOCATOR));
}
if (match) {
return ConditionOutcome.match(message.because("enabled"));
}
return ConditionOutcome.noMatch(message.because("disabled"));
}
@Contract("_, _, !null -> !null")
private @Nullable Boolean getEnabledProperty(ConfigurableEnvironment environment, String key,
@Nullable Boolean defaultValue) {
String name = "spring.web.resources.chain." + key + "enabled";
if (defaultValue == null) {
return environment.getProperty(name, Boolean.class);
}
return environment.getProperty(name, Boolean.class, defaultValue);
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free