类org.springframework.boot.autoconfigure.web.ServerProperties源码实例Demo

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

源代码1 项目: staffjoy   文件: RequestForwarder.java
public RequestForwarder(
        ServerProperties serverProperties,
        FaradayProperties faradayProperties,
        HttpClientProvider httpClientProvider,
        MappingsProvider mappingsProvider,
        LoadBalancer loadBalancer,
        Optional<MeterRegistry> meterRegistry,
        ProxyingTraceInterceptor traceInterceptor,
        PostForwardResponseInterceptor postForwardResponseInterceptor
) {
    this.serverProperties = serverProperties;
    this.faradayProperties = faradayProperties;
    this.httpClientProvider = httpClientProvider;
    this.mappingsProvider = mappingsProvider;
    this.loadBalancer = loadBalancer;
    this.meterRegistry = meterRegistry;
    this.traceInterceptor = traceInterceptor;
    this.postForwardResponseInterceptor = postForwardResponseInterceptor;
}
 
源代码2 项目: java-spring-web   文件: SkipPatternConfigTest.java
@Test
public void testShouldReturnEndpointsWithoutContextPath() {
  WebEndpointProperties webEndpointProperties = new WebEndpointProperties();
  ServerProperties properties = new ServerProperties();
  properties.getServlet().setContextPath("foo");

  EndpointsSupplier<ExposableWebEndpoint> endpointsSupplier = () -> {
    ExposableWebEndpoint infoEndpoint = createEndpoint("info");
    ExposableWebEndpoint healthEndpoint = createEndpoint("health");

    return Arrays.asList(infoEndpoint, healthEndpoint);
  };

  Optional<Pattern> pattern = new SkipPatternAutoConfiguration.ActuatorSkipPatternProviderConfig()
      .skipPatternForActuatorEndpointsSamePort(webEndpointProperties, endpointsSupplier)
      .pattern();

  then(pattern).isNotEmpty();
  then(pattern.get().pattern())
      .isEqualTo("/actuator/(info|info/.*|health|health/.*)");
}
 
源代码3 项目: tx-lcn   文件: H2DbProperties.java
public H2DbProperties(
        @Autowired(required = false) ConfigurableEnvironment environment,
        @Autowired(required = false) ServerProperties serverProperties) {
    String applicationName = "application";
    Integer port = 0;
    if (Objects.nonNull(environment)) {
        applicationName = environment.getProperty("spring.application.name");
    }
    if (Objects.nonNull(serverProperties)) {
        port = serverProperties.getPort();
    }
    this.filePath = System.getProperty("user.dir") +
            File.separator +
            ".txlcn" +
            File.separator +
            (StringUtils.hasText(applicationName) ? applicationName : "application") +
            "-" + port;
}
 
@SuppressWarnings("ConstantConditions")
public BackstopperSpringboot2ContainerErrorController(
    @NotNull ProjectApiErrors projectApiErrors,
    @NotNull UnhandledServletContainerErrorHelper unhandledServletContainerErrorHelper,
    @NotNull ServerProperties serverProperties
) {
    if (projectApiErrors == null) {
        throw new NullPointerException("ProjectApiErrors cannot be null.");
    }

    if (unhandledServletContainerErrorHelper == null) {
        throw new NullPointerException("UnhandledServletContainerErrorHelper cannot be null.");
    }

    if (serverProperties == null) {
        throw new NullPointerException("ServerProperties cannot be null.");
    }

    this.projectApiErrors = projectApiErrors;
    this.unhandledServletContainerErrorHelper = unhandledServletContainerErrorHelper;
    this.errorPath = serverProperties.getError().getPath();
}
 
@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;
}
 
源代码6 项目: staffjoy   文件: FaradayConfiguration.java
public FaradayConfiguration(FaradayProperties faradayProperties,
                            ServerProperties serverProperties,
                            StaffjoyPropreties staffjoyPropreties,
                            AssetLoader assetLoader) {
    this.faradayProperties = faradayProperties;
    this.serverProperties = serverProperties;
    this.staffjoyPropreties = staffjoyPropreties;
    this.assetLoader = assetLoader;
}
 
源代码7 项目: staffjoy   文件: ProgrammaticMappingsProvider.java
public ProgrammaticMappingsProvider(
        EnvConfig envConfig,
        ServerProperties serverProperties,
        FaradayProperties faradayProperties,
        MappingsValidator mappingsValidator,
        HttpClientProvider httpClientProvider
) {
    super(serverProperties, faradayProperties, mappingsValidator, httpClientProvider);
    this.envConfig = envConfig;
}
 
