org.springframework.beans.factory.ObjectProvider Java Examples

The following examples show how to use org.springframework.beans.factory.ObjectProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: java-technology-stack   Author: codeEngraver   File: DefaultListableBeanFactory.java    License: MIT License 6 votes vote down vote up
@Override
@Nullable
public Object resolveDependency(DependencyDescriptor descriptor, @Nullable String requestingBeanName,
		@Nullable Set<String> autowiredBeanNames, @Nullable TypeConverter typeConverter) throws BeansException {

	descriptor.initParameterNameDiscovery(getParameterNameDiscoverer());
	if (Optional.class == descriptor.getDependencyType()) {
		return createOptionalDependency(descriptor, requestingBeanName);
	}
	else if (ObjectFactory.class == descriptor.getDependencyType() ||
			ObjectProvider.class == descriptor.getDependencyType()) {
		return new DependencyObjectProvider(descriptor, requestingBeanName);
	}
	else if (javaxInjectProviderClass == descriptor.getDependencyType()) {
		return new Jsr330Factory().createDependencyProvider(descriptor, requestingBeanName);
	}
	else {
		Object result = getAutowireCandidateResolver().getLazyResolutionProxyIfNecessary(
				descriptor, requestingBeanName);
		if (result == null) {
			result = doResolveDependency(descriptor, requestingBeanName, autowiredBeanNames, typeConverter);
		}
		return result;
	}
}
 
Example #2
Source Project: beihu-boot   Author: beihu-stack   File: BeihuMongoDataAutoConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean(MongoDbFactory.class)
public MongoDbFactorySupport<?> mongoDbFactory(ObjectProvider<MongoClient> mongo,
		ObjectProvider<com.mongodb.client.MongoClient> mongoClient) {
	MongoClient preferredClient = mongo.getIfAvailable();
	if (preferredClient != null) {
		return new SimpleMongoDbFactory(preferredClient,
				this.beihuMongoProperties.getMongoClientDatabase());
	}
	com.mongodb.client.MongoClient fallbackClient = mongoClient.getIfAvailable();
	if (fallbackClient != null) {
		return new SimpleMongoClientDbFactory(fallbackClient,
				this.beihuMongoProperties.getMongoClientDatabase());
	}
	throw new IllegalStateException("Expected to find at least one MongoDB client.");
}
 
Example #3
Source Project: spring-cloud-commons   Author: spring-cloud   File: CachingServiceInstanceListSupplierTests.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
ServiceInstanceListSupplier supplier(ConfigurableApplicationContext context,
		ReactiveDiscoveryClient discoveryClient,
		LoadBalancerProperties loadBalancerProperties,
		WebClient.Builder webClientBuilder) {
	DiscoveryClientServiceInstanceListSupplier firstDelegate = new DiscoveryClientServiceInstanceListSupplier(
			discoveryClient, context.getEnvironment());
	HealthCheckServiceInstanceListSupplier delegate = new TestHealthCheckServiceInstanceListSupplier(
			firstDelegate, loadBalancerProperties.getHealthCheck(),
			webClientBuilder.build());
	delegate.afterPropertiesSet();
	ObjectProvider<LoadBalancerCacheManager> cacheManagerProvider = context
			.getBeanProvider(LoadBalancerCacheManager.class);
	return new CachingServiceInstanceListSupplier(delegate,
			cacheManagerProvider.getIfAvailable());
}
 
Example #4
@Bean
public KafkaStreamsStreamListenerSetupMethodOrchestrator kafkaStreamsStreamListenerSetupMethodOrchestrator(
		BindingServiceProperties bindingServiceProperties,
		KafkaStreamsExtendedBindingProperties kafkaStreamsExtendedBindingProperties,
		KeyValueSerdeResolver keyValueSerdeResolver,
		KafkaStreamsBindingInformationCatalogue kafkaStreamsBindingInformationCatalogue,
		KStreamStreamListenerParameterAdapter kafkaStreamListenerParameterAdapter,
		Collection<StreamListenerResultAdapter> streamListenerResultAdapters,
		ObjectProvider<CleanupConfig> cleanupConfig,
		ObjectProvider<StreamsBuilderFactoryBeanCustomizer> customizerProvider, ConfigurableEnvironment environment) {
	return new KafkaStreamsStreamListenerSetupMethodOrchestrator(
			bindingServiceProperties, kafkaStreamsExtendedBindingProperties,
			keyValueSerdeResolver, kafkaStreamsBindingInformationCatalogue,
			kafkaStreamListenerParameterAdapter, streamListenerResultAdapters,
			cleanupConfig.getIfUnique(), customizerProvider.getIfUnique(), environment);
}
 
