Stirling-PDF/src/main/java/stirling/software/SPDF/config/YamlPropertySourceFactory.java

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
952 B
Java
Raw Normal View History

2023-08-26 17:30:49 +01:00
package stirling.software.SPDF.config;
import java.io.IOException;
import java.util.Properties;
2023-08-27 00:39:22 +01:00
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.env.PropertiesPropertySource;
2023-08-26 17:30:49 +01:00
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertySourceFactory;
2023-12-30 19:11:27 +00:00
2023-08-26 17:30:49 +01:00
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);
}
}