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

The following examples show how to use org.springframework.cloud.bootstrap.config.PropertySourceLocator. These examples are extracted from open source projects. 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
/**
 * 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
@Bean
public PropertySourceLocator secretManagerPropertySourceLocator(
		SecretManagerTemplate secretManagerTemplate) {
	SecretManagerPropertySourceLocator propertySourceLocator =
			new SecretManagerPropertySourceLocator(secretManagerTemplate, this.projectIdProvider);
	return propertySourceLocator;
}
 
Example 3
@Bean
@ConditionalOnMissingBean
public PropertySourceLocator secretManagerPropertySourceLocator(
		SecretManagerTemplate secretManagerTemplate) {
	SecretManagerPropertySourceLocator propertySourceLocator =
			new SecretManagerPropertySourceLocator(secretManagerTemplate, this.gcpProjectIdProvider);
	return propertySourceLocator;
}
 
Example 4
@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 Project: syncope   Source File: SyncopeWABootstrapConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
@Bean
public PropertySourceLocator configPropertySourceLocator(final WARestClient waRestClient) {
    return new SyncopeWAPropertySourceLocator(waRestClient);
}
 
Example 6
@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
@Override
@Retryable(interceptor = "consulRetryInterceptor")
public Collection<PropertySource<?>> locateCollection(Environment environment) {
	return PropertySourceLocator.locateCollection(this, environment);
}