use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class ReactiveElasticsearchRestClientAutoConfiguration method clientConfiguration.
@Bean
@ConditionalOnMissingBean
public ClientConfiguration clientConfiguration() {
ClientConfiguration.MaybeSecureClientConfigurationBuilder builder = ClientConfiguration.builder().connectedTo(this.properties.getEndpoints().toArray(new String[0]));
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(this.properties.isUseSsl()).whenTrue().toCall(builder::usingSsl);
map.from(this.properties.getCredentials()).to((credentials) -> builder.withBasicAuth(credentials.getUsername(), credentials.getPassword()));
map.from(this.properties.getConnectionTimeout()).to(builder::withConnectTimeout);
map.from(this.properties.getSocketTimeout()).to(builder::withSocketTimeout);
map.from(this.properties.getPathPrefix()).to(builder::withPathPrefix);
configureExchangeStrategies(map, builder);
return builder.build();
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class NettyWebServerFactoryCustomizer method customize.
@Override
public void customize(NettyReactiveWebServerFactory factory) {
factory.setUseForwardHeaders(getOrDeduceUseForwardHeaders());
PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
ServerProperties.Netty nettyProperties = this.serverProperties.getNetty();
propertyMapper.from(nettyProperties::getConnectionTimeout).whenNonNull().to((connectionTimeout) -> customizeConnectionTimeout(factory, connectionTimeout));
propertyMapper.from(nettyProperties::getIdleTimeout).whenNonNull().to((idleTimeout) -> customizeIdleTimeout(factory, idleTimeout));
propertyMapper.from(nettyProperties::getMaxKeepAliveRequests).to((maxKeepAliveRequests) -> customizeMaxKeepAliveRequests(factory, maxKeepAliveRequests));
customizeRequestDecoder(factory, propertyMapper);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class UndertowWebServerFactoryCustomizer method mapAccessLogProperties.
private void mapAccessLogProperties(ConfigurableUndertowWebServerFactory factory) {
Accesslog properties = this.serverProperties.getUndertow().getAccesslog();
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(properties::isEnabled).to(factory::setAccessLogEnabled);
map.from(properties::getDir).to(factory::setAccessLogDirectory);
map.from(properties::getPattern).to(factory::setAccessLogPattern);
map.from(properties::getPrefix).to(factory::setAccessLogPrefix);
map.from(properties::getSuffix).to(factory::setAccessLogSuffix);
map.from(properties::isRotate).to(factory::setAccessLogRotate);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class UndertowWebServerFactoryCustomizer method customize.
@Override
public void customize(ConfigurableUndertowWebServerFactory factory) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
ServerOptions options = new ServerOptions(factory);
ServerProperties properties = this.serverProperties;
map.from(properties::getMaxHttpHeaderSize).asInt(DataSize::toBytes).when(this::isPositive).to(options.option(UndertowOptions.MAX_HEADER_SIZE));
mapUndertowProperties(factory, options);
mapAccessLogProperties(factory);
map.from(this::getOrDeduceUseForwardHeaders).to(factory::setUseForwardHeaders);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class UndertowWebServerFactoryCustomizer method mapUndertowProperties.
private void mapUndertowProperties(ConfigurableUndertowWebServerFactory factory, ServerOptions serverOptions) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
Undertow properties = this.serverProperties.getUndertow();
map.from(properties::getBufferSize).whenNonNull().asInt(DataSize::toBytes).to(factory::setBufferSize);
ServerProperties.Undertow.Threads threadProperties = properties.getThreads();
map.from(threadProperties::getIo).to(factory::setIoThreads);
map.from(threadProperties::getWorker).to(factory::setWorkerThreads);
map.from(properties::getDirectBuffers).to(factory::setUseDirectBuffers);
map.from(properties::getMaxHttpPostSize).as(DataSize::toBytes).when(this::isPositive).to(serverOptions.option(UndertowOptions.MAX_ENTITY_SIZE));
map.from(properties::getMaxParameters).to(serverOptions.option(UndertowOptions.MAX_PARAMETERS));
map.from(properties::getMaxHeaders).to(serverOptions.option(UndertowOptions.MAX_HEADERS));
map.from(properties::getMaxCookies).to(serverOptions.option(UndertowOptions.MAX_COOKIES));
map.from(properties::isAllowEncodedSlash).to(serverOptions.option(UndertowOptions.ALLOW_ENCODED_SLASH));
map.from(properties::isDecodeUrl).to(serverOptions.option(UndertowOptions.DECODE_URL));
map.from(properties::getUrlCharset).as(Charset::name).to(serverOptions.option(UndertowOptions.URL_CHARSET));
map.from(properties::isAlwaysSetKeepAlive).to(serverOptions.option(UndertowOptions.ALWAYS_SET_KEEP_ALIVE));
map.from(properties::getNoRequestTimeout).asInt(Duration::toMillis).to(serverOptions.option(UndertowOptions.NO_REQUEST_TIMEOUT));
map.from(properties.getOptions()::getServer).to(serverOptions.forEach(serverOptions::option));
SocketOptions socketOptions = new SocketOptions(factory);
map.from(properties.getOptions()::getSocket).to(socketOptions.forEach(socketOptions::option));
}
Aggregations