use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class CachingConnectionFactoryConfigurer method configure.
@Override
public void configure(CachingConnectionFactory connectionFactory, RabbitProperties rabbitProperties) {
PropertyMapper map = PropertyMapper.get();
map.from(rabbitProperties::isPublisherReturns).to(connectionFactory::setPublisherReturns);
map.from(rabbitProperties::getPublisherConfirmType).whenNonNull().to(connectionFactory::setPublisherConfirmType);
RabbitProperties.Cache.Channel channel = rabbitProperties.getCache().getChannel();
map.from(channel::getSize).whenNonNull().to(connectionFactory::setChannelCacheSize);
map.from(channel::getCheckoutTimeout).whenNonNull().as(Duration::toMillis).to(connectionFactory::setChannelCheckoutTimeout);
RabbitProperties.Cache.Connection connection = rabbitProperties.getCache().getConnection();
map.from(connection::getMode).whenNonNull().to(connectionFactory::setCacheMode);
map.from(connection::getSize).whenNonNull().to(connectionFactory::setConnectionCacheSize);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class DirectRabbitListenerContainerFactoryConfigurer method configure.
@Override
public void configure(DirectRabbitListenerContainerFactory factory, ConnectionFactory connectionFactory) {
PropertyMapper map = PropertyMapper.get();
RabbitProperties.DirectContainer config = getRabbitProperties().getListener().getDirect();
configure(factory, connectionFactory, config);
map.from(config::getConsumersPerQueue).whenNonNull().to(factory::setConsumersPerQueue);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class TaskSchedulerBuilder method configure.
/**
* Configure the provided {@link ThreadPoolTaskScheduler} instance using this builder.
* @param <T> the type of task scheduler
* @param taskScheduler the {@link ThreadPoolTaskScheduler} to configure
* @return the task scheduler instance
* @see #build()
*/
public <T extends ThreadPoolTaskScheduler> T configure(T taskScheduler) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(this.poolSize).to(taskScheduler::setPoolSize);
map.from(this.awaitTermination).to(taskScheduler::setWaitForTasksToCompleteOnShutdown);
map.from(this.awaitTerminationPeriod).asInt(Duration::getSeconds).to(taskScheduler::setAwaitTerminationSeconds);
map.from(this.threadNamePrefix).to(taskScheduler::setThreadNamePrefix);
if (!CollectionUtils.isEmpty(this.customizers)) {
this.customizers.forEach((customizer) -> customizer.customize(taskScheduler));
}
return taskScheduler;
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class JedisConnectionConfiguration method applyProperties.
private JedisClientConfigurationBuilder applyProperties(JedisClientConfigurationBuilder builder) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(getProperties().isSsl()).whenTrue().toCall(builder::useSsl);
map.from(getProperties().getTimeout()).to(builder::readTimeout);
map.from(getProperties().getConnectTimeout()).to(builder::connectTimeout);
map.from(getProperties().getClientName()).whenHasText().to(builder::clientName);
return builder;
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class MongoDataConfiguration method mongoMappingContext.
@Bean
@ConditionalOnMissingBean
MongoMappingContext mongoMappingContext(ApplicationContext applicationContext, MongoProperties properties, MongoCustomConversions conversions) throws ClassNotFoundException {
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
MongoMappingContext context = new MongoMappingContext();
mapper.from(properties.isAutoIndexCreation()).to(context::setAutoIndexCreation);
context.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class));
Class<?> strategyClass = properties.getFieldNamingStrategy();
if (strategyClass != null) {
context.setFieldNamingStrategy((FieldNamingStrategy) BeanUtils.instantiateClass(strategyClass));
}
context.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
return context;
}
Aggregations