org.springframework.boot.env.RandomValuePropertySource Java Examples
The following examples show how to use
org.springframework.boot.env.RandomValuePropertySource.
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: SpringConfigurationPropertySource.java From synopsys-detect with Apache License 2.0 | 6 votes |
public static List<SpringConfigurationPropertySource> fromConfigurableEnvironment(ConfigurableEnvironment configurableEnvironment, boolean ignoreUnknown) { List<ConfigurationPropertySource> sources = Bds.listOf(ConfigurationPropertySources.get(configurableEnvironment)); return Bds.of(sources).map(it -> { if (IterableConfigurationPropertySource.class.isAssignableFrom(it.getClass())) { return getPropertySource(configurableEnvironment, ignoreUnknown, it); } else if (RandomValuePropertySource.class.isAssignableFrom(it.getUnderlyingSource().getClass())) { //We know an underlying random source can't be iterated but we don't care. It can't give a list of known keys. return null; } else { if (ignoreUnknown) { return null; } else { throw new RuntimeException( new UnknownSpringConfigurationException("Unknown spring configuration type. We may be unable to find property information from it correctly. Likely a new configuration property source should be tested against. ")); } } }).filterNotNull().toList(); }
Example #2
Source File: CachedRandomPropertySourceAutoConfiguration.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@PostConstruct public void initialize() { MutablePropertySources propertySources = environment.getPropertySources(); PropertySource propertySource = propertySources .get(RandomValuePropertySource.RANDOM_PROPERTY_SOURCE_NAME); if (propertySource != null) { propertySources.addLast(new CachedRandomPropertySource(propertySource)); } }