20 changed files with 654 additions and 347 deletions
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server; |
||||
|
||||
import org.springframework.boot.web.server.WebServerFactory; |
||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer; |
||||
import org.springframework.core.Ordered; |
||||
|
||||
/** |
||||
* Base class for a {@link WebServerFactoryCustomizer} that customizes the web server's |
||||
* access log. |
||||
* |
||||
* @param <T> the {@link WebServerFactory} type that can be customized |
||||
* @author Andy Wilkinson |
||||
* @since 4.0.0 |
||||
*/ |
||||
public abstract class AccessLogCustomizer<T extends WebServerFactory> |
||||
implements WebServerFactoryCustomizer<T>, Ordered { |
||||
|
||||
private final String prefix; |
||||
|
||||
protected AccessLogCustomizer(String prefix) { |
||||
this.prefix = prefix; |
||||
} |
||||
|
||||
protected String customizePrefix(String existingPrefix) { |
||||
if (this.prefix == null) { |
||||
return existingPrefix; |
||||
} |
||||
if (existingPrefix == null) { |
||||
return this.prefix; |
||||
} |
||||
if (existingPrefix.startsWith(this.prefix)) { |
||||
return existingPrefix; |
||||
} |
||||
return this.prefix + existingPrefix; |
||||
} |
||||
|
||||
@Override |
||||
public int getOrder() { |
||||
return 1; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.jetty; |
||||
|
||||
import java.io.File; |
||||
|
||||
import org.eclipse.jetty.server.CustomRequestLog; |
||||
import org.eclipse.jetty.server.RequestLog; |
||||
import org.eclipse.jetty.server.RequestLogWriter; |
||||
import org.eclipse.jetty.server.Server; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory; |
||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
/** |
||||
* {@link AccessLogCustomizer} for Jetty. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
class JettyAccessLogCustomizer extends AccessLogCustomizer<ConfigurableJettyWebServerFactory> |
||||
implements WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> { |
||||
|
||||
JettyAccessLogCustomizer(ManagementServerProperties properties) { |
||||
super(properties.getJetty().getAccesslog().getPrefix()); |
||||
} |
||||
|
||||
@Override |
||||
public void customize(ConfigurableJettyWebServerFactory factory) { |
||||
factory.addServerCustomizers(this::customizeServer); |
||||
} |
||||
|
||||
private void customizeServer(Server server) { |
||||
RequestLog requestLog = server.getRequestLog(); |
||||
if (requestLog instanceof CustomRequestLog customRequestLog) { |
||||
customizeRequestLog(customRequestLog); |
||||
} |
||||
} |
||||
|
||||
private void customizeRequestLog(CustomRequestLog requestLog) { |
||||
if (requestLog.getWriter() instanceof RequestLogWriter requestLogWriter) { |
||||
customizeRequestLogWriter(requestLogWriter); |
||||
} |
||||
} |
||||
|
||||
private void customizeRequestLogWriter(RequestLogWriter writer) { |
||||
String filename = writer.getFileName(); |
||||
if (StringUtils.hasLength(filename)) { |
||||
File file = new File(filename); |
||||
file = new File(file.getParentFile(), customizePrefix(file.getName())); |
||||
writer.setFilename(file.getPath()); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.jetty; |
||||
|
||||
import org.eclipse.jetty.server.Server; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; |
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
|
||||
/** |
||||
* {@link ManagementContextConfiguration @ManagementContextConfiguration} for Jetty-based |
||||
* reactive web endpoint infrastructure when a separate management context running on a |
||||
* different port is required. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@ConditionalOnClass(Server.class) |
||||
@ConditionalOnWebApplication(type = Type.REACTIVE) |
||||
@EnableConfigurationProperties(ManagementServerProperties.class) |
||||
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) |
||||
class JettyReactiveManagementChildContextConfiguration { |
||||
|
||||
@Bean |
||||
JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(ManagementServerProperties properties) { |
||||
return new JettyAccessLogCustomizer(properties); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.jetty; |
||||
|
||||
import org.eclipse.jetty.server.Server; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; |
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
|
||||
/** |
||||
* {@link ManagementContextConfiguration @ManagementContextConfiguration} for Jetty-based |
||||
* servlet web endpoint infrastructure when a separate management context running on a |
||||
* different port is required. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@ConditionalOnClass(Server.class) |
||||
@ConditionalOnWebApplication(type = Type.SERVLET) |
||||
@EnableConfigurationProperties(ManagementServerProperties.class) |
||||
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) |
||||
class JettyServletManagementChildContextConfiguration { |
||||
|
||||
@Bean |
||||
JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(ManagementServerProperties properties) { |
||||
return new JettyAccessLogCustomizer(properties); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
/* |
||||
* Copyright 2012-present 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. |
||||
*/ |
||||
|
||||
/** |
||||
* Actuator Jetty web server support. |
||||
*/ |
||||
package org.springframework.boot.actuate.autoconfigure.web.server.jetty; |
||||
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.tomcat; |
||||
|
||||
import java.util.Collection; |
||||
import java.util.function.Function; |
||||
|
||||
import org.apache.catalina.Valve; |
||||
import org.apache.catalina.valves.AccessLogValve; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.web.embedded.tomcat.ConfigurableTomcatWebServerFactory; |
||||
|
||||
/** |
||||
* {@link AccessLogCustomizer} for Tomcat. |
||||
* |
||||
* @param <T> the type of factory that can be customized |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
class TomcatAccessLogCustomizer<T extends ConfigurableTomcatWebServerFactory> extends AccessLogCustomizer<T> { |
||||
|
||||
private final Function<T, Collection<Valve>> engineValvesExtractor; |
||||
|
||||
TomcatAccessLogCustomizer(ManagementServerProperties properties, |
||||
Function<T, Collection<Valve>> engineValvesExtractor) { |
||||
super(properties.getTomcat().getAccesslog().getPrefix()); |
||||
this.engineValvesExtractor = engineValvesExtractor; |
||||
} |
||||
|
||||
@Override |
||||
public void customize(T factory) { |
||||
AccessLogValve accessLogValve = findAccessLogValve(factory); |
||||
if (accessLogValve == null) { |
||||
return; |
||||
} |
||||
accessLogValve.setPrefix(customizePrefix(accessLogValve.getPrefix())); |
||||
} |
||||
|
||||
private AccessLogValve findAccessLogValve(T factory) { |
||||
for (Valve engineValve : this.engineValvesExtractor.apply(factory)) { |
||||
if (engineValve instanceof AccessLogValve accessLogValve) { |
||||
return accessLogValve; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.tomcat; |
||||
|
||||
import org.apache.catalina.startup.Tomcat; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; |
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory; |
||||
import org.springframework.context.annotation.Bean; |
||||
|
||||
/** |
||||
* {@link ManagementContextConfiguration @ManagementContextConfiguration} for Tomcat-based |
||||
* reactive web endpoint infrastructure when a separate management context running on a |
||||
* different port is required. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@ConditionalOnClass(Tomcat.class) |
||||
@ConditionalOnWebApplication(type = Type.REACTIVE) |
||||
@EnableConfigurationProperties(ManagementServerProperties.class) |
||||
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) |
||||
class TomcatReactiveManagementChildContextConfiguration { |
||||
|
||||
@Bean |
||||
TomcatAccessLogCustomizer<TomcatReactiveWebServerFactory> tomcatManagementAccessLogCustomizer( |
||||
ManagementServerProperties properties) { |
||||
return new TomcatAccessLogCustomizer<>(properties, TomcatReactiveWebServerFactory::getEngineValves); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.tomcat; |
||||
|
||||
import org.apache.catalina.startup.Tomcat; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; |
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; |
||||
import org.springframework.context.annotation.Bean; |
||||
|
||||
/** |
||||
* {@link ManagementContextConfiguration @ManagementContextConfiguration} for Tomcat-based |
||||
* servlet web endpoint infrastructure when a separate management context running on a |
||||
* different port is required. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@ConditionalOnClass(Tomcat.class) |
||||
@ConditionalOnWebApplication(type = Type.SERVLET) |
||||
@EnableConfigurationProperties(ManagementServerProperties.class) |
||||
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) |
||||
class TomcatServletManagementChildContextConfiguration { |
||||
|
||||
@Bean |
||||
TomcatAccessLogCustomizer<TomcatServletWebServerFactory> tomcatManagementAccessLogCustomizer( |
||||
ManagementServerProperties properties) { |
||||
return new TomcatAccessLogCustomizer<>(properties, TomcatServletWebServerFactory::getEngineValves); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
/* |
||||
* Copyright 2012-present 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. |
||||
*/ |
||||
|
||||
/** |
||||
* Actuator Tomcat web server support. |
||||
*/ |
||||
package org.springframework.boot.actuate.autoconfigure.web.server.tomcat; |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.undertow; |
||||
|
||||
import java.util.function.Function; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory; |
||||
|
||||
/** |
||||
* {@link AccessLogCustomizer} for Undertow. |
||||
* |
||||
* @param <T> the type of factory that can be customized |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
class UndertowAccessLogCustomizer<T extends ConfigurableUndertowWebServerFactory> extends AccessLogCustomizer<T> { |
||||
|
||||
private final Function<T, String> accessLogPrefixExtractor; |
||||
|
||||
UndertowAccessLogCustomizer(ManagementServerProperties properties, Function<T, String> accessLogPrefixExtractor) { |
||||
super(properties.getUndertow().getAccesslog().getPrefix()); |
||||
this.accessLogPrefixExtractor = accessLogPrefixExtractor; |
||||
} |
||||
|
||||
@Override |
||||
public void customize(T factory) { |
||||
factory.setAccessLogPrefix(customizePrefix(this.accessLogPrefixExtractor.apply(factory))); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.undertow; |
||||
|
||||
import io.undertow.Undertow; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; |
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory; |
||||
import org.springframework.context.annotation.Bean; |
||||
|
||||
/** |
||||
* {@link ManagementContextConfiguration @ManagementContextConfiguration} for |
||||
* Undertow-based reactive web endpoint infrastructure when a separate management context |
||||
* running on a different port is required. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@ConditionalOnClass(Undertow.class) |
||||
@ConditionalOnWebApplication(type = Type.REACTIVE) |
||||
@EnableConfigurationProperties(ManagementServerProperties.class) |
||||
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) |
||||
class UndertowReactiveManagementChildContextConfiguration { |
||||
|
||||
@Bean |
||||
UndertowAccessLogCustomizer<UndertowReactiveWebServerFactory> undertowManagementAccessLogCustomizer( |
||||
ManagementServerProperties properties) { |
||||
return new UndertowAccessLogCustomizer<>(properties, UndertowReactiveWebServerFactory::getAccessLogPrefix); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.server.undertow; |
||||
|
||||
import io.undertow.Undertow; |
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; |
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; |
||||
import org.springframework.context.annotation.Bean; |
||||
|
||||
/** |
||||
* {@link ManagementContextConfiguration @ManagementContextConfiguration} for |
||||
* Undertow-based servlet web endpoint infrastructure when a separate management context |
||||
* running on a different port is required. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@ConditionalOnClass(Undertow.class) |
||||
@ConditionalOnWebApplication(type = Type.SERVLET) |
||||
@EnableConfigurationProperties(ManagementServerProperties.class) |
||||
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) |
||||
class UndertowServletManagementChildContextConfiguration { |
||||
|
||||
@Bean |
||||
UndertowAccessLogCustomizer<UndertowServletWebServerFactory> undertowManagementAccessLogCustomizer( |
||||
ManagementServerProperties properties) { |
||||
return new UndertowAccessLogCustomizer<>(properties, UndertowServletWebServerFactory::getAccessLogPrefix); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
/* |
||||
* Copyright 2012-present 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. |
||||
*/ |
||||
|
||||
/** |
||||
* Actuator Undertow web server support. |
||||
*/ |
||||
package org.springframework.boot.actuate.autoconfigure.web.server.undertow; |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* |
||||
* Copyright 2012-present 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.actuate.autoconfigure.web.servlet; |
||||
|
||||
import org.springframework.beans.factory.ListableBeanFactory; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; |
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementWebServerFactoryCustomizer; |
||||
import org.springframework.boot.autoconfigure.web.ServerProperties; |
||||
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
/** |
||||
* {@link ManagementWebServerFactoryCustomizer} for a servlet web server. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
class ServletManagementWebServerFactoryCustomizer |
||||
extends ManagementWebServerFactoryCustomizer<ConfigurableServletWebServerFactory> { |
||||
|
||||
ServletManagementWebServerFactoryCustomizer(ListableBeanFactory beanFactory) { |
||||
super(beanFactory); |
||||
} |
||||
|
||||
@Override |
||||
protected void customize(ConfigurableServletWebServerFactory webServerFactory, |
||||
ManagementServerProperties managementServerProperties, ServerProperties serverProperties) { |
||||
super.customize(webServerFactory, managementServerProperties, serverProperties); |
||||
webServerFactory.setContextPath(getContextPath(managementServerProperties)); |
||||
} |
||||
|
||||
private String getContextPath(ManagementServerProperties managementServerProperties) { |
||||
String basePath = managementServerProperties.getBasePath(); |
||||
return StringUtils.hasText(basePath) ? basePath : ""; |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue