Home / Class/ ApplicationInfoPropertySource Class — spring-boot Architecture

ApplicationInfoPropertySource Class — spring-boot Architecture

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

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/ApplicationInfoPropertySource.java lines 38–86

class ApplicationInfoPropertySource extends MapPropertySource implements PropertySourceInfo {

	static final String NAME = "applicationInfo";

	ApplicationInfoPropertySource(@Nullable Class<?> mainClass) {
		super(NAME, getProperties(readVersion(mainClass)));
	}

	ApplicationInfoPropertySource(@Nullable String applicationVersion) {
		super(NAME, getProperties(applicationVersion));
	}

	@Override
	public boolean isImmutable() {
		return true;
	}

	private static Map<String, Object> getProperties(@Nullable String applicationVersion) {
		Map<String, Object> result = new HashMap<>();
		if (StringUtils.hasText(applicationVersion)) {
			result.put("spring.application.version", applicationVersion);
		}
		ApplicationPid applicationPid = new ApplicationPid();
		Long pid = applicationPid.toLong();
		if (pid != null) {
			result.put("spring.application.pid", pid);
		}
		return result;
	}

	private static @Nullable String readVersion(@Nullable Class<?> applicationClass) {
		Package sourcePackage = (applicationClass != null) ? applicationClass.getPackage() : null;
		return (sourcePackage != null) ? sourcePackage.getImplementationVersion() : null;
	}

	/**
	 * Moves the {@link ApplicationInfoPropertySource} to the end of the environment's
	 * property sources.
	 * @param environment the environment
	 */
	static void moveToEnd(ConfigurableEnvironment environment) {
		MutablePropertySources propertySources = environment.getPropertySources();
		PropertySource<?> propertySource = propertySources.remove(NAME);
		if (propertySource != null) {
			propertySources.addLast(propertySource);
		}
	}

}

Domain

Analyze Your Own Codebase

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

Try Supermodel Free