Class DefaultResourceLoader
java.lang.Object
cloud.opencode.base.io.resource.DefaultResourceLoader
- All Implemented Interfaces:
ResourceLoader
Default Resource Loader Implementation
默认资源加载器实现
Default implementation of ResourceLoader that intelligently loads resources based on location prefix.
ResourceLoader的默认实现,根据位置前缀智能加载资源。
Features | 主要功能:
- Automatic prefix detection - 自动前缀检测
- Support classpath, file, URL - 支持类路径、文件、URL
- Thread-safe singleton - 线程安全单例
Usage Examples | 使用示例:
ResourceLoader loader = DefaultResourceLoader.INSTANCE;
Resource resource = loader.getResource("classpath:config.properties");
- Since:
- JDK 25, opencode-base-io V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Field Summary
FieldsFields inherited from interface ResourceLoader
CLASSPATH_PREFIX, FILE_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionCreates a default resource loader 创建默认资源加载器DefaultResourceLoader(ClassLoader classLoader) Creates a resource loader with specific classloader 使用指定类加载器创建资源加载器 -
Method Summary
Modifier and TypeMethodDescriptionGets the ClassLoader used by this loader 获取此加载器使用的ClassLoadergetResource(String location) Loads a resource from the given location 从给定位置加载资源toString()
-
Field Details
-
INSTANCE
Singleton instance 单例实例
-
-
Constructor Details
-
DefaultResourceLoader
public DefaultResourceLoader()Creates a default resource loader 创建默认资源加载器 -
DefaultResourceLoader
Creates a resource loader with specific classloader 使用指定类加载器创建资源加载器- Parameters:
classLoader- the classloader | 类加载器
-
-
Method Details
-
getResource
Description copied from interface:ResourceLoaderLoads a resource from the given location 从给定位置加载资源- Specified by:
getResourcein interfaceResourceLoader- Parameters:
location- the resource location | 资源位置- Returns:
- resource | 资源
-
getClassLoader
Description copied from interface:ResourceLoaderGets the ClassLoader used by this loader 获取此加载器使用的ClassLoader- Specified by:
getClassLoaderin interfaceResourceLoader- Returns:
- classloader | 类加载器
-
toString
-