|
|
|
@ -47,6 +47,7 @@ import org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFact |
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryCustomizer; |
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryCustomizer; |
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.TomcatServletWebServerFactoryCustomizer; |
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.TomcatServletWebServerFactoryCustomizer; |
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.UndertowServletWebServerFactoryCustomizer; |
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.UndertowServletWebServerFactoryCustomizer; |
|
|
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
|
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; |
|
|
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; |
|
|
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; |
|
|
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; |
|
|
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; |
|
|
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; |
|
|
|
@ -73,6 +74,7 @@ import org.springframework.util.StringUtils; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) |
|
|
|
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) |
|
|
|
@ConditionalOnWebApplication(type = Type.SERVLET) |
|
|
|
@ConditionalOnWebApplication(type = Type.SERVLET) |
|
|
|
|
|
|
|
@EnableConfigurationProperties(ManagementServerProperties.class) |
|
|
|
class ServletManagementChildContextConfiguration { |
|
|
|
class ServletManagementChildContextConfiguration { |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
@ -83,20 +85,22 @@ class ServletManagementChildContextConfiguration { |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
@ConditionalOnClass(name = "io.undertow.Undertow") |
|
|
|
@ConditionalOnClass(name = "io.undertow.Undertow") |
|
|
|
UndertowAccessLogCustomizer undertowManagementAccessLogCustomizer() { |
|
|
|
UndertowAccessLogCustomizer undertowManagementAccessLogCustomizer( |
|
|
|
return new UndertowAccessLogCustomizer(); |
|
|
|
ManagementServerProperties managementServerProperties) { |
|
|
|
|
|
|
|
return new UndertowAccessLogCustomizer(managementServerProperties); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
@ConditionalOnClass(name = "org.apache.catalina.valves.AccessLogValve") |
|
|
|
@ConditionalOnClass(name = "org.apache.catalina.valves.AccessLogValve") |
|
|
|
TomcatAccessLogCustomizer tomcatManagementAccessLogCustomizer() { |
|
|
|
TomcatAccessLogCustomizer tomcatManagementAccessLogCustomizer( |
|
|
|
return new TomcatAccessLogCustomizer(); |
|
|
|
ManagementServerProperties managementServerProperties) { |
|
|
|
|
|
|
|
return new TomcatAccessLogCustomizer(managementServerProperties); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
@ConditionalOnClass(name = "org.eclipse.jetty.server.Server") |
|
|
|
@ConditionalOnClass(name = "org.eclipse.jetty.server.Server") |
|
|
|
JettyAccessLogCustomizer jettyManagementAccessLogCustomizer() { |
|
|
|
JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(ManagementServerProperties managementServerProperties) { |
|
|
|
return new JettyAccessLogCustomizer(); |
|
|
|
return new JettyAccessLogCustomizer(managementServerProperties); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
@ -145,14 +149,18 @@ class ServletManagementChildContextConfiguration { |
|
|
|
|
|
|
|
|
|
|
|
abstract static class AccessLogCustomizer implements Ordered { |
|
|
|
abstract static class AccessLogCustomizer implements Ordered { |
|
|
|
|
|
|
|
|
|
|
|
private static final String MANAGEMENT_PREFIX = "management_"; |
|
|
|
protected final ManagementServerProperties managementServerProperties; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AccessLogCustomizer(ManagementServerProperties managementServerProperties) { |
|
|
|
|
|
|
|
this.managementServerProperties = managementServerProperties; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected String customizePrefix(String prefix) { |
|
|
|
protected String customizePrefix(String prefix) { |
|
|
|
prefix = (prefix != null) ? prefix : ""; |
|
|
|
prefix = (prefix != null) ? prefix : ""; |
|
|
|
if (prefix.startsWith(MANAGEMENT_PREFIX)) { |
|
|
|
if (prefix.startsWith(this.managementServerProperties.getAccesslog().getPrefix())) { |
|
|
|
return prefix; |
|
|
|
return prefix; |
|
|
|
} |
|
|
|
} |
|
|
|
return MANAGEMENT_PREFIX + prefix; |
|
|
|
return this.managementServerProperties.getAccesslog().getPrefix() + prefix; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -165,12 +173,17 @@ class ServletManagementChildContextConfiguration { |
|
|
|
static class TomcatAccessLogCustomizer extends AccessLogCustomizer |
|
|
|
static class TomcatAccessLogCustomizer extends AccessLogCustomizer |
|
|
|
implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> { |
|
|
|
implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TomcatAccessLogCustomizer(ManagementServerProperties managementServerProperties) { |
|
|
|
|
|
|
|
super(managementServerProperties); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void customize(TomcatServletWebServerFactory factory) { |
|
|
|
public void customize(TomcatServletWebServerFactory factory) { |
|
|
|
AccessLogValve accessLogValve = findAccessLogValve(factory); |
|
|
|
AccessLogValve accessLogValve = findAccessLogValve(factory); |
|
|
|
if (accessLogValve == null) { |
|
|
|
if (accessLogValve == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
accessLogValve.setPrefix(customizePrefix(accessLogValve.getPrefix())); |
|
|
|
accessLogValve.setPrefix(customizePrefix(accessLogValve.getPrefix())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -188,6 +201,10 @@ class ServletManagementChildContextConfiguration { |
|
|
|
static class UndertowAccessLogCustomizer extends AccessLogCustomizer |
|
|
|
static class UndertowAccessLogCustomizer extends AccessLogCustomizer |
|
|
|
implements WebServerFactoryCustomizer<UndertowServletWebServerFactory> { |
|
|
|
implements WebServerFactoryCustomizer<UndertowServletWebServerFactory> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UndertowAccessLogCustomizer(ManagementServerProperties managementServerProperties) { |
|
|
|
|
|
|
|
super(managementServerProperties); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void customize(UndertowServletWebServerFactory factory) { |
|
|
|
public void customize(UndertowServletWebServerFactory factory) { |
|
|
|
factory.setAccessLogPrefix(customizePrefix(factory.getAccessLogPrefix())); |
|
|
|
factory.setAccessLogPrefix(customizePrefix(factory.getAccessLogPrefix())); |
|
|
|
@ -198,6 +215,10 @@ class ServletManagementChildContextConfiguration { |
|
|
|
static class JettyAccessLogCustomizer extends AccessLogCustomizer |
|
|
|
static class JettyAccessLogCustomizer extends AccessLogCustomizer |
|
|
|
implements WebServerFactoryCustomizer<JettyServletWebServerFactory> { |
|
|
|
implements WebServerFactoryCustomizer<JettyServletWebServerFactory> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JettyAccessLogCustomizer(ManagementServerProperties managementServerProperties) { |
|
|
|
|
|
|
|
super(managementServerProperties); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void customize(JettyServletWebServerFactory factory) { |
|
|
|
public void customize(JettyServletWebServerFactory factory) { |
|
|
|
factory.addServerCustomizers(this::customizeServer); |
|
|
|
factory.addServerCustomizers(this::customizeServer); |
|
|
|
|