1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-09-28 23:51:56 +02:00
Stirling-PDF/src/main/java/stirling/software/SPDF/config/YamlPropertySourceFactory.java

23 lines
928 B
Java
Raw Normal View History

2023-08-26 18:30:49 +02:00
package stirling.software.SPDF.config;
import java.io.IOException;
import java.util.Properties;
2023-08-27 01:39:22 +02:00
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.env.PropertiesPropertySource;
2023-08-26 18:30:49 +02:00
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertySourceFactory;
public class YamlPropertySourceFactory implements PropertySourceFactory {
@Override
public PropertySource<?> createPropertySource(String name, EncodedResource encodedResource)
throws IOException {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(encodedResource.getResource());
Properties properties = factory.getObject();
return new PropertiesPropertySource(encodedResource.getResource().getFilename(), properties);
}
}