Search in sources :

Example 26 with PropertyMapper

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);
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 27 with PropertyMapper

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);
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 28 with PropertyMapper

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;
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 29 with PropertyMapper

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;
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 30 with PropertyMapper

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;
}
Also used : MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) Document(org.springframework.data.mongodb.core.mapping.Document) EntityScanner(org.springframework.boot.autoconfigure.domain.EntityScanner) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

PropertyMapper (org.springframework.boot.context.properties.PropertyMapper)49 Bean (org.springframework.context.annotation.Bean)9 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)8 ServerProperties (org.springframework.boot.autoconfigure.web.ServerProperties)4 DataSize (org.springframework.util.unit.DataSize)4 Duration (java.time.Duration)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 IOException (java.io.IOException)2 Map (java.util.Map)2 AccessLogValve (org.apache.catalina.valves.AccessLogValve)2 AutoConfiguration (org.springframework.boot.autoconfigure.AutoConfiguration)2 EnableAutoConfiguration (org.springframework.boot.autoconfigure.EnableAutoConfiguration)2 Connection (org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Connection)2 Controlconnection (org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Controlconnection)2 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)2 Listener (org.springframework.boot.autoconfigure.kafka.KafkaProperties.Listener)2 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)2 ConsumerAwareRebalanceListener (org.springframework.kafka.listener.ConsumerAwareRebalanceListener)2 StringUtils (org.springframework.util.StringUtils)2