类org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties源码实例Demo

下面列出了怎么用org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties的API类实例代码及写法,或者点击链接到github查看源代码。

@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;
}
 
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 项目: java-spring-web   文件: SkipPatternConfigTest.java
@Test
public void testShouldReturnEmptyWhenManagementContextHasNoContextPath() {
  Optional<Pattern> pattern = new SkipPatternAutoConfiguration.ManagementSkipPatternProviderConfig()
      .skipPatternForManagementServerProperties(
          new ManagementServerProperties())
      .pattern();

  then(pattern).isEmpty();
}
 
源代码4 项目: java-spring-web   文件: SkipPatternConfigTest.java
@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.*");
}
 
/**
 * 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();
}
 
@Bean
@ConditionalOnBean(ManagementServerProperties.class)
public SingleSkipPattern skipPatternForManagementServerProperties(
		final ManagementServerProperties managementServerProperties) {
	return () -> getPatternForManagementServerProperties(
			managementServerProperties);
}
 
@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();
}
 
@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);
        }
    };
}
 
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;
	}
}
 
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;
}
 
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;
}
 
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;
}
 
@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);
}
 
@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)));
}
 
@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);
}
 
@Bean
@ConditionalOnBean(ManagementServerProperties.class)
public SkipPattern skipPatternForManagementServerProperties(
    final ManagementServerProperties managementServerProperties) {
  return () -> getPatternForManagementServerProperties(managementServerProperties);
}
 
 类所在包
 同包方法