diff --git a/designer-base/src/main/java/com/fr/design/ConfigHelper.java b/designer-base/src/main/java/com/fr/design/ConfigHelper.java index 31724d8652..c5fd1668d0 100644 --- a/designer-base/src/main/java/com/fr/design/ConfigHelper.java +++ b/designer-base/src/main/java/com/fr/design/ConfigHelper.java @@ -94,7 +94,10 @@ public class ConfigHelper { return properties; } - private static boolean createFile(File file) throws ResourceIOException { + /** + * 创建配置文件 + */ + public static boolean createFile(File file) throws ResourceIOException { String parent = file.getParent(); if (StringUtils.isNotEmpty(parent)) { createDirectory(parent); diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java index 736aa35096..4fd91d49a4 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java @@ -45,6 +45,7 @@ import com.fr.locale.InterMutableKey; import com.fr.locale.LocaleMarker; import com.fr.locale.LocaleScope; import com.fr.locale.LocaleUtils; +import com.fr.locale.international.InternationalLocaleManager; import com.fr.log.FineLoggerFactory; import com.fr.measure.DBMeterFactory; import com.fr.record.DefaultDBMeter; @@ -146,6 +147,7 @@ public class DesignPreLoadComponent { } FrontProviderImpl.init(InterProviderImpl.getInstance()); + InternationalLocaleManager.getInstance().init(); } diff --git a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java index 21bca14bd0..b3363f6d3d 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java @@ -1,5 +1,10 @@ package com.fanruan.boot.pre; +import com.fanruan.boot.FSProperties; +import com.fanruan.fs.FileServer; +import com.fanruan.fs.RepositoryFactory; +import com.fanruan.fs.repository.local.LocalFileRepository; +import com.fanruan.product.ProductConstants; import com.fr.design.ConfigHelper; import com.fanruan.boot.key.StartupArgsShell; import com.fanruan.carina.Carina; @@ -31,11 +36,17 @@ import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.general.CommonIOUtils; import com.fr.general.GeneralUtils; +import com.fr.io.base.ResourcePaths; +import com.fr.io.repository.ResourceRepository; +import com.fr.io.repository.ResourceRepositoryWrapper; +import com.fr.io.utils.ResourceIOUtils; import com.fr.log.FineLoggerFactory; import com.fr.module.engine.event.LifecycleErrorEvent; import com.fr.runtime.FineRuntime; import com.fr.stable.CommonCodeUtils; import com.fr.stable.CommonUtils; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import com.fr.stable.lifecycle.FineLifecycleFatalError; import com.fr.stable.project.ProjectConstants; import com.fr.stable.resource.ResourceLoader; @@ -56,6 +67,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.concurrent.CompletableFuture; @@ -72,6 +84,9 @@ public class DesignPreStartComponent { private static final String SEPARATOR = "/"; private static final String CPT = ".cpt"; private static final String XML = ".xml"; + private static final String PRE_FILE_ROOT = ProductConstants.getEnvHome() + File.separator + "prefile"; + private static final String PRE_FILE = PRE_FILE_ROOT + File.separator + "check"; + /** * 启动 @@ -84,10 +99,38 @@ public class DesignPreStartComponent { startTenant(); // 3.pluginPrepare,注册插件的反向依赖 startPluginPrepare(); - // 4.正式启动 - startPre(); - // 5.mq + // 4.mq startMq(); + // 5.基础fs + startBasicFs(); + // 6.正式启动 + startPre(); + } + + private void startBasicFs() throws Exception { + // 启动的时候无关环境信息的写缓存里 + checkFile(PRE_FILE); + LocalFileRepository.getSingleton().setWorkRoot(PRE_FILE_ROOT); + ResourceRepository realRepo = RepositoryFactory.getRepo(); + FSProperties fsProperties = Carina.properties(FSProperties.class); + FileServer.init( + new ResourceRepositoryWrapper(LocalFileRepository.getSingleton(), StringUtils.EMPTY), + new ResourceRepositoryWrapper(realRepo, StringUtils.EMPTY), + new ResourceRepositoryWrapper(realRepo, StringUtils.EMPTY), + new ResourceRepositoryWrapper(realRepo.generateTenantsSharedRepo(fsProperties.getTenantsSharedNamespace()), StringUtils.EMPTY)); + + ResourceIOUtils.setUnderlying(FileServer.local()); + ResourceIOUtils.setIsolationMode(false); + + ResourcePaths.register(ProjectConstants.ASSETS_NAME, true); + ResourcePaths.register(ProjectConstants.SCHEDULE_NAME, false); + } + + private void checkFile(String path) { + File file = new File(path); + if (!file.exists()) { + ConfigHelper.createFile(file); + } } private void startMq() throws Exception {