|
|
|
@ -84,7 +84,13 @@ import java.util.concurrent.CompletableFuture;
|
|
|
|
|
*/ |
|
|
|
|
@FineComponent(name = "design_pre_start") |
|
|
|
|
public class DesignPreStartComponent { |
|
|
|
|
private static final String SEPARATOR = "/"; |
|
|
|
|
private static final String CPT = ".cpt"; |
|
|
|
|
private static final String XML = ".xml"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 启动 |
|
|
|
|
*/ |
|
|
|
|
@Start |
|
|
|
|
public void start() throws Exception { |
|
|
|
|
// 1.注册ConfigFactory与对应的membuilder
|
|
|
|
@ -146,17 +152,17 @@ public class DesignPreStartComponent {
|
|
|
|
|
@Override |
|
|
|
|
public @Nullable InputStream getResource(@NotNull String resourcePath) { |
|
|
|
|
|
|
|
|
|
if (!resourcePath.startsWith("/")) { |
|
|
|
|
resourcePath = "/" + resourcePath; |
|
|
|
|
if (!resourcePath.startsWith(SEPARATOR)) { |
|
|
|
|
resourcePath = SEPARATOR + resourcePath; |
|
|
|
|
} |
|
|
|
|
InputStream result = null; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (resourcePath.endsWith(".cpt")) { |
|
|
|
|
if (resourcePath.endsWith(CPT)) { |
|
|
|
|
result = new ByteArrayInputStream(WorkContext.getWorkResource().readFully(CommonUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, resourcePath))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (resourcePath.endsWith(".xml")) { |
|
|
|
|
if (resourcePath.endsWith(XML)) { |
|
|
|
|
result = new ByteArrayInputStream(WorkContext.getWorkResource().readFully(CommonUtils.pathJoin(ProjectConstants.RESOURCES_NAME, resourcePath))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -167,11 +173,7 @@ public class DesignPreStartComponent {
|
|
|
|
|
} catch (Exception ignored) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (resourcePath.startsWith("/")) { |
|
|
|
|
result = ResourceLoader.getResourceAsStream(resourcePath, GeneralUtils.class); |
|
|
|
|
} else { |
|
|
|
|
result = ResourceLoader.getResourceAsStream("/" + resourcePath, GeneralUtils.class); |
|
|
|
|
} |
|
|
|
|
result = ResourceLoader.getResourceAsStream(resourcePath, GeneralUtils.class); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|