Example #5
Source Project: java-technology-stack   Author: codeEngraver   File: BeanFactoryGenericsTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testGenericMatchingWithUnresolvedOrderedStream() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE);
	bf.setAutowireCandidateResolver(new GenericTypeAwareAutowireCandidateResolver());

	RootBeanDefinition bd1 = new RootBeanDefinition(NumberStoreFactory.class);
	bd1.setFactoryMethodName("newDoubleStore");
	bf.registerBeanDefinition("store1", bd1);
	RootBeanDefinition bd2 = new RootBeanDefinition(NumberStoreFactory.class);
	bd2.setFactoryMethodName("newFloatStore");
	bf.registerBeanDefinition("store2", bd2);

	ObjectProvider<NumberStore<?>> numberStoreProvider = bf.getBeanProvider(ResolvableType.forClass(NumberStore.class));
	List<NumberStore<?>> resolved = numberStoreProvider.orderedStream().collect(Collectors.toList());
	assertEquals(2, resolved.size());
	assertSame(bf.getBean("store2"), resolved.get(0));
	assertSame(bf.getBean("store1"), resolved.get(1));
}
 
Example #6
Source Project: backstopper   Author: Nike-Inc   File: BackstopperSpringWebFluxComponentTest.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
@Primary
public SpringWebfluxUnhandledExceptionHandler springWebfluxUnhandledExceptionHandler(
    ProjectApiErrors projectApiErrors,
    ApiExceptionHandlerUtils generalUtils,
    SpringWebfluxApiExceptionHandlerUtils springUtils,
    ObjectProvider<ViewResolver> viewResolversProvider,
    ServerCodecConfigurer serverCodecConfigurer
) {
    return new SpringWebfluxUnhandledExceptionHandler(
        projectApiErrors, generalUtils, springUtils, viewResolversProvider, serverCodecConfigurer
    ) {
        @Override
        public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
            exceptionSeenByUnhandledBackstopperHandler = ex;
            return super.handle(exchange, ex);
        }
    };
}
 
Example #7
Source Project: initializr   Author: spring-io   File: InitializrAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(InitializrMetadataProvider.class)
public InitializrMetadataProvider initializrMetadataProvider(InitializrProperties properties,
		ObjectProvider<InitializrMetadataUpdateStrategy> initializrMetadataUpdateStrategy) {
	InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(properties).build();
	return new DefaultInitializrMetadataProvider(metadata,
			initializrMetadataUpdateStrategy.getIfAvailable(() -> (current) -> current));
}
 
