parent
df81e9ccfa
commit
d53704f942
|
@ -91,4 +91,11 @@ public interface ConfigurableTomcatWebServerFactory extends ConfigurableWebServe
|
||||||
*/
|
*/
|
||||||
void setUseApr(boolean useApr);
|
void setUseApr(boolean useApr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the factory should disable Tomcat's MBean registry prior to creating
|
||||||
|
* the server.
|
||||||
|
* @param disableMBeanRegistry whether to disable the MBean registry
|
||||||
|
*/
|
||||||
|
void setDisableMBeanRegistry(boolean disableMBeanRegistry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,6 +351,7 @@ public class TomcatWebServerFactory extends AbstractConfigurableWebServerFactory
|
||||||
* the server.
|
* the server.
|
||||||
* @param disableMBeanRegistry whether to disable the MBean registry
|
* @param disableMBeanRegistry whether to disable the MBean registry
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDisableMBeanRegistry(boolean disableMBeanRegistry) {
|
public void setDisableMBeanRegistry(boolean disableMBeanRegistry) {
|
||||||
this.disableMBeanRegistry = disableMBeanRegistry;
|
this.disableMBeanRegistry = disableMBeanRegistry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,6 +152,9 @@ public class TomcatWebServerFactoryCustomizer
|
||||||
.as(this::joinCharacters)
|
.as(this::joinCharacters)
|
||||||
.whenHasText()
|
.whenHasText()
|
||||||
.to((relaxedChars) -> customizeRelaxedQueryChars(factory, relaxedChars));
|
.to((relaxedChars) -> customizeRelaxedQueryChars(factory, relaxedChars));
|
||||||
|
map.from(this.tomcatProperties.getMbeanregistry()::isEnabled)
|
||||||
|
.as((enable) -> !enable)
|
||||||
|
.to(factory::setDisableMBeanRegistry);
|
||||||
customizeStaticResources(factory);
|
customizeStaticResources(factory);
|
||||||
customizeErrorReportValve(this.serverProperties.getError(), factory);
|
customizeErrorReportValve(this.serverProperties.getError(), factory);
|
||||||
factory.setUseApr(getUseApr(this.tomcatProperties.getUseApr()));
|
factory.setUseApr(getUseApr(this.tomcatProperties.getUseApr()));
|
||||||
|
|
|
@ -51,12 +51,6 @@ import org.springframework.http.ReactiveHttpInputMessage;
|
||||||
@Import({ TomcatWebServerConfiguration.class, ReactiveWebServerConfiguration.class })
|
@Import({ TomcatWebServerConfiguration.class, ReactiveWebServerConfiguration.class })
|
||||||
public class TomcatReactiveWebServerAutoConfiguration {
|
public class TomcatReactiveWebServerAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
|
||||||
TomcatReactiveWebServerFactoryCustomizer tomcatReactiveWebServerFactoryCustomizer(
|
|
||||||
TomcatServerProperties tomcatProperties) {
|
|
||||||
return new TomcatReactiveWebServerFactoryCustomizer(tomcatProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean(ReactiveWebServerFactory.class)
|
@ConditionalOnMissingBean(ReactiveWebServerFactory.class)
|
||||||
TomcatReactiveWebServerFactory tomcatReactiveWebServerFactory(
|
TomcatReactiveWebServerFactory tomcatReactiveWebServerFactory(
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2012-2025 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.tomcat.autoconfigure.reactive;
|
|
||||||
|
|
||||||
import org.springframework.boot.tomcat.autoconfigure.TomcatServerProperties;
|
|
||||||
import org.springframework.boot.tomcat.reactive.TomcatReactiveWebServerFactory;
|
|
||||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link WebServerFactoryCustomizer} to apply {@link TomcatServerProperties} to Tomcat
|
|
||||||
* reactive web servers.
|
|
||||||
*
|
|
||||||
* @author Andy Wilkinson
|
|
||||||
* @since 4.0.0
|
|
||||||
*/
|
|
||||||
public class TomcatReactiveWebServerFactoryCustomizer
|
|
||||||
implements WebServerFactoryCustomizer<TomcatReactiveWebServerFactory> {
|
|
||||||
|
|
||||||
private final TomcatServerProperties tomcatProperties;
|
|
||||||
|
|
||||||
public TomcatReactiveWebServerFactoryCustomizer(TomcatServerProperties tomcatProperties) {
|
|
||||||
this.tomcatProperties = tomcatProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void customize(TomcatReactiveWebServerFactory factory) {
|
|
||||||
factory.setDisableMBeanRegistry(!this.tomcatProperties.getMbeanregistry().isEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -53,7 +53,6 @@ class TomcatServletWebServerFactoryCustomizer
|
||||||
customizeRedirectContextRoot(factory, this.tomcatProperties.getRedirectContextRoot());
|
customizeRedirectContextRoot(factory, this.tomcatProperties.getRedirectContextRoot());
|
||||||
}
|
}
|
||||||
customizeUseRelativeRedirects(factory, this.tomcatProperties.isUseRelativeRedirects());
|
customizeUseRelativeRedirects(factory, this.tomcatProperties.isUseRelativeRedirects());
|
||||||
factory.setDisableMBeanRegistry(!this.tomcatProperties.getMbeanregistry().isEnabled());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void customizeRedirectContextRoot(ConfigurableTomcatWebServerFactory factory, boolean redirectContextRoot) {
|
private void customizeRedirectContextRoot(ConfigurableTomcatWebServerFactory factory, boolean redirectContextRoot) {
|
||||||
|
|
|
@ -588,6 +588,15 @@ class TomcatWebServerFactoryCustomizerTests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void enableMBeanRegistry() {
|
||||||
|
bind("server.tomcat.mbeanregistry.enabled=true");
|
||||||
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
|
assertThat(factory.isDisableMBeanRegistry()).isTrue();
|
||||||
|
this.customizer.customize(factory);
|
||||||
|
assertThat(factory.isDisableMBeanRegistry()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
private void bind(String... inlinedProperties) {
|
private void bind(String... inlinedProperties) {
|
||||||
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment, inlinedProperties);
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment, inlinedProperties);
|
||||||
Binder binder = new Binder(ConfigurationPropertySources.get(this.environment));
|
Binder binder = new Binder(ConfigurationPropertySources.get(this.environment));
|
||||||
|
|
Loading…
Reference in New Issue