Search in sources :

Example 6 with PropertyMapper

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

the class CassandraAutoConfiguration method mapPoolingOptions.

private void mapPoolingOptions(CassandraProperties properties, CassandraDriverOptions options) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    CassandraProperties.Pool poolProperties = properties.getPool();
    map.from(poolProperties::getIdleTimeout).asInt(Duration::toMillis).to((idleTimeout) -> options.add(DefaultDriverOption.HEARTBEAT_TIMEOUT, idleTimeout));
    map.from(poolProperties::getHeartbeatInterval).asInt(Duration::toMillis).to((heartBeatInterval) -> options.add(DefaultDriverOption.HEARTBEAT_INTERVAL, heartBeatInterval));
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 7 with PropertyMapper

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

the class CassandraAutoConfiguration method mapConnectionOptions.

private void mapConnectionOptions(CassandraProperties properties, CassandraDriverOptions options) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    Connection connectionProperties = properties.getConnection();
    map.from(connectionProperties::getConnectTimeout).asInt(Duration::toMillis).to((connectTimeout) -> options.add(DefaultDriverOption.CONNECTION_CONNECT_TIMEOUT, connectTimeout));
    map.from(connectionProperties::getInitQueryTimeout).asInt(Duration::toMillis).to((initQueryTimeout) -> options.add(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT, initQueryTimeout));
}
Also used : Connection(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Connection) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 8 with PropertyMapper

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

the class BasicBatchConfigurer method createJobRepository.

protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    PropertyMapper map = PropertyMapper.get();
    map.from(this.dataSource).to(factory::setDataSource);
    map.from(this::determineIsolationLevel).whenNonNull().to(factory::setIsolationLevelForCreate);
    map.from(this.properties.getJdbc()::getTablePrefix).whenHasText().to(factory::setTablePrefix);
    map.from(this::getTransactionManager).to(factory::setTransactionManager);
    factory.afterPropertiesSet();
    return factory.getObject();
}
Also used : JobRepositoryFactoryBean(org.springframework.batch.core.repository.support.JobRepositoryFactoryBean) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 9 with PropertyMapper

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

the class LdapAutoConfiguration method ldapContextSource.

@Bean
@ConditionalOnMissingBean
public LdapContextSource ldapContextSource(LdapProperties properties, Environment environment, ObjectProvider<DirContextAuthenticationStrategy> dirContextAuthenticationStrategy) {
    LdapContextSource source = new LdapContextSource();
    dirContextAuthenticationStrategy.ifUnique(source::setAuthenticationStrategy);
    PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
    propertyMapper.from(properties.getUsername()).to(source::setUserDn);
    propertyMapper.from(properties.getPassword()).to(source::setPassword);
    propertyMapper.from(properties.getAnonymousReadOnly()).to(source::setAnonymousReadOnly);
    propertyMapper.from(properties.getBase()).to(source::setBase);
    propertyMapper.from(properties.determineUrls(environment)).to(source::setUrls);
    propertyMapper.from(properties.getBaseEnvironment()).to((baseEnvironment) -> source.setBaseEnvironmentProperties(Collections.unmodifiableMap(baseEnvironment)));
    return source;
}
Also used : LdapContextSource(org.springframework.ldap.core.support.LdapContextSource) 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 10 with PropertyMapper

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

the class LdapAutoConfiguration method ldapTemplate.

@Bean
@ConditionalOnMissingBean(LdapOperations.class)
public LdapTemplate ldapTemplate(LdapProperties properties, ContextSource contextSource) {
    Template template = properties.getTemplate();
    PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
    LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
    propertyMapper.from(template.isIgnorePartialResultException()).to(ldapTemplate::setIgnorePartialResultException);
    propertyMapper.from(template.isIgnoreNameNotFoundException()).to(ldapTemplate::setIgnoreNameNotFoundException);
    propertyMapper.from(template.isIgnoreSizeLimitExceededException()).to(ldapTemplate::setIgnoreSizeLimitExceededException);
    return ldapTemplate;
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) LdapTemplate(org.springframework.ldap.core.LdapTemplate) LdapTemplate(org.springframework.ldap.core.LdapTemplate) Template(org.springframework.boot.autoconfigure.ldap.LdapProperties.Template) 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