Example #8
Source Project: influx-proxy   Author: spring-avengers   File: WebExceptionConfig.java    License: Apache License 2.0 5 votes vote down vote up
public WebExceptionConfig(ServerProperties serverProperties,
                                     ResourceProperties resourceProperties,
                                     ObjectProvider<ViewResolver> viewResolversProvider,
                                     ServerCodecConfigurer serverCodecConfigurer,
                                     ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider.orderedStream()
            .collect(Collectors.toList());
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
Example #9
Source Project: spring-cloud-gateway   Author: spring-cloud   File: NettyRoutingFilter.java    License: Apache License 2.0 5 votes vote down vote up
public NettyRoutingFilter(HttpClient httpClient,
		ObjectProvider<List<HttpHeadersFilter>> headersFiltersProvider,
		HttpClientProperties properties) {
	this.httpClient = httpClient;
	this.headersFiltersProvider = headersFiltersProvider;
	this.properties = properties;
}
 
Example #10
Source Project: api-boot   Author: minbox-projects   File: ApiBootMybatisPageableAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public ApiBootMybatisPageableAutoConfiguration(ApiBootMyBatisPageableProperties myBatisPageableProperties,
                                               ObjectProvider<List<SqlSessionFactory>> interceptorsProvider,
                                               ObjectProvider<PageableConfigurer> pageableConfigurerObjectProvider) {
    this.myBatisPageableProperties = myBatisPageableProperties;
    this.sqlSessionFactoryList = interceptorsProvider.getIfAvailable();
    this.pageableConfigurer = pageableConfigurerObjectProvider.getIfAvailable();
}
 
Example #11
Source Project: initializr   Author: spring-io   File: MainSourceCodeProjectContributor.java    License: Apache License 2.0 5 votes vote down vote up
public MainSourceCodeProjectContributor(ProjectDescription description, Supplier<S> sourceFactory,
		SourceCodeWriter<S> sourceWriter, ObjectProvider<MainApplicationTypeCustomizer<?>> mainTypeCustomizers,
		ObjectProvider<MainCompilationUnitCustomizer<?, ?>> mainCompilationUnitCustomizers,
		ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers) {
	this.description = description;
	this.sourceFactory = sourceFactory;
	this.sourceWriter = sourceWriter;
	this.mainTypeCustomizers = mainTypeCustomizers;
	this.mainCompilationUnitCustomizers = mainCompilationUnitCustomizers;
	this.mainSourceCodeCustomizers = mainSourceCodeCustomizers;
}
 
Example #12
Source Project: spring-security-oauth2-boot   Author: spring-projects   File: DefaultUserInfoRestTemplateFactory.java    License: Apache License 2.0 5 votes vote down vote up
public DefaultUserInfoRestTemplateFactory(ObjectProvider<List<UserInfoRestTemplateCustomizer>> customizers,
		ObjectProvider<OAuth2ProtectedResourceDetails> details,
		ObjectProvider<OAuth2ClientContext> oauth2ClientContext) {
	this.customizers = customizers.getIfAvailable();
	this.details = details.getIfAvailable();
	this.oauth2ClientContext = oauth2ClientContext.getIfAvailable();
}
 
Example #13
Source Project: beihu-boot   Author: beihu-stack   File: ApiBootQuartzAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public ApiBootQuartzAutoConfiguration(ApiBootQuartzProperties properties, ObjectProvider<SchedulerFactoryBeanCustomizer> customizers, JobDetail[] jobDetails, Map<String, Calendar> calendars, Trigger[] triggers, ApplicationContext applicationContext) {
    this.properties = properties;
    this.customizers = customizers;
    this.jobDetails = jobDetails;
    this.calendars = calendars;
    this.triggers = triggers;
    this.applicationContext = applicationContext;
}
 
Example #14
Source Project: backstopper   Author: Nike-Inc   File: SpringWebfluxUnhandledExceptionHandlerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void beforeMethod() {
    generalUtils = ApiExceptionHandlerUtils.DEFAULT_IMPL;
    testProjectApiErrors = ProjectApiErrorsForTesting.withProjectSpecificData(null, null);
    springUtilsMock = mock(SpringWebfluxApiExceptionHandlerUtils.class);
    viewResolversProviderMock = mock(ObjectProvider.class);
    serverCodecConfigurerMock = mock(ServerCodecConfigurer.class);
    messageReaders = Arrays.asList(mock(HttpMessageReader.class), mock(HttpMessageReader.class));
    messageWriters = Arrays.asList(mock(HttpMessageWriter.class), mock(HttpMessageWriter.class));
    viewResolvers = Arrays.asList(mock(ViewResolver.class), mock(ViewResolver.class));
    serverWebExchangeMock = mock(ServerWebExchange.class);
    serverHttpRequestMock = mock(ServerHttpRequest.class);
    serverHttpResponseMock = mock(ServerHttpResponse.class);
    serverHttpResponseHeadersMock = mock(HttpHeaders.class);
    uri = URI.create("http://localhost:8080/foo/bar?someQuery=someValue");
    exMock = mock(Throwable.class);

    doAnswer(invocation -> viewResolvers.stream()).when(viewResolversProviderMock).orderedStream();
    doReturn(messageReaders).when(serverCodecConfigurerMock).getReaders();
    doReturn(messageWriters).when(serverCodecConfigurerMock).getWriters();

    doReturn(serverHttpRequestMock).when(serverWebExchangeMock).getRequest();
    doReturn(uri).when(serverHttpRequestMock).getURI();

    doReturn(serverHttpResponseMock).when(serverWebExchangeMock).getResponse();
    doReturn(serverHttpResponseHeadersMock).when(serverHttpResponseMock).getHeaders();

    handlerSpy = spy(new SpringWebfluxUnhandledExceptionHandler(
        testProjectApiErrors, generalUtils, springUtilsMock, viewResolversProviderMock, serverCodecConfigurerMock
    ));
}
 
Example #15
Source Project: spring-cloud-consul   Author: spring-cloud   File: ConsulAutoServiceRegistrationAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ConsulAutoRegistration consulRegistration(
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext applicationContext,
		ObjectProvider<List<ConsulRegistrationCustomizer>> registrationCustomizers,
		ObjectProvider<List<ConsulManagementRegistrationCustomizer>> managementRegistrationCustomizers,
		HeartbeatProperties heartbeatProperties) {
	return ConsulAutoRegistration.registration(autoServiceRegistrationProperties,
			properties, applicationContext, registrationCustomizers.getIfAvailable(),
			managementRegistrationCustomizers.getIfAvailable(), heartbeatProperties);
}
 
Example #16
Source Project: spring-cloud-gateway   Author: spring-cloud   File: ConfigurationService.java    License: Apache License 2.0 5 votes vote down vote up
public ConfigurationService(BeanFactory beanFactory,
		ObjectProvider<ConversionService> conversionService,
		ObjectProvider<Validator> validator) {
	this.beanFactory = beanFactory;
	this.conversionService = conversionService::getIfAvailable;
	this.validator = validator::getIfAvailable;
}
 
Example #17
Source Project: SpringCloud   Author: zhoutaoo   File: ExceptionAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public ExceptionAutoConfiguration(ServerProperties serverProperties,
                                  ResourceProperties resourceProperties,
                                  ObjectProvider<List<ViewResolver>> viewResolversProvider,
                                  ServerCodecConfigurer serverCodecConfigurer,
                                  ApplicationContext applicationContext) {
    this.serverProperties = serverProperties;
    this.applicationContext = applicationContext;
    this.resourceProperties = resourceProperties;
    this.viewResolvers = viewResolversProvider
            .getIfAvailable(() -> Collections.emptyList());
    this.serverCodecConfigurer = serverCodecConfigurer;
}
 
Example #18
Source Project: backstopper   Author: Nike-Inc   File: SpringWebfluxUnhandledExceptionHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public SpringWebfluxUnhandledExceptionHandler(
    @NotNull ProjectApiErrors projectApiErrors,
    @NotNull ApiExceptionHandlerUtils generalUtils,
    @NotNull SpringWebfluxApiExceptionHandlerUtils springUtils,
    @NotNull ObjectProvider<ViewResolver> viewResolversProvider,
    @NotNull ServerCodecConfigurer serverCodecConfigurer
) {
    super(projectApiErrors, generalUtils);

    //noinspection ConstantConditions
    if (springUtils == null) {
        throw new NullPointerException("springUtils cannot be null.");
    }
    
    //noinspection ConstantConditions
    if (viewResolversProvider == null) {
        throw new NullPointerException("viewResolversProvider cannot be null.");
    }

    //noinspection ConstantConditions
    if (serverCodecConfigurer == null) {
        throw new NullPointerException("serverCodecConfigurer cannot be null.");
    }

    this.singletonGenericServiceError = Collections.singleton(projectApiErrors.getGenericServiceError());
    this.genericServiceErrorHttpStatusCode = projectApiErrors.getGenericServiceError().getHttpStatusCode();

    this.springUtils = springUtils;
    this.viewResolvers = viewResolversProvider.orderedStream().collect(Collectors.toList());
    this.messageReaders = serverCodecConfigurer.getReaders();
    this.messageWriters = serverCodecConfigurer.getWriters();
}
 
Example #19
Source Project: spring-boot-starter-micro-job   Author: hengyuboy   File: JobQuartzAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Order(0)
public SchedulerFactoryBeanCustomizer jobDataSourceCustomizer(QuartzProperties properties, DataSource dataSource, @QuartzDataSource ObjectProvider<DataSource> quartzDataSource, ObjectProvider<PlatformTransactionManager> transactionManager) {
    return (schedulerFactoryBean) -> {
        if (properties.getJobStoreType() == JobStoreType.JDBC) {
            DataSource dataSourceToUse = this.getDataSource(dataSource, quartzDataSource);
            schedulerFactoryBean.setDataSource(dataSourceToUse);
            PlatformTransactionManager txManager = (PlatformTransactionManager) transactionManager.getIfUnique();
            if (txManager != null) {
                schedulerFactoryBean.setTransactionManager(txManager);
            }
        }

    };
}
 
Example #20
Source Project: backstopper   Author: Nike-Inc   File: SpringWebfluxApiExceptionHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public SpringWebfluxApiExceptionHandler(
    @NotNull ProjectApiErrors projectApiErrors,
    @NotNull SpringWebFluxApiExceptionHandlerListenerList apiExceptionHandlerListeners,
    @NotNull ApiExceptionHandlerUtils generalUtils,
    @NotNull SpringWebfluxApiExceptionHandlerUtils springUtils,
    @NotNull ObjectProvider<ViewResolver> viewResolversProvider,
    @NotNull ServerCodecConfigurer serverCodecConfigurer
) {
    super(projectApiErrors, apiExceptionHandlerListeners.listeners, generalUtils);

    //noinspection ConstantConditions
    if (springUtils == null) {
        throw new NullPointerException("springUtils cannot be null.");
    }

    //noinspection ConstantConditions
    if (viewResolversProvider == null) {
        throw new NullPointerException("viewResolversProvider cannot be null.");
    }

    //noinspection ConstantConditions
    if (serverCodecConfigurer == null) {
        throw new NullPointerException("serverCodecConfigurer cannot be null.");
    }

    this.springUtils = springUtils;
    this.viewResolvers = viewResolversProvider.orderedStream().collect(Collectors.toList());
    this.messageReaders = serverCodecConfigurer.getReaders();
    this.messageWriters = serverCodecConfigurer.getWriters();
}
 
Example #21
@Bean
@Lazy(false)
@ConditionalOnMissingBean
public CloudFoundryApplicationFactory applicationFactory(InstanceProperties instance,
		ManagementServerProperties management, ServerProperties server, PathMappedEndpoints pathMappedEndpoints,
		WebEndpointProperties webEndpoint, ObjectProvider<List<MetadataContributor>> metadataContributors,
		CloudFoundryApplicationProperties cfApplicationProperties) {
	return new CloudFoundryApplicationFactory(instance, management, server, pathMappedEndpoints, webEndpoint,
			new CompositeMetadataContributor(metadataContributors.getIfAvailable(Collections::emptyList)),
			cfApplicationProperties);
}
 
Example #22
Source Project: soul   Author: Dromara   File: HttpClientPluginConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Web client plugin soul plugin.
 *
 * @param httpClient the http client
 * @return the soul plugin
 */
@Bean
public SoulPlugin webClientPlugin(final ObjectProvider<HttpClient> httpClient) {
    WebClient webClient = WebClient.builder()
            .clientConnector(new ReactorClientHttpConnector(Objects.requireNonNull(httpClient.getIfAvailable())))
            .build();
    return new WebClientPlugin(webClient);
}
 
Example #23
Source Project: redisson-spring-boot   Author: drtrang   File: RedissonSpringAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public RedissonSpringAutoConfiguration(RedissonSpringProperties redissonSpringProperties,
                                       ObjectProvider<List<Customizer<RedissonSpringCacheManager>>> customizersProvider) {
    this.redissonSpringProperties = redissonSpringProperties;
    this.redissonSpringCacheManagerCustomizers = customizersProvider.getIfAvailable();
    this.redissonSpringCacheManagerCustomizers = redissonSpringCacheManagerCustomizers != null
            ? redissonSpringCacheManagerCustomizers : emptyList();
}
 
Example #24
Source Project: Moss   Author: SpringCloud   File: MultRegisterCenterServerMgmtConfig.java    License: Apache License 2.0 5 votes vote down vote up
public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient,
                                             CloudEurekaInstanceConfig instanceConfig,
                                             ApplicationInfoManager applicationInfoManager,
                                             @Autowired(required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) {
    return EurekaRegistration.builder(instanceConfig)
            .with(applicationInfoManager)
            .with(eurekaClient)
            .with(healthCheckHandler)
            .build();
}
 
Example #25
Source Project: spring-microservice-exam   Author: wells2333   File: GatewayExceptionConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 自定义异常处理
 */
@Primary
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ObjectProvider<List<ViewResolver>> viewResolversProvider, ServerCodecConfigurer serverCodecConfigurer) {
    GatewayExceptionHandler gatewayExceptionHandler = new GatewayExceptionHandler();
    gatewayExceptionHandler.setViewResolvers(viewResolversProvider.getIfAvailable(Collections::emptyList));
    gatewayExceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters());
    gatewayExceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders());
    return gatewayExceptionHandler;
}
 
