Interface ResourceLoader
- All Known Implementing Classes:
DefaultResourceLoader
public interface ResourceLoader
Resource Loader Interface
资源加载器接口
Interface for loading resources with location prefix support. Automatically detects resource type based on location prefix.
支持位置前缀的资源加载接口。 根据位置前缀自动检测资源类型。
Supported Prefixes | 支持的前缀:
- classpath: - classpath resource | 类路径资源
- file: - filesystem resource | 文件系统资源
- http:/https: - URL resource | URL资源
Usage Examples | 使用示例:
ResourceLoader loader = ResourceLoader.getDefault();
Resource r1 = loader.getResource("classpath:config.yaml");
Resource r2 = loader.getResource("file:/etc/app/config.yaml");
Resource r3 = loader.getResource("https://server/config.yaml");
Features | 主要功能:
- Unified resource loading with location prefix detection - 统一资源加载,支持位置前缀检测
- Support for classpath:, file:, http/https: prefixes - 支持classpath:、file:、http/https:前缀
- Default implementation via getDefault() - 通过getDefault()获取默认实现
Security | 安全性:
- Thread-safe: Depends on implementation - 线程安全: 取决于实现
- Null-safe: No, location must not be null - 空值安全: 否,位置不可为null
- Since:
- JDK 25, opencode-base-io V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionGets the ClassLoader used by this loader 获取此加载器使用的ClassLoaderstatic ResourceLoaderGets the default resource loader 获取默认资源加载器getResource(String location) Loads a resource from the given location 从给定位置加载资源
-
Field Details
-
CLASSPATH_PREFIX
-
FILE_PREFIX
-
-
Method Details
-
getResource
-
getClassLoader
ClassLoader getClassLoader()Gets the ClassLoader used by this loader 获取此加载器使用的ClassLoader- Returns:
- classloader | 类加载器
-
getDefault
Gets the default resource loader 获取默认资源加载器- Returns:
- default loader | 默认加载器
-