Search in sources :

Example 46 with PropertyMapper

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

the class RepositoryRestProperties method applyTo.

public void applyTo(RepositoryRestConfiguration rest) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    map.from(this::getBasePath).to(rest::setBasePath);
    map.from(this::getDefaultPageSize).to(rest::setDefaultPageSize);
    map.from(this::getMaxPageSize).to(rest::setMaxPageSize);
    map.from(this::getPageParamName).to(rest::setPageParamName);
    map.from(this::getLimitParamName).to(rest::setLimitParamName);
    map.from(this::getSortParamName).to(rest::setSortParamName);
    map.from(this::getDetectionStrategy).to(rest::setRepositoryDetectionStrategy);
    map.from(this::getDefaultMediaType).to(rest::setDefaultMediaType);
    map.from(this::getReturnBodyOnCreate).to(rest::setReturnBodyOnCreate);
    map.from(this::getReturnBodyOnUpdate).to(rest::setReturnBodyOnUpdate);
    map.from(this::getEnableEnumTranslation).to(rest::setEnableEnumTranslation);
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 47 with PropertyMapper

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

the class TaskExecutorBuilder method configure.

/**
 * Configure the provided {@link ThreadPoolTaskExecutor} instance using this builder.
 * @param <T> the type of task executor
 * @param taskExecutor the {@link ThreadPoolTaskExecutor} to configure
 * @return the task executor instance
 * @see #build()
 * @see #build(Class)
 */
public <T extends ThreadPoolTaskExecutor> T configure(T taskExecutor) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    map.from(this.queueCapacity).to(taskExecutor::setQueueCapacity);
    map.from(this.corePoolSize).to(taskExecutor::setCorePoolSize);
    map.from(this.maxPoolSize).to(taskExecutor::setMaxPoolSize);
    map.from(this.keepAlive).asInt(Duration::getSeconds).to(taskExecutor::setKeepAliveSeconds);
    map.from(this.allowCoreThreadTimeOut).to(taskExecutor::setAllowCoreThreadTimeOut);
    map.from(this.awaitTermination).to(taskExecutor::setWaitForTasksToCompleteOnShutdown);
    map.from(this.awaitTerminationPeriod).as(Duration::toMillis).to(taskExecutor::setAwaitTerminationMillis);
    map.from(this.threadNamePrefix).whenHasText().to(taskExecutor::setThreadNamePrefix);
    map.from(this.taskDecorator).to(taskExecutor::setTaskDecorator);
    if (!CollectionUtils.isEmpty(this.customizers)) {
        this.customizers.forEach((customizer) -> customizer.customize(taskExecutor));
    }
    return taskExecutor;
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 48 with PropertyMapper

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

the class NettyRSocketServerFactory method configureServer.

private void configureServer(io.rsocket.core.RSocketServer server) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    map.from(this.fragmentSize).asInt(DataSize::toBytes).to(server::fragment);
    this.rSocketServerCustomizers.forEach((customizer) -> customizer.customize(server));
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 49 with PropertyMapper

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

the class WavefrontMetricsExportAutoConfiguration method createWavefrontSender.

private WavefrontSender createWavefrontSender(WavefrontConfig wavefrontConfig) {
    Builder builder = WavefrontMeterRegistry.getDefaultSenderBuilder(wavefrontConfig);
    PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
    Sender sender = this.properties.getSender();
    mapper.from(sender.getMaxQueueSize()).to(builder::maxQueueSize);
    mapper.from(sender.getFlushInterval()).asInt(Duration::getSeconds).to(builder::flushIntervalSeconds);
    mapper.from(sender.getMessageSize()).asInt(DataSize::toBytes).to(builder::messageSizeBytes);
    return builder.build();
}
Also used : WavefrontSender(com.wavefront.sdk.common.WavefrontSender) Sender(org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront.WavefrontProperties.Sender) Builder(com.wavefront.sdk.common.clients.WavefrontClient.Builder) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

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