Home / Class/ ApplicationFileSystemResourceLoader Class — spring-boot Architecture

ApplicationFileSystemResourceLoader Class — spring-boot Architecture

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

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/io/ApplicationResourceLoader.java lines 172–223

	private static final class ApplicationFileSystemResourceLoader extends DefaultResourceLoader {

		private static final ResourceLoader shared = new ApplicationFileSystemResourceLoader(null, null);

		private final @Nullable Path workingDirectory;

		private ApplicationFileSystemResourceLoader(@Nullable ClassLoader classLoader,
				@Nullable Path workingDirectory) {
			super(classLoader);
			this.workingDirectory = workingDirectory;
		}

		@Override
		public Resource getResource(String location) {
			Resource resource = super.getResource(location);
			if (this.workingDirectory == null) {
				return resource;
			}
			if (!resource.isFile()) {
				return resource;
			}
			return resolveFile(resource, this.workingDirectory);
		}

		private Resource resolveFile(Resource resource, Path workingDirectory) {
			try {
				File file = resource.getFile();
				return new ApplicationResource(workingDirectory.resolve(file.toPath()));
			}
			catch (FileNotFoundException ex) {
				return resource;
			}
			catch (IOException ex) {
				throw new UncheckedIOException(ex);
			}
		}

		@Override
		protected Resource getResourceByPath(String path) {
			return new ApplicationResource(path);
		}

		static ResourceLoader get(@Nullable ClassLoader classLoader, @Nullable Path workingDirectory) {
			if (classLoader == null && workingDirectory != null) {
				throw new IllegalArgumentException(
						"It's not possible to use null as 'classLoader' but specify a 'workingDirectory'");
			}
			return (classLoader != null) ? new ApplicationFileSystemResourceLoader(classLoader, workingDirectory)
					: ApplicationFileSystemResourceLoader.shared;
		}

	}

Domain

Analyze Your Own Codebase

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

Try Supermodel Free