org.springframework.boot.autoconfigure.condition.SearchStrategy Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.condition.SearchStrategy. 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 File: EurekaClientAutoConfigurationTests.java    From spring-cloud-netflix with Apache License 2.0 6 votes vote down vote up
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean(value = EurekaClient.class,
		search = SearchStrategy.CURRENT)
public EurekaClient eurekaClient(ApplicationInfoManager manager,
		EurekaClientConfig config, ApplicationContext context) {
	return new CloudEurekaClient(manager, config, null, context) {
		@Override
		public synchronized void shutdown() {
			CountDownLatch latch = countDownLatch();
			if (latch.getCount() == 1) {
				latch.countDown();
			}
			super.shutdown();
		}
	};
}
 
Example #2
Source File: SoulExtConfiguration.java    From soul with Apache License 2.0 5 votes vote down vote up
/**
 * Remote address resolver remote address resolver.
 *
 * @return the remote address resolver
 */
@Bean
@ConditionalOnMissingBean(value = RemoteAddressResolver.class, search = SearchStrategy.ALL)
public RemoteAddressResolver remoteAddressResolver() {
    return new RemoteAddressResolver() {
    };
}
 
Example #3
Source File: DiscoveryClientOptionalArgsConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnClass(name = "com.sun.jersey.api.client.filter.ClientFilter")
@ConditionalOnMissingBean(value = AbstractDiscoveryClientOptionalArgs.class,
		search = SearchStrategy.CURRENT)
public MutableDiscoveryClientOptionalArgs discoveryClientOptionalArgs() {
	logger.info("Eureka Client uses Jersey");
	return new MutableDiscoveryClientOptionalArgs();
}
 
Example #4
Source File: DiscoveryClientOptionalArgsConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingClass("com.sun.jersey.api.client.filter.ClientFilter")
@ConditionalOnClass(
		name = "org.springframework.web.reactive.function.client.WebClient")
@ConditionalOnMissingBean(
		value = { AbstractDiscoveryClientOptionalArgs.class,
				RestTemplateDiscoveryClientOptionalArgs.class },
		search = SearchStrategy.CURRENT)
@ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled",
		havingValue = "true")
public WebClientDiscoveryClientOptionalArgs webClientDiscoveryClientOptionalArgs() {
	logger.info("Eureka HTTP Client uses WebClient.");
	return new WebClientDiscoveryClientOptionalArgs();
}
 
Example #5
Source File: DiscoveryClientOptionalArgsConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnClass(name = "org.springframework.web.client.RestTemplate")
@ConditionalOnMissingClass("com.sun.jersey.api.client.filter.ClientFilter")
@ConditionalOnMissingBean(value = { AbstractDiscoveryClientOptionalArgs.class },
		search = SearchStrategy.CURRENT)
@ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled",
		matchIfMissing = true, havingValue = "false")
public RestTemplateDiscoveryClientOptionalArgs restTemplateDiscoveryClientOptionalArgs() {
	logger.info("Eureka HTTP Client uses RestTemplate.");
	return new RestTemplateDiscoveryClientOptionalArgs();
}
 
Example #6
Source File: BrpcServiceRegistrationAutoConfiguration.java    From brpc-java with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = EurekaInstanceConfig.class, search = SearchStrategy.CURRENT)
public EurekaInstanceConfigBean eurekaInstanceConfigBean(
        InetUtils inetUtils, ManagementMetadataProvider managementMetadataProvider) {
    EurekaInstanceConfigBean instance = new EurekaClientAutoConfiguration(env)
            .eurekaInstanceConfigBean(inetUtils, managementMetadataProvider);

    String brpcPort = env.getProperty(ENV_PORT_KEY);
    if (StringUtils.isNoneBlank(brpcPort)) {
        instance.getMetadataMap().put(META_DATA_PORT_KEY, brpcPort);
    }
    return instance;
}
 
Example #7
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = ApplicationInfoManager.class,
		search = SearchStrategy.CURRENT)
public ApplicationInfoManager eurekaApplicationInfoManager(
		EurekaInstanceConfig config) {
	InstanceInfo instanceInfo = new InstanceInfoFactory().create(config);
	return new ApplicationInfoManager(config, instanceInfo);
}
 
Example #8
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean(value = EurekaClient.class,
		search = SearchStrategy.CURRENT)
public EurekaClient eurekaClient(ApplicationInfoManager manager,
		EurekaClientConfig config) {
	return new CloudEurekaClient(manager, config, this.optionalArgs,
			this.context);
}
 
Example #9
Source File: ConfigurationPropertiesRebinderAutoConfiguration.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public ConfigurationPropertiesRebinder configurationPropertiesRebinder(
		ConfigurationPropertiesBeans beans) {
	ConfigurationPropertiesRebinder rebinder = new ConfigurationPropertiesRebinder(
			beans);
	return rebinder;
}
 
