use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class TomcatWebServerFactoryCustomizer method customizeAccessLog.
private void customizeAccessLog(ConfigurableTomcatWebServerFactory factory) {
ServerProperties.Tomcat tomcatProperties = this.serverProperties.getTomcat();
AccessLogValve valve = new AccessLogValve();
PropertyMapper map = PropertyMapper.get();
Accesslog accessLogConfig = tomcatProperties.getAccesslog();
map.from(accessLogConfig.getConditionIf()).to(valve::setConditionIf);
map.from(accessLogConfig.getConditionUnless()).to(valve::setConditionUnless);
map.from(accessLogConfig.getPattern()).to(valve::setPattern);
map.from(accessLogConfig.getDirectory()).to(valve::setDirectory);
map.from(accessLogConfig.getPrefix()).to(valve::setPrefix);
map.from(accessLogConfig.getSuffix()).to(valve::setSuffix);
map.from(accessLogConfig.getEncoding()).whenHasText().to(valve::setEncoding);
map.from(accessLogConfig.getLocale()).whenHasText().to(valve::setLocale);
map.from(accessLogConfig.isCheckExists()).to(valve::setCheckExists);
map.from(accessLogConfig.isRotate()).to(valve::setRotatable);
map.from(accessLogConfig.isRenameOnRotate()).to(valve::setRenameOnRotate);
map.from(accessLogConfig.getMaxDays()).to(valve::setMaxDays);
map.from(accessLogConfig.getFileDateFormat()).to(valve::setFileDateFormat);
map.from(accessLogConfig.isIpv6Canonical()).to(valve::setIpv6Canonical);
map.from(accessLogConfig.isRequestAttributesEnabled()).to(valve::setRequestAttributesEnabled);
map.from(accessLogConfig.isBuffered()).to(valve::setBuffered);
factory.addEngineValves(valve);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class ReactiveMultipartAutoConfiguration method defaultPartHttpMessageReaderCustomizer.
@Bean
@Order(0)
CodecCustomizer defaultPartHttpMessageReaderCustomizer(ReactiveMultipartProperties multipartProperties) {
return (configurer) -> configurer.defaultCodecs().configureDefaultCodec((codec) -> {
if (codec instanceof DefaultPartHttpMessageReader) {
DefaultPartHttpMessageReader defaultPartHttpMessageReader = (DefaultPartHttpMessageReader) codec;
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(multipartProperties::getMaxInMemorySize).asInt(DataSize::toBytes).to(defaultPartHttpMessageReader::setMaxInMemorySize);
map.from(multipartProperties::getMaxHeadersSize).asInt(DataSize::toBytes).to(defaultPartHttpMessageReader::setMaxHeadersSize);
map.from(multipartProperties::getMaxDiskUsagePerPart).asInt(DataSize::toBytes).to(defaultPartHttpMessageReader::setMaxDiskUsagePerPart);
map.from(multipartProperties::getMaxParts).to(defaultPartHttpMessageReader::setMaxParts);
map.from(multipartProperties::getStreaming).to(defaultPartHttpMessageReader::setStreaming);
map.from(multipartProperties::getFileStorageDirectory).as(Paths::get).to((dir) -> configureFileStorageDirectory(defaultPartHttpMessageReader, dir));
map.from(multipartProperties::getHeadersCharset).to(defaultPartHttpMessageReader::setHeadersCharset);
}
});
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class ServletWebServerFactoryCustomizer method customize.
@Override
public void customize(ConfigurableServletWebServerFactory factory) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(this.serverProperties::getPort).to(factory::setPort);
map.from(this.serverProperties::getAddress).to(factory::setAddress);
map.from(this.serverProperties.getServlet()::getContextPath).to(factory::setContextPath);
map.from(this.serverProperties.getServlet()::getApplicationDisplayName).to(factory::setDisplayName);
map.from(this.serverProperties.getServlet()::isRegisterDefaultServlet).to(factory::setRegisterDefaultServlet);
map.from(this.serverProperties.getServlet()::getSession).to(factory::setSession);
map.from(this.serverProperties::getSsl).to(factory::setSsl);
map.from(this.serverProperties.getServlet()::getJsp).to(factory::setJsp);
map.from(this.serverProperties::getCompression).to(factory::setCompression);
map.from(this.serverProperties::getHttp2).to(factory::setHttp2);
map.from(this.serverProperties::getServerHeader).to(factory::setServerHeader);
map.from(this.serverProperties.getServlet()::getContextParameters).to(factory::setInitParameters);
map.from(this.serverProperties.getShutdown()).to(factory::setShutdown);
for (WebListenerRegistrar registrar : this.webListenerRegistrars) {
registrar.register(factory);
}
if (!CollectionUtils.isEmpty(this.cookieSameSiteSuppliers)) {
factory.setCookieSameSiteSuppliers(this.cookieSameSiteSuppliers);
}
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class ReactiveWebServerFactoryCustomizer method customize.
@Override
public void customize(ConfigurableReactiveWebServerFactory factory) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(this.serverProperties::getPort).to(factory::setPort);
map.from(this.serverProperties::getAddress).to(factory::setAddress);
map.from(this.serverProperties::getSsl).to(factory::setSsl);
map.from(this.serverProperties::getCompression).to(factory::setCompression);
map.from(this.serverProperties::getHttp2).to(factory::setHttp2);
map.from(this.serverProperties.getShutdown()).to(factory::setShutdown);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class OAuth2ClientPropertiesRegistrationAdapter method getClientRegistration.
private static ClientRegistration getClientRegistration(String registrationId, OAuth2ClientProperties.Registration properties, Map<String, Provider> providers) {
Builder builder = getBuilderFromIssuerIfPossible(registrationId, properties.getProvider(), providers);
if (builder == null) {
builder = getBuilder(registrationId, properties.getProvider(), providers);
}
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(properties::getClientId).to(builder::clientId);
map.from(properties::getClientSecret).to(builder::clientSecret);
map.from(properties::getClientAuthenticationMethod).as(ClientAuthenticationMethod::new).to(builder::clientAuthenticationMethod);
map.from(properties::getAuthorizationGrantType).as(AuthorizationGrantType::new).to(builder::authorizationGrantType);
map.from(properties::getRedirectUri).to(builder::redirectUri);
map.from(properties::getScope).as(StringUtils::toStringArray).to(builder::scope);
map.from(properties::getClientName).to(builder::clientName);
return builder.build();
}
Aggregations