Destiny.Lin
6 months ago
50 changed files with 556 additions and 242 deletions
@ -0,0 +1,59 @@
|
||||
package com.fr.design.env; |
||||
|
||||
import com.fanruan.workplace.http.HttpConstants; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.workspace.server.repository.connect.FineWorkspaceHttpClient; |
||||
import com.fr.decision.webservice.bean.authentication.LoginRequestInfoBean; |
||||
import com.fr.decision.webservice.bean.authentication.LoginResponseInfoBean; |
||||
import com.fr.workspace.connect.WorkspaceClient; |
||||
import com.fr.workspace.connect.WorkspaceConnection; |
||||
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
||||
import com.fr.workspace.connect.WorkspaceConnector; |
||||
import com.fr.workspace.server.repository.connect.RemoteNetworkRepository; |
||||
|
||||
import java.net.InetAddress; |
||||
import java.util.UUID; |
||||
|
||||
/** |
||||
* 远程环境连接器 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/5/24 |
||||
*/ |
||||
public class HttpWorkspaceConnector implements WorkspaceConnector { |
||||
private static final HttpWorkspaceConnector INSTANCE = new HttpWorkspaceConnector(); |
||||
|
||||
public static HttpWorkspaceConnector getInstance() { |
||||
|
||||
return INSTANCE; |
||||
} |
||||
|
||||
@Override |
||||
public boolean testConnection(WorkspaceConnectionInfo connectionInfo) throws Exception { |
||||
LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); |
||||
return StringUtils.isNotEmpty(bean.getAccessToken()); |
||||
} |
||||
|
||||
@Override |
||||
public WorkspaceClient connect(WorkspaceConnectionInfo connectionInfo) throws Exception { |
||||
FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo); |
||||
LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); |
||||
WorkspaceConnection connection = new WorkspaceConnection( |
||||
UUID.randomUUID().toString(), |
||||
connectionInfo.getUserName(), |
||||
HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(), |
||||
InetAddress.getLocalHost().getHostAddress()); |
||||
client.updateConnection(connection); |
||||
client.startHeartBeat(); |
||||
return client; |
||||
} |
||||
|
||||
private LoginRequestInfoBean createLoginBean(WorkspaceConnectionInfo connectionInfo) { |
||||
LoginRequestInfoBean bean = new LoginRequestInfoBean(); |
||||
bean.setUsername(connectionInfo.getUserName()); |
||||
bean.setPassword(connectionInfo.getPassword()); |
||||
bean.setEncrypted(false); |
||||
return bean; |
||||
} |
||||
} |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.init; |
||||
|
||||
|
||||
import com.fanruan.carina.annotions.ActivatorRefer; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.init; |
||||
|
||||
import com.fanruan.carina.Carina; |
||||
import com.fanruan.carina.annotions.FineComponent; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.init; |
||||
|
||||
import com.fanruan.carina.Carina; |
||||
import com.fanruan.carina.annotions.DependsOn; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.init; |
||||
|
||||
|
||||
import com.fanruan.carina.annotions.ActivatorRefer; |
@ -0,0 +1,28 @@
|
||||
package com.fanruan.boot.pre; |
||||
|
||||
import com.fanruan.carina.annotions.FineComponent; |
||||
import com.fanruan.carina.annotions.Start; |
||||
import com.fanruan.config.ConfigProviderFactory; |
||||
import com.fanruan.config.impl.PublicConfigProviderImpl; |
||||
import com.fanruan.config.impl.ShareConfigProviderImpl; |
||||
import com.fanruan.config.realm.ConfigRealm; |
||||
import com.fanruan.config.realm.ConfigRepositoryFactory; |
||||
import com.fanruan.config.realm.mem.MemConfigRepositoryBuilder; |
||||
|
||||
/** |
||||
* 类解释注释 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/5/29 |
||||
*/ |
||||
@FineComponent(name = "design_universal_config") |
||||
public class DesignConfigComponent { |
||||
|
||||
@Start |
||||
public void start() { |
||||
ConfigProviderFactory.getInstance().registerProvider(ConfigRealm.SHARE, new ShareConfigProviderImpl()); |
||||
ConfigProviderFactory.getInstance().registerProvider(ConfigRealm.PUBLIC, new PublicConfigProviderImpl()); |
||||
ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new MemConfigRepositoryBuilder()); |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fanruan.boot.pre; |
||||
|
||||
import com.fanruan.boot.PluginComponent; |
||||
import com.fanruan.carina.annotions.DependsOn; |
||||
import com.fanruan.carina.annotions.FineComponent; |
||||
import com.fanruan.carina.annotions.Start; |
||||
import com.fanruan.carina.annotions.Supplemental; |
||||
|
||||
/** |
||||
* 类解释注释 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/5/31 |
||||
*/ |
||||
@FineComponent(name = "design_plugin_supplement") |
||||
@DependsOn(dependencies = {"design_tenant", "design_universal_config"}) |
||||
public class DesignPluginSupplementComponent extends PluginComponent { |
||||
|
||||
@Start |
||||
public void start() { |
||||
super.prepare(); |
||||
} |
||||
} |
@ -0,0 +1,151 @@
|
||||
package com.fanruan.boot.pre; |
||||
|
||||
import com.fanruan.boot.key.StartupArgsShell; |
||||
import com.fanruan.carina.Carina; |
||||
import com.fanruan.carina.annotions.DependsOn; |
||||
import com.fanruan.carina.annotions.FineComponent; |
||||
import com.fanruan.carina.annotions.Start; |
||||
import com.fanruan.carina.annotions.Supplemental; |
||||
import com.fanruan.carina.context.CarinaApplicationContext; |
||||
import com.fanruan.carina.lifecycle.bootstrap.BootstrapFactory; |
||||
import com.fanruan.carina.standard.PartitionManager; |
||||
import com.fanruan.carina.standard.PartitionManagerImpl; |
||||
import com.fr.base.StateHubContext; |
||||
import com.fr.base.function.UITerminator; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.deeplink.DeepLinkManager; |
||||
import com.fr.design.fun.OemProcessor; |
||||
import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; |
||||
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; |
||||
import com.fr.design.monitor.DesignerLifecycleMonitorContext; |
||||
import com.fr.design.ui.util.UIUtil; |
||||
import com.fr.design.utils.DesignUtils; |
||||
import com.fr.design.utils.DesignerPort; |
||||
import com.fr.event.Event; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.event.Listener; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.module.engine.event.LifecycleErrorEvent; |
||||
import com.fr.runtime.FineRuntime; |
||||
import com.fr.stable.lifecycle.FineLifecycleFatalError; |
||||
import com.fr.start.DesignContext; |
||||
import com.fr.start.DesignLauncher; |
||||
import com.fr.start.DesignerSubListener; |
||||
import com.fr.start.EmptyServletContext; |
||||
import com.fr.start.LifecycleFatalErrorHandler; |
||||
import com.fr.start.OemHandler; |
||||
import com.fr.start.SplashContext; |
||||
import com.fr.start.SplashStrategy; |
||||
import com.fr.start.common.SplashCommon; |
||||
import com.fr.start.preload.PreLoadService; |
||||
|
||||
import java.util.concurrent.CompletableFuture; |
||||
|
||||
/** |
||||
* 设计器启动前处理的模块入口 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/5/31 |
||||
*/ |
||||
@FineComponent(name = "design_pre_start") |
||||
@DependsOn(dependencies = {"design_universal_config", "design_tenant", "design_plugin_supplement"}) |
||||
public class DesignPreStartComponent { |
||||
|
||||
|
||||
|
||||
@Start |
||||
public void start() { |
||||
DesignerEnvManager.getEnvManager(); |
||||
|
||||
startPreload0(); |
||||
|
||||
DesignerLifecycleMonitorContext.getMonitor().beforeStart(); |
||||
//启动运行时
|
||||
FineRuntime.start(); |
||||
//等 FineRuntime 启动后启动
|
||||
DeepLinkManager.getInstance().start(Carina.getApplicationContext().singleton(StartupArgsShell.class).get().get()); |
||||
|
||||
startPreload1(); |
||||
|
||||
DesignerSubListener.getInstance().start(); |
||||
EventDispatcher.listen(LifecycleErrorEvent.SELF, new Listener<FineLifecycleFatalError>() { |
||||
@Override |
||||
public void on(Event event, FineLifecycleFatalError param) { |
||||
LifecycleFatalErrorHandler.getInstance().handle(param); |
||||
} |
||||
}); |
||||
|
||||
try { |
||||
BootstrapFactory.get().start("design_init"); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 在 {@link FineRuntime#start()} 运行后 |
||||
*/ |
||||
protected static void startPreload1() { |
||||
|
||||
CompletableFuture<Void> initLookAndFeel = CompletableFuture.runAsync(DesignUtils::initLookAndFeel); |
||||
PreLoadService.getInstance().addUIFuture(initLookAndFeel); |
||||
|
||||
showSplash(); |
||||
} |
||||
|
||||
/** |
||||
* 在 {@link FineRuntime#start()} 运行前 |
||||
*/ |
||||
protected static void startPreload0() { |
||||
|
||||
PreLoadService.getInstance().addRunnable(() -> { |
||||
if (DesignUtils.isPortOccupied()) { |
||||
UITerminator action = new UITerminator() { |
||||
@Override |
||||
protected void doRun() { |
||||
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.PORT_OCCUPIED.getId(), |
||||
DesignerErrorMessage.PORT_OCCUPIED.getMessage()); |
||||
DesignerPort.getInstance().resetPort(); |
||||
} |
||||
}; |
||||
action.run(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
private static void showSplash() { |
||||
|
||||
// 快快显示启动画面
|
||||
// vito: 这里必须用 wait, 不然会导致莫名其妙的问题
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
SplashContext.getInstance().registerSplash(createSplash()); |
||||
SplashContext.getInstance().show(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private static SplashStrategy createSplash() { |
||||
|
||||
OemProcessor oemProcessor = OemHandler.findOem(); |
||||
if (oemProcessor != null) { |
||||
SplashStrategy splashStrategy = null; |
||||
try { |
||||
splashStrategy = oemProcessor.createSplashStrategy(); |
||||
} catch (Throwable e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
if (splashStrategy != null) { |
||||
return splashStrategy; |
||||
} |
||||
} |
||||
|
||||
return new SplashCommon(); |
||||
} |
||||
|
||||
} |
@ -1,5 +1,6 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.boot.ConfConfigComponent; |
||||
import com.fanruan.carina.annotions.DependsOn; |
||||
import com.fanruan.carina.annotions.FineComponent; |
||||
import com.fanruan.carina.annotions.JPAEntityScan; |
@ -1,5 +1,6 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.boot.CoreSupplementalComponent; |
||||
import com.fanruan.carina.annotions.DependsOn; |
||||
import com.fanruan.carina.annotions.FineComponent; |
||||
import com.fanruan.carina.annotions.Start; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.carina.annotions.ActivatorRefer; |
||||
import com.fanruan.carina.annotions.FineComponent; |
@ -1,6 +1,7 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
|
||||
import com.fanruan.boot.LoggerComponent; |
||||
import com.fanruan.carina.annotions.DependsOn; |
||||
import com.fanruan.carina.annotions.FineComponent; |
||||
import com.fanruan.carina.annotions.Start; |
@ -1,5 +1,6 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.boot.PluginComponent; |
||||
import com.fanruan.carina.annotions.DependsOn; |
||||
import com.fanruan.carina.annotions.FineComponent; |
||||
import com.fanruan.carina.annotions.Start; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.carina.annotions.ActivatorRefer; |
||||
import com.fanruan.carina.annotions.DependsOn; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.carina.annotions.ActivatorRefer; |
||||
import com.fanruan.carina.annotions.DependsOn; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.carina.annotions.ActivatorRefer; |
||||
import com.fanruan.carina.annotions.DependsOn; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.carina.annotions.ActivatorRefer; |
||||
import com.fanruan.carina.annotions.DependsOn; |
@ -1,6 +1,7 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
|
||||
import com.fanruan.boot.DAOComponent; |
||||
import com.fanruan.carina.annotions.DependsOn; |
||||
import com.fanruan.carina.annotions.FineComponent; |
||||
import com.fanruan.carina.annotions.Start; |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.boot; |
||||
package com.fanruan.boot.show; |
||||
|
||||
import com.fanruan.carina.annotions.DependsOn; |
||||
import com.fanruan.carina.annotions.FineComponent; |
@ -1,58 +1,58 @@
|
||||
package com.fr.start.module.optimized; |
||||
|
||||
import com.fanruan.carina.Carina; |
||||
import com.fanruan.dao.shell.DBContextShell; |
||||
import com.fr.config.BaseDBEnv; |
||||
import com.fr.config.dao.DaoSelectorFactory; |
||||
import com.fr.config.dao.swicter.DaoSwitcher; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.event.Event; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.event.Listener; |
||||
import com.fr.event.Null; |
||||
import com.fr.exit.ConfigToPropMigrator; |
||||
import com.fr.stable.db.DBContext; |
||||
import com.fr.stable.db.tenant.TenantDBAdapter; |
||||
import com.fr.start.event.LazyStartupEvent; |
||||
import com.fr.start.server.EmbedServerEvent; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2022/3/7 |
||||
*/ |
||||
public class TenantDBAdapter4Designer extends TenantDBAdapter { |
||||
|
||||
@Override |
||||
public void start() { |
||||
BaseDBEnv.setDBContext((DBContext) Carina.getApplicationContext().singleton(DBContextShell.class).get()); |
||||
if (DaoSelectorFactory.getDaoSelector().useCacheDao()) { |
||||
listenEvent(LazyStartupEvent.INSTANCE, new Listener<Null>() { |
||||
@Override |
||||
public void on(Event event, Null param) { |
||||
TenantDBAdapter4Designer.super.start(); |
||||
afterStart(); |
||||
} |
||||
}); |
||||
|
||||
listenEvent(EmbedServerEvent.BeforeStart, new Listener<Null>() { |
||||
@Override |
||||
public void on(Event event, Null param) { |
||||
if (DaoSelectorFactory.getDaoSelector().useCacheDao()) { |
||||
EventDispatcher.fire(LazyStartupEvent.INSTANCE); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
} else { |
||||
super.start(); |
||||
} |
||||
} |
||||
|
||||
private void afterStart() { |
||||
DesignerEnvManager.getEnvManager().setPropertiesUsable(false); |
||||
DaoSwitcher.executeSwitch(); |
||||
ConfigToPropMigrator.getInstance().deletePropertiesCache(); |
||||
DesignerEnvManager.getEnvManager().saveXMLFile(); |
||||
} |
||||
} |
||||
//package com.fr.start.module.optimized;
|
||||
//
|
||||
//import com.fanruan.carina.Carina;
|
||||
//import com.fanruan.dao.shell.DBContextShell;
|
||||
//import com.fr.config.BaseDBEnv;
|
||||
//import com.fr.config.dao.DaoSelectorFactory;
|
||||
//import com.fr.config.dao.swicter.DaoSwitcher;
|
||||
//import com.fr.design.DesignerEnvManager;
|
||||
//import com.fr.event.Event;
|
||||
//import com.fr.event.EventDispatcher;
|
||||
//import com.fr.event.Listener;
|
||||
//import com.fr.event.Null;
|
||||
//import com.fr.exit.ConfigToPropMigrator;
|
||||
//import com.fr.stable.db.DBContext;
|
||||
//import com.fr.stable.db.tenant.TenantDBAdapter;
|
||||
//import com.fr.start.event.LazyStartupEvent;
|
||||
//import com.fr.start.server.EmbedServerEvent;
|
||||
//
|
||||
///**
|
||||
// * @author hades
|
||||
// * @version 11.0
|
||||
// * Created by hades on 2022/3/7
|
||||
// */
|
||||
//public class TenantDBAdapter4Designer extends TenantDBAdapter {
|
||||
//
|
||||
// @Override
|
||||
// public void start() {
|
||||
// BaseDBEnv.setDBContext((DBContext) Carina.getApplicationContext().singleton(DBContextShell.class).get());
|
||||
// if (DaoSelectorFactory.getDaoSelector().useCacheDao()) {
|
||||
// listenEvent(LazyStartupEvent.INSTANCE, new Listener<Null>() {
|
||||
// @Override
|
||||
// public void on(Event event, Null param) {
|
||||
// TenantDBAdapter4Designer.super.start();
|
||||
// afterStart();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// listenEvent(EmbedServerEvent.BeforeStart, new Listener<Null>() {
|
||||
// @Override
|
||||
// public void on(Event event, Null param) {
|
||||
// if (DaoSelectorFactory.getDaoSelector().useCacheDao()) {
|
||||
// EventDispatcher.fire(LazyStartupEvent.INSTANCE);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// } else {
|
||||
// super.start();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void afterStart() {
|
||||
// DesignerEnvManager.getEnvManager().setPropertiesUsable(false);
|
||||
// DaoSwitcher.executeSwitch();
|
||||
// ConfigToPropMigrator.getInstance().deletePropertiesCache();
|
||||
// DesignerEnvManager.getEnvManager().saveXMLFile();
|
||||
// }
|
||||
//}
|
||||
|
Loading…
Reference in new issue