Example #10
Source File: BindingServiceConfiguration.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
@Bean
// This conditional is intentionally not in an autoconfig (usually a bad idea) because
// it is used to detect a BindingService in the parent context (which we know
// already exists).
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public BindingService bindingService(
		BindingServiceProperties bindingServiceProperties,
		BinderFactory binderFactory, TaskScheduler taskScheduler) {

	return new BindingService(bindingServiceProperties, binderFactory, taskScheduler);
}
 
Example #11
Source File: AppEngineMemcachedCacheAutoConfiguration.java    From memcached-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = MemcachedCacheManager.class, search = SearchStrategy.CURRENT)
public MemcachedCacheManager cacheManager(MemcachedCacheProperties properties) throws IOException {
    return new AppEngineMemcachedCacheManagerFactory(properties).create();
}
 
Example #12
Source File: EnvironmentRepositoryConfiguration.java    From spring-cloud-config with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public MultipleJGitEnvironmentProperties multipleJGitEnvironmentProperties() {
	return new MultipleJGitEnvironmentProperties();
}
 
Example #13
Source File: EurekaConfigServerBootstrapConfiguration.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = EurekaClientConfig.class,
		search = SearchStrategy.CURRENT)
public EurekaClientConfigBean eurekaClientConfigBean() {
	return new EurekaClientConfigBean();
}
 
Example #14
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = EurekaInstanceConfig.class,
		search = SearchStrategy.CURRENT)
public EurekaInstanceConfigBean eurekaInstanceConfigBean(InetUtils inetUtils,
		ManagementMetadataProvider managementMetadataProvider) {
	String hostname = getProperty("eureka.instance.hostname");
	boolean preferIpAddress = Boolean
			.parseBoolean(getProperty("eureka.instance.prefer-ip-address"));
	String ipAddress = getProperty("eureka.instance.ip-address");
	boolean isSecurePortEnabled = Boolean
			.parseBoolean(getProperty("eureka.instance.secure-port-enabled"));

	String serverContextPath = env.getProperty("server.servlet.context-path", "/");
	int serverPort = Integer.parseInt(
			env.getProperty("server.port", env.getProperty("port", "8080")));

	Integer managementPort = env.getProperty("management.server.port", Integer.class);
	String managementContextPath = env
			.getProperty("management.server.servlet.context-path");
	Integer jmxPort = env.getProperty("com.sun.management.jmxremote.port",
			Integer.class);
	EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean(inetUtils);

	instance.setNonSecurePort(serverPort);
	instance.setInstanceId(getDefaultInstanceId(env));
	instance.setPreferIpAddress(preferIpAddress);
	instance.setSecurePortEnabled(isSecurePortEnabled);
	if (StringUtils.hasText(ipAddress)) {
		instance.setIpAddress(ipAddress);
	}

	if (isSecurePortEnabled) {
		instance.setSecurePort(serverPort);
	}

	if (StringUtils.hasText(hostname)) {
		instance.setHostname(hostname);
	}
	String statusPageUrlPath = getProperty("eureka.instance.status-page-url-path");
	String healthCheckUrlPath = getProperty("eureka.instance.health-check-url-path");

	if (StringUtils.hasText(statusPageUrlPath)) {
		instance.setStatusPageUrlPath(statusPageUrlPath);
	}
	if (StringUtils.hasText(healthCheckUrlPath)) {
		instance.setHealthCheckUrlPath(healthCheckUrlPath);
	}

	ManagementMetadata metadata = managementMetadataProvider.get(instance, serverPort,
			serverContextPath, managementContextPath, managementPort);

	if (metadata != null) {
		instance.setStatusPageUrl(metadata.getStatusPageUrl());
		instance.setHealthCheckUrl(metadata.getHealthCheckUrl());
		if (instance.isSecurePortEnabled()) {
			instance.setSecureHealthCheckUrl(metadata.getSecureHealthCheckUrl());
		}
		Map<String, String> metadataMap = instance.getMetadataMap();
		metadataMap.computeIfAbsent("management.port",
				k -> String.valueOf(metadata.getManagementPort()));
	}
	else {
		// without the metadata the status and health check URLs will not be set
		// and the status page and health check url paths will not include the
		// context path so set them here
		if (StringUtils.hasText(managementContextPath)) {
			instance.setHealthCheckUrlPath(
					managementContextPath + instance.getHealthCheckUrlPath());
			instance.setStatusPageUrlPath(
					managementContextPath + instance.getStatusPageUrlPath());
		}
	}

	setupJmxPort(instance, jmxPort);
	return instance;
}
 
Example #15
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = EurekaClientConfig.class,
		search = SearchStrategy.CURRENT)
public EurekaClientConfigBean eurekaClientConfigBean(ConfigurableEnvironment env) {
	return new EurekaClientConfigBean();
}
 
