本文整理汇总了Java中org.springframework.boot.env.PropertySourceLoader类的典型用法代码示例。如果您正苦于以下问题:Java PropertySourceLoader类的具体用法?Java PropertySourceLoader怎么用?Java PropertySourceLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PropertySourceLoader类属于org.springframework.boot.env包,在下文中一共展示了PropertySourceLoader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPropertySource
import org.springframework.boot.env.PropertySourceLoader; //导入依赖的package包/类
private PropertySource createPropertySource(AnnotationAttributes attributes, ConfigurableEnvironment environment, ResourceLoader resourceLoader, EncryptablePropertyResolver resolver, List<PropertySourceLoader> loaders) throws Exception {
String name = generateName(attributes.getString("name"));
String[] locations = attributes.getStringArray("value");
boolean ignoreResourceNotFound = attributes.getBoolean("ignoreResourceNotFound");
CompositePropertySource compositePropertySource = new CompositePropertySource(name);
Assert.isTrue(locations.length > 0, "At least one @PropertySource(value) location is required");
for (String location : locations) {
String resolvedLocation = environment.resolveRequiredPlaceholders(location);
Resource resource = resourceLoader.getResource(resolvedLocation);
if (!resource.exists()) {
if (!ignoreResourceNotFound) {
throw new IllegalStateException(String.format("Encryptable Property Source '%s' from location: %s Not Found", name, resolvedLocation));
} else {
log.info("Ignoring NOT FOUND Encryptable Property Source '{}' from locations: {}", name, resolvedLocation);
}
} else {
String actualName = name + "#" + resolvedLocation;
loadPropertySource(loaders, resource, actualName)
.ifPresent(compositePropertySource::addPropertySource);
}
}
return new EncryptableEnumerablePropertySourceWrapper<>(compositePropertySource, resolver);
}
开发者ID:ulisesbocchio,项目名称:jasypt-spring-boot,代码行数:24,代码来源:EncryptablePropertySourceBeanFactoryPostProcessor.java
示例2: postProcessBeanFactory
import org.springframework.boot.env.PropertySourceLoader; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
ResourceLoader ac = new DefaultResourceLoader();
MutablePropertySources propertySources = env.getPropertySources();
Stream<AnnotationAttributes> encryptablePropertySourcesMetadata = getEncryptablePropertySourcesMetadata(beanFactory);
EncryptablePropertyResolver propertyResolver = beanFactory.getBean(RESOLVER_BEAN_NAME, EncryptablePropertyResolver.class);
List<PropertySourceLoader> loaders = initPropertyLoaders();
encryptablePropertySourcesMetadata.forEach(eps -> loadEncryptablePropertySource(eps, env, ac, propertyResolver, propertySources, loaders));
}
开发者ID:ulisesbocchio,项目名称:jasypt-spring-boot,代码行数:10,代码来源:EncryptablePropertySourceBeanFactoryPostProcessor.java
示例3: loadEncryptablePropertySource
import org.springframework.boot.env.PropertySourceLoader; //导入依赖的package包/类
private void loadEncryptablePropertySource(AnnotationAttributes encryptablePropertySource, ConfigurableEnvironment env, ResourceLoader resourceLoader, EncryptablePropertyResolver resolver, MutablePropertySources propertySources, List<PropertySourceLoader> loaders) throws BeansException {
try {
PropertySource ps = createPropertySource(encryptablePropertySource, env, resourceLoader, resolver, loaders);
propertySources.addLast(ps);
log.info("Created Encryptable Property Source '{}' from locations: {}", ps.getName(), Arrays.asList(encryptablePropertySource.getStringArray("value")));
} catch (Exception e) {
throw new ApplicationContextException("Exception Creating PropertySource", e);
}
}
开发者ID:ulisesbocchio,项目名称:jasypt-spring-boot,代码行数:10,代码来源:EncryptablePropertySourceBeanFactoryPostProcessor.java
示例4: loadPropertySource
import org.springframework.boot.env.PropertySourceLoader; //导入依赖的package包/类
private Optional<PropertySource<?>> loadPropertySource(List<PropertySourceLoader> loaders, Resource resource, String sourceName) throws IOException {
return Optional.of(resource)
.filter(this::isFile)
.map(res -> loaders.stream()
.filter(loader -> canLoadFileExtension(loader, resource))
.findFirst()
.map(loader -> load(loader, sourceName, resource))
.orElse(null));
}
开发者ID:ulisesbocchio,项目名称:jasypt-spring-boot,代码行数:10,代码来源:EncryptablePropertySourceBeanFactoryPostProcessor.java
示例5: loadProperties
import org.springframework.boot.env.PropertySourceLoader; //导入依赖的package包/类
private EnumerablePropertySource loadProperties(PropertySourceLoader hoconLoader, String path) throws IOException {
return (EnumerablePropertySource) hoconLoader.load("hocon", new ClassPathResource(path), null);
}
示例6: initPropertyLoaders
import org.springframework.boot.env.PropertySourceLoader; //导入依赖的package包/类
private List<PropertySourceLoader> initPropertyLoaders() {
return SpringFactoriesLoader.loadFactories(PropertySourceLoader.class, getClass().getClassLoader());
}
开发者ID:ulisesbocchio,项目名称:jasypt-spring-boot,代码行数:4,代码来源:EncryptablePropertySourceBeanFactoryPostProcessor.java
示例7: load
import org.springframework.boot.env.PropertySourceLoader; //导入依赖的package包/类
@SneakyThrows
private PropertySource<?> load(PropertySourceLoader loader, String sourceName, Resource resource) {
return loader.load(sourceName, resource, null);
}
开发者ID:ulisesbocchio,项目名称:jasypt-spring-boot,代码行数:5,代码来源:EncryptablePropertySourceBeanFactoryPostProcessor.java
示例8: canLoadFileExtension
import org.springframework.boot.env.PropertySourceLoader; //导入依赖的package包/类
private boolean canLoadFileExtension(PropertySourceLoader loader, Resource resource) {
return Arrays.stream(loader.getFileExtensions())
.anyMatch(extension -> resource.getFilename().toLowerCase().endsWith("." + extension.toLowerCase()));
}
开发者ID:ulisesbocchio,项目名称:jasypt-spring-boot,代码行数:5,代码来源:EncryptablePropertySourceBeanFactoryPostProcessor.java