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);
|
|
|
|
}
|
|
|
|
}
|