Example #16
Source File: ConfigurationPropertiesRebinderAutoConfiguration.java    From spring-cloud-commons with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public static ConfigurationPropertiesBeans configurationPropertiesBeans() {
	return new ConfigurationPropertiesBeans();
}
 
Example #17
Source File: BindingServiceConfiguration.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@Bean(name = STREAM_LISTENER_ANNOTATION_BEAN_POST_PROCESSOR_NAME)
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public static StreamListenerAnnotationBeanPostProcessor streamListenerAnnotationBeanPostProcessor() {
	return new StreamListenerAnnotationBeanPostProcessor();
}
 
Example #18
Source File: SignPluginConfiguration.java    From soul with Apache License 2.0 4 votes vote down vote up
/**
 * Sign service sign service.
 *
 * @return the sign service
 */
@Bean
@ConditionalOnMissingBean(value = SignService.class, search = SearchStrategy.ALL)
public SignService signService() {
    return new DefaultSignService();
}
 
Example #19
Source File: AppEngineMemcachedCacheAutoConfiguration.java    From memcached-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean
@RefreshScope
@ConditionalOnMissingBean(value = MemcachedCacheManager.class, search = SearchStrategy.CURRENT)
public MemcachedCacheManager cacheManager(MemcachedCacheProperties properties) throws IOException {
    return new AppEngineMemcachedCacheManagerFactory(properties).create();
}
 
Example #20
Source File: XMemcachedCacheAutoConfiguration.java    From memcached-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = MemcachedCacheManager.class, search = SearchStrategy.CURRENT)
public MemcachedCacheManager cacheManager(MemcachedCacheProperties properties) throws IOException {
    return new XMemcachedCacheManagerFactory(properties).create();
}
 
Example #21
Source File: XMemcachedCacheAutoConfiguration.java    From memcached-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean
@RefreshScope
@ConditionalOnMissingBean(value = MemcachedCacheManager.class, search = SearchStrategy.CURRENT)
public MemcachedCacheManager cacheManager(MemcachedCacheProperties properties) throws IOException {
    return new XMemcachedCacheManagerFactory(properties).create();
}
 
Example #22
Source File: CrnkErrorControllerAutoConfiguration.java    From crnk-framework with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController jsonapiErrorController(ErrorAttributes errorAttributes) {
	return new CrnkErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers);
}
 
Example #23
Source File: CrnkErrorControllerAutoConfiguration.java    From crnk-framework with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController jsonapiErrorController(ErrorAttributes errorAttributes) {
	return new CrnkErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers);
}
 
Example #24
Source File: BladeErrorMvcAutoConfiguration.java    From blade-tool with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes) {
	return new BladeErrorController(errorAttributes, serverProperties.getError());
}
 
Example #25
Source File: BladeErrorMvcAutoConfiguration.java    From blade-tool with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = ErrorAttributes.class, search = SearchStrategy.CURRENT)
public DefaultErrorAttributes errorAttributes() {
	return new BladeErrorAttributes();
}
 
Example #26
Source File: TarsEurekaAutoConfiguration.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = HealthCheckHandler.class, search = SearchStrategy.CURRENT)
public HealthCheckHandler HealthCheckHandler() {
    return new TarsEurekaHealthCheckHandler();
}
 
Example #27
Source File: TarsEurekaAutoConfiguration.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = DiscoveryClientOptionalArgs.class, search = SearchStrategy.CURRENT)
public DiscoveryClientOptionalArgs discoveryClientOptionalArgs() {
    return new DiscoveryClientOptionalArgs();
}
 
Example #28
Source File: SoulConfiguration.java    From soul with Apache License 2.0 4 votes vote down vote up
/**
 * Generic param resolve service dubbo param resolve service.
 *
 * @return the dubbo param resolve service
 */
@Bean
@ConditionalOnMissingBean(value = DubboParamResolveService.class, search = SearchStrategy.ALL)
public DubboParamResolveService defaultDubboParamResolveService() {
    return new DefaultDubboParamResolveService();
}
 
Example #29
Source File: SoulExtConfiguration.java    From soul with Apache License 2.0 4 votes vote down vote up
/**
 * Soul result soul result.
 *
 * @return the soul result
 */
@Bean
@ConditionalOnMissingBean(value = SoulResult.class, search = SearchStrategy.ALL)
public SoulResult soulResult() {
    return new DefaultSoulResult();
}
 
Example #30
Source File: GlobalPluginConfiguration.java    From soul with Apache License 2.0 4 votes vote down vote up
/**
 * Soul context builder soul context builder.
 *
 * @return the soul context builder
 */
@Bean
@ConditionalOnMissingBean(value = SoulContextBuilder.class, search = SearchStrategy.ALL)
public SoulContextBuilder soulContextBuilder() {
    return new DefaultSoulContextBuilder();
}