Java源码示例:org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties
示例1
@Autowired
public LightminClientProperties(final ManagementServerProperties managementServerProperties,
final ServerProperties serverProperties,
@Value("${spring.batch.lightmin.application-name:null}") final String name,
@Value("${endpoints.health.id:health}") final String healthEndpointId,
final WebEndpointProperties webEndpointProperties,
final Environment environment) {
if (name == null || "null".equals(name)) {
this.name = environment.getProperty("spring.application.name", "spring-boot-application");
} else {
this.name = name;
}
this.healthEndpointId = healthEndpointId;
this.managementServerProperties = managementServerProperties;
this.serverProperties = serverProperties;
this.webEndpointProperties = webEndpointProperties;
}
示例2
static Optional<Pattern> getPatternForManagementServerProperties(
ManagementServerProperties managementServerProperties) {
String contextPath = managementServerProperties.getServlet().getContextPath();
if (StringUtils.hasText(contextPath)) {
return Optional.of(Pattern.compile(contextPath + ".*"));
}
return Optional.empty();
}
示例3
@Test
public void testShouldReturnEmptyWhenManagementContextHasNoContextPath() {
Optional<Pattern> pattern = new SkipPatternAutoConfiguration.ManagementSkipPatternProviderConfig()
.skipPatternForManagementServerProperties(
new ManagementServerProperties())
.pattern();
then(pattern).isEmpty();
}
示例4
@Test
public void testShouldReturnManagementContextWithContextPath() {
ManagementServerProperties properties = new ManagementServerProperties();
properties.getServlet().setContextPath("foo");
Optional<Pattern> pattern = new SkipPatternAutoConfiguration.ManagementSkipPatternProviderConfig()
.skipPatternForManagementServerProperties(properties).pattern();
then(pattern).isNotEmpty();
then(pattern.get().pattern()).isEqualTo("foo.*");
}
示例5
/**
* Sets or appends {@link ManagementServerProperties#getServlet()} to the skip
* pattern. If neither is available then sets the default one
* @param managementServerProperties properties
* @return optional skip pattern
*/
static Optional<Pattern> getPatternForManagementServerProperties(
ManagementServerProperties managementServerProperties) {
String contextPath = managementServerProperties.getServlet().getContextPath();
if (StringUtils.hasText(contextPath)) {
return Optional.of(Pattern.compile(contextPath + ".*"));
}
return Optional.empty();
}
示例6
@Bean
@ConditionalOnBean(ManagementServerProperties.class)
public SingleSkipPattern skipPatternForManagementServerProperties(
final ManagementServerProperties managementServerProperties) {
return () -> getPatternForManagementServerProperties(
managementServerProperties);
}
示例7
@Test
public void should_return_empty_when_management_context_has_no_context_path()
throws Exception {
Optional<Pattern> pattern = new SkipPatternConfiguration.ManagementSkipPatternProviderConfig()
.skipPatternForManagementServerProperties(
new ManagementServerProperties())
.skipPattern();
then(pattern).isEmpty();
}
示例8
@Bean
@ConditionalOnProperty("management.server.port")
ArmeriaServerConfigurator secureActuatorServerConfigurator(WebEndpointProperties properties,
ManagementServerProperties serverProperties,
ConfigurableEnvironment environment,
ArmeriaSettings armeriaSettings) {
return sb -> {
final Port port = obtainManagementServerPort(serverProperties.getPort());
if (port != null) {
configurePorts(sb, ImmutableList.of(port));
addLocalManagementPortPropertyAlias(environment, port);
configureSecureDecorator(sb, port, properties.getBasePath(), armeriaSettings);
}
};
}
示例9
public static Integer getPort(BeanFactory beanFactory) {
if (!hasActuator) {
return null;
}
try {
ManagementServerProperties properties = beanFactory
.getBean(ManagementServerProperties.class);
return properties.getPort();
}
catch (NoSuchBeanDefinitionException ex) {
return null;
}
}
示例10
public CloudFoundryApplicationFactory(InstanceProperties instance, ManagementServerProperties management,
ServerProperties server, PathMappedEndpoints pathMappedEndpoints, WebEndpointProperties webEndpoint,
MetadataContributor metadataContributor, CloudFoundryApplicationProperties cfApplicationProperties) {
super(instance, management, server, pathMappedEndpoints, webEndpoint, metadataContributor);
this.cfApplicationProperties = cfApplicationProperties;
this.instance = instance;
}
示例11
public DefaultApplicationFactory(InstanceProperties instance, ManagementServerProperties management,
ServerProperties server, PathMappedEndpoints pathMappedEndpoints, WebEndpointProperties webEndpoint,
MetadataContributor metadataContributor) {
this.instance = instance;
this.management = management;
this.server = server;
this.pathMappedEndpoints = pathMappedEndpoints;
this.webEndpoint = webEndpoint;
this.metadataContributor = metadataContributor;
}
示例12
public ServletApplicationFactory(InstanceProperties instance, ManagementServerProperties management,
ServerProperties server, ServletContext servletContext, PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint, MetadataContributor metadataContributor,
DispatcherServletPath dispatcherServletPath) {
super(instance, management, server, pathMappedEndpoints, webEndpoint, metadataContributor);
this.servletContext = servletContext;
this.server = server;
this.management = management;
this.instance = instance;
this.dispatcherServletPath = dispatcherServletPath;
}
示例13
@Bean
@Lazy(false)
@ConditionalOnMissingBean
public ApplicationFactory applicationFactory(InstanceProperties instance, ManagementServerProperties management,
ServerProperties server, ServletContext servletContext, PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint, ObjectProvider<List<MetadataContributor>> metadataContributors,
DispatcherServletPath dispatcherServletPath) {
return new ServletApplicationFactory(instance, management, server, servletContext, pathMappedEndpoints,
webEndpoint,
new CompositeMetadataContributor(metadataContributors.getIfAvailable(Collections::emptyList)),
dispatcherServletPath);
}
示例14
@Bean
@Lazy(false)
@ConditionalOnMissingBean
public ApplicationFactory applicationFactory(InstanceProperties instance, ManagementServerProperties management,
ServerProperties server, PathMappedEndpoints pathMappedEndpoints, WebEndpointProperties webEndpoint,
ObjectProvider<List<MetadataContributor>> metadataContributors) {
return new DefaultApplicationFactory(instance, management, server, pathMappedEndpoints, webEndpoint,
new CompositeMetadataContributor(metadataContributors.getIfAvailable(Collections::emptyList)));
}
示例15
@Bean
@Lazy(false)
@ConditionalOnMissingBean
public CloudFoundryApplicationFactory applicationFactory(InstanceProperties instance,
ManagementServerProperties management, ServerProperties server, PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint, ObjectProvider<List<MetadataContributor>> metadataContributors,
CloudFoundryApplicationProperties cfApplicationProperties) {
return new CloudFoundryApplicationFactory(instance, management, server, pathMappedEndpoints, webEndpoint,
new CompositeMetadataContributor(metadataContributors.getIfAvailable(Collections::emptyList)),
cfApplicationProperties);
}
示例16
@Bean
@ConditionalOnBean(ManagementServerProperties.class)
public SkipPattern skipPatternForManagementServerProperties(
final ManagementServerProperties managementServerProperties) {
return () -> getPatternForManagementServerProperties(managementServerProperties);
}