org.springframework.cloud.bootstrap.config.PropertySourceLocator Java Examples

The following examples show how to use org.springframework.cloud.bootstrap.config.PropertySourceLocator. 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: ConfigurationChangeDetector.java    From spring-cloud-kubernetes with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a list of MapPropertySource that correspond to the current state of the
 * system. This only handles the PropertySource objects that are returned.
 * @param propertySourceLocator Spring's property source locator
 * @param environment Spring environment
 * @return a list of MapPropertySource that correspond to the current state of the
 * system
 */
protected List<MapPropertySource> locateMapPropertySources(
		PropertySourceLocator propertySourceLocator, Environment environment) {

	List<MapPropertySource> result = new ArrayList<>();
	PropertySource propertySource = propertySourceLocator.locate(environment);
	if (propertySource instanceof MapPropertySource) {
		result.add((MapPropertySource) propertySource);
	}
	else if (propertySource instanceof CompositePropertySource) {
		result.addAll(((CompositePropertySource) propertySource).getPropertySources()
				.stream().filter(p -> p instanceof MapPropertySource)
				.map(p -> (MapPropertySource) p).collect(Collectors.toList()));
	}
	else {
		this.log.debug("Found property source that cannot be handled: "
				+ propertySource.getClass());
	}

	return result;
}
 
Example #2
Source File: SecretManagerTestConfiguration.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
public PropertySourceLocator secretManagerPropertySourceLocator(
		SecretManagerTemplate secretManagerTemplate) {
	SecretManagerPropertySourceLocator propertySourceLocator =
			new SecretManagerPropertySourceLocator(secretManagerTemplate, this.projectIdProvider);
	return propertySourceLocator;
}
 
Example #3
Source File: GcpSecretManagerBootstrapConfiguration.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public PropertySourceLocator secretManagerPropertySourceLocator(
		SecretManagerTemplate secretManagerTemplate) {
	SecretManagerPropertySourceLocator propertySourceLocator =
			new SecretManagerPropertySourceLocator(secretManagerTemplate, this.gcpProjectIdProvider);
	return propertySourceLocator;
}
 
Example #4
Source File: VaultBootstrapPropertySourceConfiguration.java    From spring-cloud-vault with Apache License 2.0 5 votes vote down vote up
@Bean
public PropertySourceLocator vaultPropertySourceLocator(VaultOperations operations,
		VaultProperties vaultProperties,
		VaultKeyValueBackendProperties kvBackendProperties,
		ObjectFactory<SecretLeaseContainer> secretLeaseContainerObjectFactory) {

	VaultConfigTemplate vaultConfigTemplate = new VaultConfigTemplate(operations,
			vaultProperties);

	PropertySourceLocatorConfiguration configuration = getPropertySourceConfiguration(
			Collections.singletonList(kvBackendProperties));

	VaultProperties.Lifecycle lifecycle = vaultProperties.getConfig().getLifecycle();

	if (lifecycle.isEnabled()) {

		// This is to destroy bootstrap resources
		// otherwise, the bootstrap context is not shut down cleanly
		this.applicationContext.registerShutdownHook();

		SecretLeaseContainer secretLeaseContainer = secretLeaseContainerObjectFactory
				.getObject();

		secretLeaseContainer.start();

		return new LeasingVaultPropertySourceLocator(vaultProperties, configuration,
				secretLeaseContainer);
	}

	return new VaultPropertySourceLocator(vaultConfigTemplate, vaultProperties,
			configuration);
}
 
Example #5
Source File: SyncopeWABootstrapConfiguration.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Autowired
@Bean
public PropertySourceLocator configPropertySourceLocator(final WARestClient waRestClient) {
    return new SyncopeWAPropertySourceLocator(waRestClient);
}
 
Example #6
Source File: ConfigServicePropertySourceLocator.java    From spring-cloud-config with Apache License 2.0 4 votes vote down vote up
@Override
@Retryable(interceptor = "configServerRetryInterceptor")
public Collection<org.springframework.core.env.PropertySource<?>> locateCollection(
		org.springframework.core.env.Environment environment) {
	return PropertySourceLocator.locateCollection(this, environment);
}
 
Example #7
Source File: ConsulPropertySourceLocator.java    From spring-cloud-consul with Apache License 2.0 4 votes vote down vote up
@Override
@Retryable(interceptor = "consulRetryInterceptor")
public Collection<PropertySource<?>> locateCollection(Environment environment) {
	return PropertySourceLocator.locateCollection(this, environment);
}