Example #26
Source Project: summerframework   Author: spring-avengers   File: RestTemplateAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public SmartInitializingSingleton metricsAsyncRestTemplateInitializer(
    final ObjectProvider<List<AsyncRestTemplate>> asyncRestTemplatesProvider,
    final RestTemplatePostProcessor customizer) {
    return () -> {
        final List<AsyncRestTemplate> asyncRestTemplates = asyncRestTemplatesProvider.getIfAvailable();
        if (!CollectionUtils.isEmpty(asyncRestTemplates)) {
            asyncRestTemplates.forEach(customizer::customize);
        }
    };
}
 
Example #27
Source Project: embedded-database-spring-test   Author: zonkyio   File: PrefetchingDatabaseProvider.java    License: Apache License 2.0 5 votes vote down vote up
public PrefetchingDatabaseProvider(ObjectProvider<List<DatabaseProvider>> databaseProviders, Environment environment) {
    this.databaseProviders = Optional.ofNullable(databaseProviders.getIfAvailable()).orElse(emptyList()).stream()
            .collect(Collectors.toMap(p -> new DatabaseDescriptor(p.getDatabaseType(), p.getProviderType()), identity()));

    String threadNamePrefix = environment.getProperty("zonky.test.database.prefetching.thread-name-prefix", "prefetching-");
    int concurrency = environment.getProperty("zonky.test.database.prefetching.concurrency", int.class, 3);
    pipelineCacheSize = environment.getProperty("zonky.test.database.prefetching.pipeline-cache-size", int.class, 3);

    taskExecutor.setThreadNamePrefix(threadNamePrefix);
    taskExecutor.setCorePoolSize(concurrency);
}
 
