Class NestedJarResource
java.lang.Object
cloud.opencode.base.classloader.resource.AbstractResource
cloud.opencode.base.classloader.resource.NestedJarResource
- All Implemented Interfaces:
Resource
Nested JAR Resource - Represents a single resource entry inside a nested JAR
嵌套 JAR 资源 - 表示嵌套 JAR 中的单个资源条目
Provides access to resources that reside within a JAR that is itself embedded inside another (outer) JAR, such as those found in Spring Boot fat JARs.
提供对嵌套在外层 JAR 内部的 JAR 中资源的访问,例如 Spring Boot fat JAR 中的资源。
Features | 主要功能:
- Access resources in nested JARs - 访问嵌套 JAR 中的资源
- Lazy extraction via NestedJarHandler - 通过 NestedJarHandler 延迟解压
- Standard Resource interface compliance - 符合标准 Resource 接口
Usage Examples | 使用示例:
NestedJarHandler handler = NestedJarHandler.builder().build();
NestedJarResource res = new NestedJarResource(
handler, outerJar, "BOOT-INF/lib/inner.jar", "com/example/App.class");
if (res.exists()) {
byte[] bytes = res.getBytes();
}
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Since:
- JDK 25, opencode-base-classloader V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionNestedJarResource(NestedJarHandler handler, Path outerJarPath, String nestedJarEntry, String resourceEntry) Create a nested JAR resource 创建嵌套 JAR 资源 -
Method Summary
Modifier and TypeMethodDescriptioncreateRelative(String relativePath) Create relative resource 创建相对资源booleanexists()Check if resource exists 检查资源是否存在Get resource description 获取资源描述Get filename 获取文件名Get input stream for resource 获取资源的输入流Get the nested JAR entry name 获取嵌套 JAR 条目名Get the outer JAR path 获取外层 JAR 路径Get the resource entry name inside the nested JAR 获取嵌套 JAR 中的资源条目名getUrl()Get resource URL 获取资源 URLMethods inherited from class AbstractResource
contentLength, equals, getFile, getPath, getUri, hashCode, isFile, isReadable, lastModified, toString
-
Constructor Details
-
NestedJarResource
public NestedJarResource(NestedJarHandler handler, Path outerJarPath, String nestedJarEntry, String resourceEntry) Create a nested JAR resource 创建嵌套 JAR 资源- Parameters:
handler- the handler used to extract nested JARs | 用于解压嵌套 JAR 的处理器outerJarPath- path to the outer JAR file | 外层 JAR 文件路径nestedJarEntry- entry name of the nested JAR inside the outer JAR | 内层 JAR 在外层 JAR 中的条目名resourceEntry- entry name of the resource inside the nested JAR | 资源在内层 JAR 中的条目名
-
-
Method Details
-
exists
public boolean exists()Description copied from interface:ResourceCheck if resource exists 检查资源是否存在- Specified by:
existsin interfaceResource- Overrides:
existsin classAbstractResource- Returns:
- true if exists | 存在返回 true
-
getInputStream
Description copied from interface:ResourceGet input stream for resource 获取资源的输入流- Returns:
- input stream | 输入流
- Throws:
IOException- if cannot open stream | 无法打开流时抛出
-
getUrl
Description copied from interface:ResourceGet resource URL 获取资源 URL- Returns:
- resource URL | 资源 URL
- Throws:
IOException- if cannot get URL | 无法获取 URL 时抛出
-
getFilename
Description copied from interface:ResourceGet filename 获取文件名- Specified by:
getFilenamein interfaceResource- Overrides:
getFilenamein classAbstractResource- Returns:
- filename or null | 文件名或 null
-
getDescription
-
createRelative
Description copied from interface:ResourceCreate relative resource 创建相对资源- Parameters:
relativePath- relative path | 相对路径- Returns:
- relative resource | 相对资源
- Throws:
IOException- if cannot create relative resource | 无法创建相对资源时抛出
-
getOuterJarPath
Get the outer JAR path 获取外层 JAR 路径- Returns:
- outer JAR path | 外层 JAR 路径
-
getNestedJarEntry
Get the nested JAR entry name 获取嵌套 JAR 条目名- Returns:
- nested JAR entry name | 嵌套 JAR 条目名
-
getResourceEntry
Get the resource entry name inside the nested JAR 获取嵌套 JAR 中的资源条目名- Returns:
- resource entry name | 资源条目名
-