public static RequestMatcher getRequestMatcher(
ManagementContextResolver contextResolver) {
if (contextResolver == null) {
return null;
}
ManagementServerProperties management = contextResolver
.getApplicationContext().getBean(ManagementServerProperties.class);
ServerProperties server = contextResolver.getApplicationContext()
.getBean(ServerProperties.class);
String path = management.getContextPath();
if (StringUtils.hasText(path)) {
AntPathRequestMatcher matcher = new AntPathRequestMatcher(
server.getPath(path) + "/**");
return matcher;
}
// Match everything, including the sensitive and non-sensitive paths
return new LazyEndpointPathRequestMatcher(contextResolver, EndpointPaths.ALL);
}
java类org.springframework.boot.autoconfigure.web.ServerProperties的实例源码
ManagementWebSecurityAutoConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 38
收藏 0
点赞 0
评论 0
PurgeAccessLogAutoConfiguration.java 文件源码
项目:spring-boot-starter-purge-accesslog
阅读 37
收藏 0
点赞 0
评论 0
/**
* Purge access log customizer embedded servlet container customizer.
*
* @param serverProperties the server properties
* @param purgeProperties the purge properties
* @return the embedded servlet container customizer
*/
@Bean
public EmbeddedServletContainerCustomizer purgeAccessLogCustomizer(
final ServerProperties serverProperties,
final PurgeProperties purgeProperties) {
return container -> {
final UndertowEmbeddedServletContainerFactory factory = (UndertowEmbeddedServletContainerFactory)
container;
final Undertow.Accesslog accesslog = serverProperties.getUndertow()
.getAccesslog();
final UndertowPurgeAccessLogHolder accessLogHolder = new UndertowPurgeAccessLogHolder(
purgeProperties, accesslog.getDir().toPath(),
accesslog.getPrefix(), accesslog.getSuffix());
factory.addDeploymentInfoCustomizers(accessLogHolder);
};
}
PurgeAccessLogAutoConfiguration.java 文件源码
项目:spring-boot-starter-purge-accesslog
阅读 49
收藏 0
点赞 0
评论 0
/**
* Purge access log customizer embedded servlet container customizer.
*
* @param serverProperties the server properties
* @param purgeProperties the purge properties
* @return the embedded servlet container customizer
*/
@Bean
public EmbeddedServletContainerCustomizer purgeAccessLogCustomizer(
final ServerProperties serverProperties,
final PurgeProperties purgeProperties) {
return container -> {
final TomcatEmbeddedServletContainerFactory factory = (TomcatEmbeddedServletContainerFactory) container;
final Accesslog accesslog = serverProperties.getTomcat().getAccesslog();
factory.getEngineValves().stream()
.filter(valve -> valve instanceof AccessLogValve)
.map(valve -> (AccessLogValve) valve).findFirst()
.ifPresent(valve -> {
final TomcatPurgeAccessLogHolder accessLogHolder = new TomcatPurgeAccessLogHolder(
purgeProperties, Paths.get(accesslog.getDirectory()),
accesslog.getPrefix(), accesslog.getSuffix(), valve);
factory.addContextCustomizers(accessLogHolder);
});
};
}
AppConfig.java 文件源码
项目:Robocode
阅读 39
收藏 0
点赞 0
评论 0
@Bean
@Autowired
public EmbeddedServletContainerCustomizer servletContainerCustomizer(ServerProperties properties) {
return container -> {
if (container instanceof JettyEmbeddedServletContainerFactory) {
JettyEmbeddedServletContainerFactory jettyContainer = (JettyEmbeddedServletContainerFactory) container;
jettyContainer.addConfigurations(new AbstractConfiguration() {
@Override
public void configure(WebAppContext context) throws Exception {
properties.getContextParameters().forEach((k, v) -> context.setInitParameter(k, v));
}
});
}
};
}
RequestForwarder.java 文件源码
项目:charon-spring-boot-starter
阅读 34
收藏 0
点赞 0
评论 0
public RequestForwarder(
ServerProperties server,
CharonProperties charon,
HttpClientProvider httpClientProvider,
MappingsProvider mappingsProvider,
LoadBalancer loadBalancer,
MetricRegistry metricRegistry,
TraceInterceptor traceInterceptor
) {
this.server = server;
this.charon = charon;
this.httpClientProvider = httpClientProvider;
this.mappingsProvider = mappingsProvider;
this.loadBalancer = loadBalancer;
this.metricRegistry = metricRegistry;
this.traceInterceptor = traceInterceptor;
}
ManagementWebSecurityAutoConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 32
收藏 0
点赞 0
评论 0
public static RequestMatcher getRequestMatcher(
ManagementContextResolver contextResolver) {
if (contextResolver == null) {
return null;
}
ManagementServerProperties management = contextResolver
.getApplicationContext().getBean(ManagementServerProperties.class);
ServerProperties server = contextResolver.getApplicationContext()
.getBean(ServerProperties.class);
String path = management.getContextPath();
if (StringUtils.hasText(path)) {
AntPathRequestMatcher matcher = new AntPathRequestMatcher(
server.getPath(path) + "/**");
return matcher;
}
// Match everything, including the sensitive and non-sensitive paths
return new LazyEndpointPathRequestMatcher(contextResolver, EndpointPaths.ALL);
}
EndpointWebMvcChildContextConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 34
收藏 0
点赞 0
评论 0
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (this.managementServerProperties == null) {
this.managementServerProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory,
ManagementServerProperties.class);
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, ServerProperties.class);
}
// Customize as per the parent context first (so e.g. the access logs go to
// the same place)
this.server.customize(container);
// Then reset the error pages
container.setErrorPages(Collections.<ErrorPage>emptySet());
// and the context path
container.setContextPath("");
// and add the management-specific bits
container.setPort(this.managementServerProperties.getPort());
if (this.managementServerProperties.getSsl() != null) {
container.setSsl(this.managementServerProperties.getSsl());
}
container.setServerHeader(this.server.getServerHeader());
container.setAddress(this.managementServerProperties.getAddress());
container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
}
EndpointWebMvcAutoConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 41
收藏 0
点赞 0
评论 0
public static ManagementServerPort get(Environment environment,
BeanFactory beanFactory) {
Integer serverPort = getPortProperty(environment, "server.");
if (serverPort == null && hasCustomBeanDefinition(beanFactory,
ServerProperties.class, ServerPropertiesAutoConfiguration.class)) {
serverPort = getTemporaryBean(beanFactory, ServerProperties.class)
.getPort();
}
Integer managementPort = getPortProperty(environment, "management.");
if (managementPort == null && hasCustomBeanDefinition(beanFactory,
ManagementServerProperties.class,
ManagementServerPropertiesAutoConfiguration.class)) {
managementPort = getTemporaryBean(beanFactory,
ManagementServerProperties.class).getPort();
}
if (managementPort != null && managementPort < 0) {
return DISABLE;
}
return ((managementPort == null)
|| (serverPort == null && managementPort.equals(8080))
|| (managementPort != 0 && managementPort.equals(serverPort)) ? SAME
: DIFFERENT);
}
EndpointWebMvcAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 37
收藏 0
点赞 0
评论 0
@Test
public void overrideServerProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"server.displayName:foo");
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
ServerProperties serverProperties = this.applicationContext
.getBean(ServerProperties.class);
assertThat(serverProperties.getDisplayName()).isEqualTo("foo");
}
EndpointWebMvcChildContextConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 39
收藏 0
点赞 0
评论 0
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (this.managementServerProperties == null) {
this.managementServerProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory,
ManagementServerProperties.class);
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, ServerProperties.class);
}
// Customize as per the parent context first (so e.g. the access logs go to
// the same place)
this.server.customize(container);
// Then reset the error pages
container.setErrorPages(Collections.<ErrorPage>emptySet());
// and the context path
container.setContextPath("");
// and add the management-specific bits
container.setPort(this.managementServerProperties.getPort());
container.setServerHeader(this.server.getServerHeader());
container.setAddress(this.managementServerProperties.getAddress());
container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
}
EndpointWebMvcAutoConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 31
收藏 0
点赞 0
评论 0
public static ManagementServerPort get(Environment environment,
BeanFactory beanFactory) {
Integer serverPort = getPortProperty(environment, "server.");
if (serverPort == null && hasCustomBeanDefinition(beanFactory,
ServerProperties.class, ServerPropertiesAutoConfiguration.class)) {
serverPort = getTemporaryBean(beanFactory, ServerProperties.class)
.getPort();
}
Integer managementPort = getPortProperty(environment, "management.");
if (managementPort == null && hasCustomBeanDefinition(beanFactory,
ManagementServerProperties.class,
ManagementServerPropertiesAutoConfiguration.class)) {
managementPort = getTemporaryBean(beanFactory,
ManagementServerProperties.class).getPort();
}
if (managementPort != null && managementPort < 0) {
return DISABLE;
}
return ((managementPort == null)
|| (serverPort == null && managementPort.equals(8080))
|| (managementPort != 0 && managementPort.equals(serverPort)) ? SAME
: DIFFERENT);
}
EndpointWebMvcAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void overrideServerProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"server.displayName:foo");
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
ServerProperties serverProperties = this.applicationContext
.getBean(ServerProperties.class);
assertThat(serverProperties.getDisplayName()).isEqualTo("foo");
}
EndpointWebMvcChildContextConfiguration.java 文件源码
项目:contestparser
阅读 38
收藏 0
点赞 0
评论 0
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (this.managementServerProperties == null) {
this.managementServerProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory,
ManagementServerProperties.class);
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, ServerProperties.class);
}
// Customize as per the parent context first (so e.g. the access logs go to
// the same place)
this.server.customize(container);
// Then reset the error pages
container.setErrorPages(Collections.<ErrorPage>emptySet());
// and add the management-specific bits
container.setPort(this.managementServerProperties.getPort());
container.setAddress(this.managementServerProperties.getAddress());
container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
}
ServletFilterErrorHandler.java 文件源码
项目:errorest-spring-boot-starter
阅读 32
收藏 0
点赞 0
评论 0
public ServletFilterErrorHandler(ErrorAttributes errorAttributes, ServerProperties serverProperties, ErrorsFactory errorsFactory, ErrorDataProviderContext providerContext) {
super(errorAttributes, emptyList());
this.errorAttributes = errorAttributes;
errorProperties = serverProperties.getError();
this.errorsFactory = errorsFactory;
this.providerContext = providerContext;
}
SampleController.java 文件源码
项目:wingtips
阅读 35
收藏 0
点赞 0
评论 0
@Autowired
public SampleController(ServerProperties serverProps, Environment environment) {
this.serverPort = serverProps.getPort();
String userIdHeaderKeysFromEnv = environment.getProperty("wingtips.user-id-header-keys");
this.userIdHeaderKeys = (userIdHeaderKeysFromEnv == null)
? null
: Arrays.asList(userIdHeaderKeysFromEnv.split(","));
}
MappingsProvider.java 文件源码
项目:charon-spring-boot-starter
阅读 22
收藏 0
点赞 0
评论 0
public MappingsProvider(
ServerProperties server,
CharonProperties charon,
MappingsCorrector mappingsCorrector,
HttpClientProvider httpClientProvider
) {
this.server = server;
this.charon = charon;
this.mappingsCorrector = mappingsCorrector;
this.httpClientProvider = httpClientProvider;
}
ConfigurationMappingsProvider.java 文件源码
项目:charon-spring-boot-starter
阅读 36
收藏 0
点赞 0
评论 0
public ConfigurationMappingsProvider(
ServerProperties server,
CharonProperties charon,
MappingsCorrector mappingsCorrector,
HttpClientProvider httpClientProvider
) {
super(server, charon, mappingsCorrector, httpClientProvider);
}
ManagementWebSecurityAutoConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 46
收藏 0
点赞 0
评论 0
private RequestMatcher createDelegate() {
ServerProperties server = this.contextResolver.getApplicationContext()
.getBean(ServerProperties.class);
List<RequestMatcher> matchers = new ArrayList<RequestMatcher>();
EndpointHandlerMapping endpointHandlerMapping = getRequiredEndpointHandlerMapping();
for (String path : this.endpointPaths.getPaths(endpointHandlerMapping)) {
matchers.add(new AntPathRequestMatcher(server.getPath(path)));
}
return (matchers.isEmpty() ? MATCH_NONE : new OrRequestMatcher(matchers));
}
EndpointWebMvcHypermediaManagementContextConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 39
收藏 0
点赞 0
评论 0
@Bean
@ConditionalOnBean(DocsMvcEndpoint.class)
@ConditionalOnMissingBean(CurieProvider.class)
@ConditionalOnProperty(prefix = "endpoints.docs.curies", name = "enabled", matchIfMissing = false)
public DefaultCurieProvider curieProvider(ServerProperties server,
ManagementServerProperties management, DocsMvcEndpoint endpoint) {
String path = management.getContextPath() + endpoint.getPath()
+ "/#spring_boot_actuator__{rel}";
if (server.getPort().equals(management.getPort()) && management.getPort() != 0) {
path = server.getPath(path);
}
return new DefaultCurieProvider("boot", new UriTemplate(path));
}
EndpointWebMvcAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 37
收藏 0
点赞 0
评论 0
@Bean
public ServerProperties serverProperties() {
ServerProperties properties = new ServerProperties() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
ServerPortConfig.this.count++;
super.customize(container);
}
};
properties.setPort(server.getPort());
properties.setContextPath(server.getContextPath());
return properties;
}
SamplePropertyValidationApplicationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void validatorOnlyCalledOnSupportedClass() {
this.context.register(SamplePropertyValidationApplication.class);
this.context.register(ServerProperties.class); // our validator will not apply
EnvironmentTestUtils.addEnvironment(this.context, "sample.host:192.168.0.1",
"sample.port:9090");
this.context.refresh();
SampleProperties properties = this.context.getBean(SampleProperties.class);
assertThat(properties.getHost()).isEqualTo("192.168.0.1");
assertThat(properties.getPort()).isEqualTo(Integer.valueOf(9090));
}
EmbeddedKeycloakApp.java 文件源码
项目:spring-boot-keycloak-server-example
阅读 30
收藏 0
点赞 0
评论 0
@Bean
ApplicationListener<ApplicationReadyEvent> onApplicationReadyEventListener(ServerProperties serverProperties, KeycloakServerProperties keycloakServerProperties) {
return (evt) -> {
Integer port = serverProperties.getPort();
String rootContextPath = serverProperties.getContextPath();
String keycloakContextPath = keycloakServerProperties.getContextPath();
System.out.printf("Embedded Keycloak started: http://localhost:%s%s%s to use keycloak%n", port, rootContextPath, keycloakContextPath);
};
}
ServerPropertiesEndpointLocatorTests.java 文件源码
项目:Zipkin
阅读 23
收藏 0
点赞 0
评论 0
@Test
public void portDefaultsTo8080() {
ServerPropertiesEndpointLocator locator = new ServerPropertiesEndpointLocator(
new ServerProperties(), "unknown");
assertThat(locator.local().port).isEqualTo((short) 8080);
}
ServerPropertiesEndpointLocatorTests.java 文件源码
项目:Zipkin
阅读 36
收藏 0
点赞 0
评论 0
@Test
public void portFromServerProperties() {
ServerProperties properties = new ServerProperties();
properties.setPort(1234);
ServerPropertiesEndpointLocator locator = new ServerPropertiesEndpointLocator(
properties, "unknown");
assertThat(locator.local().port).isEqualTo((short) 1234);
}
ServerPropertiesEndpointLocatorTests.java 文件源码
项目:Zipkin
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void portDefaultsToLocalhost() {
ServerPropertiesEndpointLocator locator = new ServerPropertiesEndpointLocator(
new ServerProperties(), "unknown");
assertThat(locator.local().ipv4).isEqualTo(127 << 24 | 1);
}
ServerPropertiesEndpointLocatorTests.java 文件源码
项目:Zipkin
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void hostFromServerPropertiesIp() throws UnknownHostException {
ServerProperties properties = new ServerProperties();
properties.setAddress(InetAddress.getByAddress(new byte[] { 1, 2, 3, 4 }));
ServerPropertiesEndpointLocator locator = new ServerPropertiesEndpointLocator(
properties, "unknown");
assertThat(locator.local().ipv4).isEqualTo(1 << 24 | 2 << 16 | 3 << 8 | 4);
}
ServerPropertiesHostLocatorTests.java 文件源码
项目:Zipkin
阅读 32
收藏 0
点赞 0
评论 0
@Test
public void portDefaultsTo8080() {
ServerPropertiesHostLocator locator = new ServerPropertiesHostLocator(
new ServerProperties(), "unknown");
assertThat(locator.locate(this.span).getPort()).isEqualTo((short) 8080);
}
ServerPropertiesHostLocatorTests.java 文件源码
项目:Zipkin
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void portFromServerProperties() {
ServerProperties properties = new ServerProperties();
properties.setPort(1234);
ServerPropertiesHostLocator locator = new ServerPropertiesHostLocator(properties,
"unknown");
assertThat(locator.locate(this.span).getPort()).isEqualTo((short) 1234);
}
ServerPropertiesHostLocatorTests.java 文件源码
项目:Zipkin
阅读 23
收藏 0
点赞 0
评论 0
@Test
public void portDefaultsToLocalhost() {
ServerPropertiesHostLocator locator = new ServerPropertiesHostLocator(
new ServerProperties(), "unknown");
assertThat(locator.locate(this.span).getAddress()).isEqualTo("127.0.0.1");
}
ServerPropertiesHostLocatorTests.java 文件源码
项目:Zipkin
阅读 29
收藏 0
点赞 0
评论 0
@Test
public void hostFromServerPropertiesIp() throws UnknownHostException {
ServerProperties properties = new ServerProperties();
properties.setAddress(InetAddress.getByAddress(new byte[] { 1, 2, 3, 4 }));
ServerPropertiesHostLocator locator = new ServerPropertiesHostLocator(properties,
"unknown");
assertThat(locator.locate(this.span).getAddress()).isEqualTo("1.2.3.4");
}