Example #28
Source Project: spring-cloud-function   Author: spring-cloud   File: RequestProcessor.java    License: Apache License 2.0 5 votes vote down vote up
public RequestProcessor(FunctionInspector inspector,
		FunctionCatalog functionCatalog,
		ObjectProvider<JsonMapper> mapper, StringConverter converter,
		ObjectProvider<ServerCodecConfigurer> codecs) {
	this.mapper = mapper.getIfAvailable();
	this.inspector = inspector;
	this.functionCatalog = functionCatalog;
	this.converter = converter;
	ServerCodecConfigurer source = codecs.getIfAvailable();
	this.messageReaders = source == null ? null : source.getReaders();
}
 
Example #29
Source Project: shardingsphere   Author: apache   File: MasterSlaveRuleSpringbootConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Master slave rule configuration for spring boot.
 *
 * @param yamlRuleConfiguration YAML master slave rule configuration
 * @param loadBalanceAlgorithms load balance algorithms
 * @return master slave rule configuration
 */
@Bean
public RuleConfiguration masterSlaveRuleConfiguration(final YamlMasterSlaveRuleConfiguration yamlRuleConfiguration,
                                                      final ObjectProvider<Map<String, MasterSlaveLoadBalanceAlgorithm>> loadBalanceAlgorithms) {
    AlgorithmProvidedMasterSlaveRuleConfiguration ruleConfiguration = swapper.swapToObject(yamlRuleConfiguration);
    Map<String, MasterSlaveLoadBalanceAlgorithm> balanceAlgorithmMap = Optional.ofNullable(loadBalanceAlgorithms.getIfAvailable()).orElse(Collections.emptyMap());
    ruleConfiguration.setLoadBalanceAlgorithms(balanceAlgorithmMap);
    return ruleConfiguration;
}
 
Example #30
Source Project: spring-cloud-aws   Author: spring-cloud   File: ContextStackConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public ContextStackConfiguration(ObjectProvider<RegionProvider> regionProvider,
		ObjectProvider<AWSCredentialsProvider> credentialsProvider,
		ObjectProvider<AmazonEC2> amazonEc2) {
	this.regionProvider = regionProvider.getIfAvailable();
	this.credentialsProvider = credentialsProvider.getIfAvailable();
	this.amazonEc2 = amazonEc2.getIfAvailable();
}