use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class CassandraAutoConfiguration method mapControlConnectionOptions.
private void mapControlConnectionOptions(CassandraProperties properties, CassandraDriverOptions options) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
Controlconnection controlProperties = properties.getControlconnection();
map.from(controlProperties::getTimeout).asInt(Duration::toMillis).to((timeout) -> options.add(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT, timeout));
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class RabbitConnectionFactoryBeanConfigurer method configure.
/**
* Configure the specified rabbit connection factory bean. The factory bean can be
* further tuned and default settings can be overridden. It is the responsibility of
* the caller to invoke {@link RabbitConnectionFactoryBean#afterPropertiesSet()}
* though.
* @param factory the {@link RabbitConnectionFactoryBean} instance to configure
*/
public void configure(RabbitConnectionFactoryBean factory) {
Assert.notNull(factory, "RabbitConnectionFactoryBean must not be null");
factory.setResourceLoader(this.resourceLoader);
PropertyMapper map = PropertyMapper.get();
map.from(this.rabbitProperties::determineHost).whenNonNull().to(factory::setHost);
map.from(this.rabbitProperties::determinePort).to(factory::setPort);
map.from(this.rabbitProperties::determineUsername).whenNonNull().to(factory::setUsername);
map.from(this.rabbitProperties::determinePassword).whenNonNull().to(factory::setPassword);
map.from(this.rabbitProperties::determineVirtualHost).whenNonNull().to(factory::setVirtualHost);
map.from(this.rabbitProperties::getRequestedHeartbeat).whenNonNull().asInt(Duration::getSeconds).to(factory::setRequestedHeartbeat);
map.from(this.rabbitProperties::getRequestedChannelMax).to(factory::setRequestedChannelMax);
RabbitProperties.Ssl ssl = this.rabbitProperties.getSsl();
if (ssl.determineEnabled()) {
factory.setUseSSL(true);
map.from(ssl::getAlgorithm).whenNonNull().to(factory::setSslAlgorithm);
map.from(ssl::getKeyStoreType).to(factory::setKeyStoreType);
map.from(ssl::getKeyStore).to(factory::setKeyStore);
map.from(ssl::getKeyStorePassword).to(factory::setKeyStorePassphrase);
map.from(ssl::getKeyStoreAlgorithm).whenNonNull().to(factory::setKeyStoreAlgorithm);
map.from(ssl::getTrustStoreType).to(factory::setTrustStoreType);
map.from(ssl::getTrustStore).to(factory::setTrustStore);
map.from(ssl::getTrustStorePassword).to(factory::setTrustStorePassphrase);
map.from(ssl::getTrustStoreAlgorithm).whenNonNull().to(factory::setTrustStoreAlgorithm);
map.from(ssl::isValidateServerCertificate).to((validate) -> factory.setSkipServerCertificateValidation(!validate));
map.from(ssl::getVerifyHostname).to(factory::setEnableHostnameVerification);
}
map.from(this.rabbitProperties::getConnectionTimeout).whenNonNull().asInt(Duration::toMillis).to(factory::setConnectionTimeout);
map.from(this.rabbitProperties::getChannelRpcTimeout).whenNonNull().asInt(Duration::toMillis).to(factory::setChannelRpcTimeout);
map.from(this.credentialsProvider).whenNonNull().to(factory::setCredentialsProvider);
map.from(this.credentialsRefreshService).whenNonNull().to(factory::setCredentialsRefreshService);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class RabbitTemplateConfigurer method configure.
/**
* Configure the specified {@link RabbitTemplate}. The template can be further tuned
* and default settings can be overridden.
* @param template the {@link RabbitTemplate} instance to configure
* @param connectionFactory the {@link ConnectionFactory} to use
*/
public void configure(RabbitTemplate template, ConnectionFactory connectionFactory) {
PropertyMapper map = PropertyMapper.get();
template.setConnectionFactory(connectionFactory);
if (this.messageConverter != null) {
template.setMessageConverter(this.messageConverter);
}
template.setMandatory(determineMandatoryFlag());
RabbitProperties.Template templateProperties = this.rabbitProperties.getTemplate();
if (templateProperties.getRetry().isEnabled()) {
template.setRetryTemplate(new RetryTemplateFactory(this.retryTemplateCustomizers).createRetryTemplate(templateProperties.getRetry(), RabbitRetryTemplateCustomizer.Target.SENDER));
}
map.from(templateProperties::getReceiveTimeout).whenNonNull().as(Duration::toMillis).to(template::setReceiveTimeout);
map.from(templateProperties::getReplyTimeout).whenNonNull().as(Duration::toMillis).to(template::setReplyTimeout);
map.from(templateProperties::getExchange).to(template::setExchange);
map.from(templateProperties::getRoutingKey).to(template::setRoutingKey);
map.from(templateProperties::getDefaultReceiveQueue).whenNonNull().to(template::setDefaultReceiveQueue);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class SimpleRabbitListenerContainerFactoryConfigurer method configure.
@Override
public void configure(SimpleRabbitListenerContainerFactory factory, ConnectionFactory connectionFactory) {
PropertyMapper map = PropertyMapper.get();
RabbitProperties.SimpleContainer config = getRabbitProperties().getListener().getSimple();
configure(factory, connectionFactory, config);
map.from(config::getConcurrency).whenNonNull().to(factory::setConcurrentConsumers);
map.from(config::getMaxConcurrency).whenNonNull().to(factory::setMaxConcurrentConsumers);
map.from(config::getBatchSize).whenNonNull().to(factory::setBatchSize);
map.from(config::isConsumerBatchEnabled).to(factory::setConsumerBatchEnabled);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class IntegrationAutoConfiguration method integrationGlobalProperties.
@Bean(name = IntegrationContextUtils.INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME)
@ConditionalOnMissingBean(name = IntegrationContextUtils.INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME)
public static org.springframework.integration.context.IntegrationProperties integrationGlobalProperties(IntegrationProperties properties) {
org.springframework.integration.context.IntegrationProperties integrationProperties = new org.springframework.integration.context.IntegrationProperties();
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(properties.getChannel().isAutoCreate()).to(integrationProperties::setChannelsAutoCreate);
map.from(properties.getChannel().getMaxUnicastSubscribers()).to(integrationProperties::setChannelsMaxUnicastSubscribers);
map.from(properties.getChannel().getMaxBroadcastSubscribers()).to(integrationProperties::setChannelsMaxBroadcastSubscribers);
map.from(properties.getError().isRequireSubscribers()).to(integrationProperties::setErrorChannelRequireSubscribers);
map.from(properties.getError().isIgnoreFailures()).to(integrationProperties::setErrorChannelIgnoreFailures);
map.from(properties.getEndpoint().isThrowExceptionOnLateReply()).to(integrationProperties::setMessagingTemplateThrowExceptionOnLateReply);
map.from(properties.getEndpoint().getReadOnlyHeaders()).as(StringUtils::toStringArray).to(integrationProperties::setReadOnlyHeaders);
map.from(properties.getEndpoint().getNoAutoStartup()).as(StringUtils::toStringArray).to(integrationProperties::setNoAutoStartupEndpoints);
return integrationProperties;
}
Aggregations