Home / Class/ PropertiesPropertySourceLoader Class — spring-boot Architecture

PropertiesPropertySourceLoader Class — spring-boot Architecture

Architecture documentation for the PropertiesPropertySourceLoader class in PropertiesPropertySourceLoader.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/env/PropertiesPropertySourceLoader.java lines 42–90

public class PropertiesPropertySourceLoader implements PropertySourceLoader {

	private static final String XML_FILE_EXTENSION = ".xml";

	@Override
	public String[] getFileExtensions() {
		return new String[] { "properties", "xml" };
	}

	@Override
	public List<PropertySource<?>> load(String name, Resource resource) throws IOException {
		return load(name, resource, null);
	}

	@Override
	public List<PropertySource<?>> load(String name, Resource resource, @Nullable Charset encoding) throws IOException {
		List<Map<String, ?>> properties = loadProperties(resource, encoding);
		if (properties.isEmpty()) {
			return Collections.emptyList();
		}
		List<PropertySource<?>> propertySources = new ArrayList<>(properties.size());
		for (int i = 0; i < properties.size(); i++) {
			String documentNumber = (properties.size() != 1) ? " (document #" + i + ")" : "";
			propertySources.add(new OriginTrackedMapPropertySource(name + documentNumber,
					Collections.unmodifiableMap(properties.get(i)), true));
		}
		return propertySources;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	private List<Map<String, ?>> loadProperties(Resource resource, @Nullable Charset encoding) throws IOException {
		String filename = resource.getFilename();
		List<Map<String, ?>> result = new ArrayList<>();
		if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
			if (encoding == null) {
				result.add((Map) PropertiesLoaderUtils.loadProperties(resource));
			}
			else {
				result.add((Map) PropertiesLoaderUtils.loadProperties(new EncodedResource(resource, encoding)));
			}
		}
		else {
			List<Document> documents = new OriginTrackedPropertiesLoader(resource).load(encoding);
			documents.forEach((document) -> result.add(document.asMap()));
		}
		return result;
	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free