Search in sources :

Example 36 with PropertyMapper

use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.

the class OAuth2ClientPropertiesRegistrationAdapter method getBuilder.

private static Builder getBuilder(Builder builder, Provider provider) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    map.from(provider::getAuthorizationUri).to(builder::authorizationUri);
    map.from(provider::getTokenUri).to(builder::tokenUri);
    map.from(provider::getUserInfoUri).to(builder::userInfoUri);
    map.from(provider::getUserInfoAuthenticationMethod).as(AuthenticationMethod::new).to(builder::userInfoAuthenticationMethod);
    map.from(provider::getJwkSetUri).to(builder::jwkSetUri);
    map.from(provider::getUserNameAttribute).to(builder::userNameAttributeName);
    return builder;
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 37 with PropertyMapper

use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.

the class KafkaAutoConfiguration method kafkaTemplate.

@Bean
@ConditionalOnMissingBean(KafkaTemplate.class)
public KafkaTemplate<?, ?> kafkaTemplate(ProducerFactory<Object, Object> kafkaProducerFactory, ProducerListener<Object, Object> kafkaProducerListener, ObjectProvider<RecordMessageConverter> messageConverter) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    KafkaTemplate<Object, Object> kafkaTemplate = new KafkaTemplate<>(kafkaProducerFactory);
    messageConverter.ifUnique(kafkaTemplate::setMessageConverter);
    map.from(kafkaProducerListener).to(kafkaTemplate::setProducerListener);
    map.from(this.properties.getTemplate().getDefaultTopic()).to(kafkaTemplate::setDefaultTopic);
    map.from(this.properties.getTemplate().getTransactionIdPrefix()).to(kafkaTemplate::setTransactionIdPrefix);
    return kafkaTemplate;
}
Also used : KafkaTemplate(org.springframework.kafka.core.KafkaTemplate) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 38 with PropertyMapper

use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.

the class RestDocsRestAssuredBuilderCustomizer method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    PropertyMapper map = PropertyMapper.get();
    String host = this.properties.getUriHost();
    map.from(this.properties::getUriScheme).when((scheme) -> StringUtils.hasText(scheme) && StringUtils.hasText(host)).to((scheme) -> this.delegate.baseUri(scheme + "://" + host));
    map.from(this.properties::getUriPort).whenNonNull().to(this.delegate::port);
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) RequestSpecification(io.restassured.specification.RequestSpecification) InitializingBean(org.springframework.beans.factory.InitializingBean) StringUtils(org.springframework.util.StringUtils) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 39 with PropertyMapper

use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.

the class BasicBatchConfigurer method createJobExplorer.

protected JobExplorer createJobExplorer() throws Exception {
    PropertyMapper map = PropertyMapper.get();
    JobExplorerFactoryBean factory = new JobExplorerFactoryBean();
    factory.setDataSource(this.dataSource);
    map.from(this.properties.getJdbc()::getTablePrefix).whenHasText().to(factory::setTablePrefix);
    factory.afterPropertiesSet();
    return factory.getObject();
}
Also used : JobExplorerFactoryBean(org.springframework.batch.core.explore.support.JobExplorerFactoryBean) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 40 with PropertyMapper

use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.

the class CassandraAutoConfiguration method mapRequestOptions.

private void mapRequestOptions(CassandraProperties properties, CassandraDriverOptions options) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    Request requestProperties = properties.getRequest();
    map.from(requestProperties::getTimeout).asInt(Duration::toMillis).to(((timeout) -> options.add(DefaultDriverOption.REQUEST_TIMEOUT, timeout)));
    map.from(requestProperties::getConsistency).to(((consistency) -> options.add(DefaultDriverOption.REQUEST_CONSISTENCY, consistency)));
    map.from(requestProperties::getSerialConsistency).to((serialConsistency) -> options.add(DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY, serialConsistency));
    map.from(requestProperties::getPageSize).to((pageSize) -> options.add(DefaultDriverOption.REQUEST_PAGE_SIZE, pageSize));
    Throttler throttlerProperties = requestProperties.getThrottler();
    map.from(throttlerProperties::getType).as(ThrottlerType::type).to((type) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_CLASS, type));
    map.from(throttlerProperties::getMaxQueueSize).to((maxQueueSize) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE, maxQueueSize));
    map.from(throttlerProperties::getMaxConcurrentRequests).to((maxConcurrentRequests) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_CONCURRENT_REQUESTS, maxConcurrentRequests));
    map.from(throttlerProperties::getMaxRequestsPerSecond).to((maxRequestsPerSecond) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_REQUESTS_PER_SECOND, maxRequestsPerSecond));
    map.from(throttlerProperties::getDrainInterval).asInt(Duration::toMillis).to((drainInterval) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_DRAIN_INTERVAL, drainInterval));
}
Also used : SSLContext(javax.net.ssl.SSLContext) Throttler(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Throttler) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) Request(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Request) Supplier(java.util.function.Supplier) Scope(org.springframework.context.annotation.Scope) LinkedHashMap(java.util.LinkedHashMap) ProgrammaticDriverConfigLoaderBuilder(com.datastax.oss.driver.api.core.config.ProgrammaticDriverConfigLoaderBuilder) ObjectProvider(org.springframework.beans.factory.ObjectProvider) DefaultDriverOption(com.datastax.oss.driver.api.core.config.DefaultDriverOption) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Duration(java.time.Duration) Map(java.util.Map) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) ConfigFactory(com.typesafe.config.ConfigFactory) AutoConfiguration(org.springframework.boot.autoconfigure.AutoConfiguration) Resource(org.springframework.core.io.Resource) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) EnableAutoConfiguration(org.springframework.boot.autoconfigure.EnableAutoConfiguration) Config(com.typesafe.config.Config) Connection(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Connection) CqlSessionBuilder(com.datastax.oss.driver.api.core.CqlSessionBuilder) IOException(java.io.IOException) Controlconnection(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Controlconnection) ThrottlerType(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.ThrottlerType) Collectors(java.util.stream.Collectors) DriverOption(com.datastax.oss.driver.api.core.config.DriverOption) DefaultDriverConfigLoader(com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader) DefaultProgrammaticDriverConfigLoaderBuilder(com.datastax.oss.driver.internal.core.config.typesafe.DefaultProgrammaticDriverConfigLoaderBuilder) List(java.util.List) DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Lazy(org.springframework.context.annotation.Lazy) Bean(org.springframework.context.annotation.Bean) Request(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Request) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) Throttler(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Throttler)

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