源代码8 项目: staffjoy   文件: MappingsProvider.java
public MappingsProvider(
        ServerProperties serverProperties,
        FaradayProperties faradayProperties,
        MappingsValidator mappingsValidator,
        HttpClientProvider httpClientProvider
) {
    this.serverProperties = serverProperties;
    this.faradayProperties = faradayProperties;
    this.mappingsValidator = mappingsValidator;
    this.httpClientProvider = httpClientProvider;
}
 
源代码9 项目: staffjoy   文件: ConfigurationMappingsProvider.java
public ConfigurationMappingsProvider(
        ServerProperties serverProperties,
        FaradayProperties faradayProperties,
        MappingsValidator mappingsValidator,
        HttpClientProvider httpClientProvider
) {
    super(serverProperties, faradayProperties,
            mappingsValidator, httpClientProvider);
}
 
源代码10 项目: beihu-boot   文件: DefaultErrorController.java
public DefaultErrorController(ErrorAttributes errorAttributes, ServerProperties properties) {
    super(errorAttributes == null ? new DefaultErrorAttributes() : errorAttributes);
    if (properties == null) {
        errorProperties = new ErrorProperties();
        errorProperties.setPath("/error");
    } else {
        this.errorProperties = properties.getError();
    }
}
 
public ErrorHandlerConfig(ServerProperties serverProperties,
                                 ResourceProperties resourceProperties,
                                 ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                 ServerCodecConfigurer serverCodecConfigurer,
                                 ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
public CustomErrorWebFluxAutoConfiguration(ServerProperties serverProperties,
                                           ResourceProperties resourceProperties,
                                           ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                           ServerCodecConfigurer serverCodecConfigurer,
                                           ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
源代码13 项目: SpringBlade   文件: ErrorHandlerConfiguration.java
public ErrorHandlerConfiguration(ServerProperties serverProperties,
								 ResourceProperties resourceProperties,
								 ObjectProvider<List<ViewResolver>> viewResolversProvider,
								 ServerCodecConfigurer serverCodecConfigurer,
								 ApplicationContext applicationContext) {
	this.serverProperties = serverProperties;
	this.applicationContext = applicationContext;
	this.resourceProperties = resourceProperties;
	this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
	this.serverCodecConfigurer = serverCodecConfigurer;
}
 
源代码14 项目: open-cloud   文件: GatewayConfiguration.java
/**
 * 路由加载器
 *
 * @return
 */
@Bean
public JdbcRouteLocator jdbcRouteLocator(ZuulProperties zuulProperties, ServerProperties serverProperties, JdbcTemplate jdbcTemplate, ApplicationEventPublisher publisher) {
    jdbcRouteLocator = new JdbcRouteLocator(serverProperties.getServlet().getContextPath(), zuulProperties, jdbcTemplate, publisher);
    log.info("JdbcRouteLocator:{}", jdbcRouteLocator);
    return jdbcRouteLocator;
}
 
源代码15 项目: fw-spring-cloud   文件: FwGatewayErrorConfigure.java
public FwGatewayErrorConfigure(ServerProperties serverProperties,
                                 ResourceProperties resourceProperties,
                                 ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                 ServerCodecConfigurer serverCodecConfigurer,
                                 ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
public ErrorHandlerConfiguration(ServerProperties serverProperties,
                                 ResourceProperties resourceProperties,
                                 ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                 ServerCodecConfigurer serverCodecConfigurer,
                                 ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
public ErrorHandlerConfiguration(ServerProperties serverProperties,
                                 ResourceProperties resourceProperties,
                                 ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                 ServerCodecConfigurer serverCodecConfigurer,
                                 ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
@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);
}
 
源代码19 项目: sophia_scaffolding   文件: ErrorHandler.java
public ErrorHandler(ServerProperties serverProperties,
                    ResourceProperties resourceProperties,
                    ObjectProvider<List<ViewResolver>> viewResolversProvider,
                    ServerCodecConfigurer serverCodecConfigurer,
                    ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
源代码20 项目: soul   文件: ErrorHandlerConfiguration.java
/**
 * Instantiates a new Error handler configuration.
 *
 * @param serverProperties      the server properties
 * @param resourceProperties    the resource properties
 * @param viewResolversProvider the view resolvers provider
 * @param serverCodecConfigurer the server codec configurer
 * @param applicationContext    the application context
 */
public ErrorHandlerConfiguration(final ServerProperties serverProperties,
                                 final ResourceProperties resourceProperties,
                                 final ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                 final ServerCodecConfigurer serverCodecConfigurer,
                                 final ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
public ErrorHandlerConfiguration(ServerProperties serverProperties,
                                 ResourceProperties resourceProperties,
                                 ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                 ServerCodecConfigurer serverCodecConfigurer,
                                 ApplicationContext applicationContext) {
	this.serverProperties = serverProperties;
	this.applicationContext = applicationContext;
	this.resourceProperties = resourceProperties;
	this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
	this.serverCodecConfigurer = serverCodecConfigurer;
}
 
@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);
}
 
源代码23 项目: pig   文件: DynamicRouteConfiguration.java
public DynamicRouteConfiguration(Registration registration, DiscoveryClient discovery,
                                 ZuulProperties zuulProperties, ServerProperties server, RedisTemplate redisTemplate) {
    this.registration = registration;
    this.discovery = discovery;
    this.zuulProperties = zuulProperties;
    this.server = server;
    this.redisTemplate = redisTemplate;
}
 
/**
 * Registers a custom {@link ErrorController} to change the default error handling approach.
 *
 * @param errorAttributes    Will be used to enrich error responses.
 * @param serverProperties   Will be used to access error related configurations.
 * @param errorViewResolvers All possible view resolvers to render the whitelabel error page.
 * @return The custom error controller instance.
 */
@Bean
@ConditionalOnBean(WebErrorHandlers.class)
@ConditionalOnMissingBean(ErrorController.class)
public BasicErrorController customErrorController(ErrorAttributes errorAttributes,
                                             ServerProperties serverProperties,
                                             ObjectProvider<ErrorViewResolver> errorViewResolvers) {
    List<ErrorViewResolver> resolvers = errorViewResolvers.orderedStream().collect(toList());
    return new CustomServletErrorController(errorAttributes, serverProperties.getError(), resolvers);
}
 
@Test
public void testExtractorsCount() {
	ConfigurableApplicationContext context = new SpringApplicationBuilder(
			BusConfig.class, EnvironmentMonitorAutoConfiguration.class,
			ServletWebServerFactoryAutoConfiguration.class, ServerProperties.class,
			PropertyPlaceholderAutoConfiguration.class).properties("server.port=-1")
					.run();
	PropertyPathEndpoint endpoint = context.getBean(PropertyPathEndpoint.class);
	assertThat(((Collection<?>) ReflectionTestUtils.getField(
			ReflectionTestUtils.getField(endpoint, "extractor"), "extractors"))
					.size()).isEqualTo(7);
	context.close();
}
 
源代码26 项目: JetfireCloud   文件: ExceptionAutoConfiguration.java
public ExceptionAutoConfiguration(ServerProperties serverProperties,
                                  ResourceProperties resourceProperties,
                                  ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                  ServerCodecConfigurer serverCodecConfigurer,
                                  ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider
            .getIfAvailable(() -> Collections.emptyList());
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
源代码27 项目: SpringCloud   文件: ExceptionAutoConfiguration.java
public ExceptionAutoConfiguration(ServerProperties serverProperties,
                                  ResourceProperties resourceProperties,
                                  ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                  ServerCodecConfigurer serverCodecConfigurer,
                                  ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider
            .getIfAvailable(() -> Collections.emptyList());
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
@Test
public void should_return_empty_when_no_endpoints() {
	EndpointsSupplier<ExposableWebEndpoint> endpointsSupplier = Collections::emptyList;
	Optional<Pattern> pattern = new SkipPatternConfiguration.ActuatorSkipPatternProviderConfig()
			.skipPatternForActuatorEndpointsSamePort(new ServerProperties(),
					new WebEndpointProperties(), endpointsSupplier)
			.skipPattern();

	then(pattern).isEmpty();
}
 
@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)));
}
 
@Before
public void beforeMethod() {
    projectApiErrorsMock = mock(ProjectApiErrors.class);
    unhandledContainerErrorHelperMock = mock(UnhandledServletContainerErrorHelper.class);
    servletRequestMock = mock(ServletRequest.class);
    serverPropertiesMock = mock(ServerProperties.class);
    errorPropertiesMock = mock(ErrorProperties.class);
    errorPath = UUID.randomUUID().toString();

    doReturn(errorPropertiesMock).when(serverPropertiesMock).getError();
    doReturn(errorPath).when(errorPropertiesMock).getPath();
}
 
 类方法
 同包方法