Browse Source

REPORT-114391 【微服务适配】远程&本地设计器能够正常启动 优化依赖

mss/2.0
Destiny.Lin 6 months ago
parent
commit
219a45a35b
  1. 1
      build.gradle
  2. 63
      designer-base/src/main/java/com/fr/design/extra/PluginHelper.java
  3. 14
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  4. 22
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  5. 32
      designer-realize/src/main/java/com/fanruan/boot/DesignPluginComponent.java
  6. 9
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

1
build.gradle

@ -65,6 +65,7 @@ allprojects {
implementation 'com.fr.essential:fine-essential:' + cbbVersion
implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion
implementation 'com.fr.plugin:fine-plugin-api:' + apiVersion
implementation 'com.fr.plugin:fine-plugin:' + apiVersion
implementation 'com.fr.workplace:workplace-api:' + apiVersion
implementation 'com.fr.carina:fine-carina:' + apiVersion
implementation 'com.fr.auth:fine-auth-api:' + apiVersion

63
designer-base/src/main/java/com/fr/design/extra/PluginHelper.java

@ -1,63 +0,0 @@
package com.fr.design.extra;
import com.fanruan.carina.Carina;
import com.fanruan.plugin.design.loader.PluginResourceLoaderSingletonShell;
import com.fanruan.plugin.design.loader.UPMResourceLoaderSingletonShell;
import com.fanruan.plugin.design.store.PluginStoreProvider;
import com.fanruan.plugin.design.store.PluginStoreSingletonShell;
import com.fr.decision.webservice.v10.plugin.helper.category.ResourceLoader;
import java.util.List;
/**
* 用于设计器调用插件内部资源
* <p>对应的资源需要提前注册进环境里</p>
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/5/14
*/
public class PluginHelper {
private PluginStoreProvider storeProvider;
private ResourceLoader upmLoader;
private ResourceLoader pluginLoader;
private static final PluginHelper INSTANCE = new PluginHelper();
private PluginHelper() {
storeProvider = Carina.getApplicationContext().singleton(PluginStoreSingletonShell.class).get();
upmLoader = Carina.getApplicationContext().singleton(UPMResourceLoaderSingletonShell.class).get();
pluginLoader = Carina.getApplicationContext().singleton(PluginResourceLoaderSingletonShell.class).get();
}
/**
* 获取插件helper单例
*/
public static PluginHelper getInstance() {
return INSTANCE;
}
public PluginStoreProvider getStoreProvider() {
return storeProvider;
}
public void setStoreProvider(PluginStoreProvider storeProvider) {
this.storeProvider = storeProvider;
}
public ResourceLoader getUpmLoader() {
return upmLoader;
}
public void setUpmLoader(ResourceLoader upmLoader) {
this.upmLoader = upmLoader;
}
public ResourceLoader getPluginLoader() {
return pluginLoader;
}
public void setPluginLoader(ResourceLoader pluginLoader) {
this.pluginLoader = pluginLoader;
}
}

14
designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java

@ -14,6 +14,8 @@ import com.fr.general.IOUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginStoreConfig;
import com.fr.plugin.PluginStoreConstants;
import com.fr.stable.CommonUtils;
import com.fr.stable.EnvChangedListener;
import com.fanruan.product.ProductConstants;
@ -41,14 +43,14 @@ public class WebViewDlgHelper {
private static final String LATEST = "latest";
private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8;
private static String installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome();
private static String installHome = PluginStoreConstants.getLocalInstallHome();
private static final String MAIN_JS_PATH = "/scripts/plugin.html";
static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome();
installHome = PluginStoreConstants.getLocalInstallHome();
}
});
}
@ -71,9 +73,9 @@ public class WebViewDlgHelper {
return;
}
// 检测更新前先刷新一下版本号
PluginHelper.getInstance().getStoreProvider().refreshProps();
PluginStoreConstants.refreshProps();
String jarVersion = PluginHelper.getInstance().getStoreProvider().getEnvVersion();
String jarVersion = PluginStoreConfig.getInstance().getEnvVersion();
if (ComparatorUtils.equals(jarVersion, ProductConstants.VERSION)) {
updateShopScripts(SHOP_SCRIPTS);
showPluginDlg();
@ -262,7 +264,7 @@ public class WebViewDlgHelper {
IOUtils.unzip(scriptZip, installHome);
CommonUtils.deleteFile(scriptZip);
}
PluginHelper.getInstance().getStoreProvider().refreshProps(); // 下载完刷新一下版本号等
PluginStoreConstants.refreshProps(); // 下载完刷新一下版本号等
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE);
}
} catch (InterruptedException e) {
@ -282,7 +284,7 @@ public class WebViewDlgHelper {
protected Void doInBackground() throws Exception {
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update");
if (url != null) {
String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginHelper.getInstance().getStoreProvider().getVersion());
String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConfig.getInstance().getVersion());
JSONObject resultJSONObject = new JSONObject(text);
String isLatest = resultJSONObject.optString("result");
if (!ComparatorUtils.equals(isLatest, LATEST)) {

22
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -1,8 +1,9 @@
package com.fr.design.upm;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.BaseResourceLoader;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.PluginHelper;
import com.fr.design.i18n.Toolkit;
import com.fr.design.login.utils.DesignerLoginUtils;
import com.fr.design.mainframe.DesignerContext;
@ -15,10 +16,8 @@ import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.plugin.PluginStoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
@ -36,9 +35,8 @@ public class UpmFinder {
private static final String UPM_DIR = "/upm";
private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
public static final String TEMP_FILE = "cache/temp.zip";
public static final String SCRIPT_DOWNLOAD_PATH = CommonUtils.pathJoin(WorkContext.getCurrent().getPath(), TEMP_FILE);
public static String installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome();
public static String installHome = PluginStoreConstants.getLocalInstallHome();
private static UIDialog dialog = null;
@ -46,8 +44,8 @@ public class UpmFinder {
EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome();
PluginHelper.getInstance().getUpmLoader().checkOldShopFile();
installHome = PluginStoreConstants.getLocalInstallHome();
UpmResourceLoader.INSTANCE.checkOldShopFile();
}
});
}
@ -87,7 +85,7 @@ public class UpmFinder {
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
if (val == JOptionPane.OK_OPTION) {
try {
PluginHelper.getInstance().getUpmLoader().download();
UpmResourceLoader.INSTANCE.download();
installUpmResource();
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"),
@ -109,8 +107,8 @@ public class UpmFinder {
}
private static void installUpmResource() {
String installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome();
File scriptZip = new File(SCRIPT_DOWNLOAD_PATH);
String installHome = PluginStoreConstants.getLocalInstallHome();
File scriptZip = new File(BaseResourceLoader.SCRIPT_DOWNLOAD_PATH);
if (scriptZip.exists()) {
IOUtils.unzip(scriptZip, installHome);
CommonIOUtils.deleteFile(scriptZip);

32
designer-realize/src/main/java/com/fanruan/boot/DesignPluginComponent.java

@ -0,0 +1,32 @@
package com.fanruan.boot;
import com.fanruan.carina.annotions.DependsOn;
import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start;
import javax.servlet.ServletContext;
/**
* 设计器插件模块
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/5/17
*/
@FineComponent(name = "design_plugin")
@DependsOn(dependencies = {"design_core_supplemental", "design_dao", "design_conf_config", "design_logger"})
public class DesignPluginComponent extends PluginComponent{
/**
* start
*/
@Start
public void start() {
super.start();
}
@Override
protected void addPluginStoreFilter(ServletContext servletContext) {
// do nothing
}
}

9
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -13,7 +13,8 @@ import com.fr.base.theme.migrator.ReportThemeConfigMigrator;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.config.ServerPreferenceConfig;
import com.fr.decision.update.backup.RecoverManager;
import com.fr.decision.webservice.v10.plugin.helper.category.ResourceLoader;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.PluginResourceLoader;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.NewFormAction;
@ -35,7 +36,6 @@ import com.fr.design.actions.replace.utils.ReplaceOperator;
import com.fr.design.bridge.DesignToolbarProvider;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.env.DesignerWorkspaceLoader;
import com.fr.design.extra.PluginHelper;
import com.fr.design.fit.NewJForm;
import com.fr.design.fit.common.TemplateTool;
import com.fr.design.form.parameter.FormParaDesigner;
@ -144,7 +144,6 @@ import com.fr.start.BBSGuestPaneProvider;
import com.fr.start.common.DesignerStartupExecutor;
import com.fr.start.common.DesignerStartupPool;
import com.fr.task.Once;
import com.fr.tenant.context.TenantContext;
import com.fr.workspace.WorkContext;
import com.fr.xml.ReportXMLUtils;
@ -215,8 +214,8 @@ public class DesignerActivator extends Activator implements Prepare {
CompletableFuture<Void> resourcePrepare = CompletableFuture.runAsync(() -> {
pushUpdateTask.run();
if (WorkContext.getCurrent().isLocal()) {
PluginHelper.getInstance().getPluginLoader().checkOldShopFile();
PluginHelper.getInstance().getUpmLoader().checkOldShopFile();
PluginResourceLoader.INSTANCE.checkOldShopFile();
UpmResourceLoader.INSTANCE.checkOldShopFile();
}
}, DesignerStartupPool.common());

Loading…
Cancel
Save