use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class WebSessionIdResolverAutoConfiguration method initializeCookie.
private void initializeCookie(ResponseCookieBuilder builder) {
Cookie cookie = this.serverProperties.getReactive().getSession().getCookie();
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(cookie::getDomain).to(builder::domain);
map.from(cookie::getPath).to(builder::path);
map.from(cookie::getHttpOnly).to(builder::httpOnly);
map.from(cookie::getSecure).to(builder::secure);
map.from(cookie::getMaxAge).to(builder::maxAge);
map.from(getSameSite(cookie)).to(builder::sameSite);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class MultipartProperties method createMultipartConfig.
/**
* Create a new {@link MultipartConfigElement} using the properties.
* @return a new {@link MultipartConfigElement} configured using there properties
*/
public MultipartConfigElement createMultipartConfig() {
MultipartConfigFactory factory = new MultipartConfigFactory();
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(this.fileSizeThreshold).to(factory::setFileSizeThreshold);
map.from(this.location).whenHasText().to(factory::setLocation);
map.from(this.maxRequestSize).to(factory::setMaxRequestSize);
map.from(this.maxFileSize).to(factory::setMaxFileSize);
return factory.createMultipartConfig();
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class RetryTemplateFactory method createRetryTemplate.
RetryTemplate createRetryTemplate(RabbitProperties.Retry properties, RabbitRetryTemplateCustomizer.Target target) {
PropertyMapper map = PropertyMapper.get();
RetryTemplate template = new RetryTemplate();
SimpleRetryPolicy policy = new SimpleRetryPolicy();
map.from(properties::getMaxAttempts).to(policy::setMaxAttempts);
template.setRetryPolicy(policy);
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
map.from(properties::getInitialInterval).whenNonNull().as(Duration::toMillis).to(backOffPolicy::setInitialInterval);
map.from(properties::getMultiplier).to(backOffPolicy::setMultiplier);
map.from(properties::getMaxInterval).whenNonNull().as(Duration::toMillis).to(backOffPolicy::setMaxInterval);
template.setBackOffPolicy(backOffPolicy);
if (this.customizers != null) {
for (RabbitRetryTemplateCustomizer customizer : this.customizers) {
customizer.customize(target, template);
}
}
return template;
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class RabbitStreamConfiguration method configure.
static EnvironmentBuilder configure(EnvironmentBuilder builder, RabbitProperties properties) {
builder.lazyInitialization(true);
RabbitProperties.Stream stream = properties.getStream();
PropertyMapper mapper = PropertyMapper.get();
mapper.from(stream.getHost()).to(builder::host);
mapper.from(stream.getPort()).to(builder::port);
mapper.from(stream.getUsername()).as(withFallback(properties::getUsername)).whenNonNull().to(builder::username);
mapper.from(stream.getPassword()).as(withFallback(properties::getPassword)).whenNonNull().to(builder::password);
return builder;
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class AbstractConnectionFactoryConfigurer method configure.
/**
* Configures the given {@code connectionFactory} with sensible defaults.
* @param connectionFactory connection factory to configure
*/
public final void configure(T connectionFactory) {
Assert.notNull(connectionFactory, "ConnectionFactory must not be null");
PropertyMapper map = PropertyMapper.get();
map.from(this.rabbitProperties::determineAddresses).to(connectionFactory::setAddresses);
map.from(this.rabbitProperties::getAddressShuffleMode).whenNonNull().to(connectionFactory::setAddressShuffleMode);
map.from(this.connectionNameStrategy).whenNonNull().to(connectionFactory::setConnectionNameStrategy);
configure(connectionFactory, this.rabbitProperties);
}
Aggregations