Browse Source

Pull request #15432: REPORT-140221 适配插件接口移动

Merge in DESIGN/design from ~DESTINY.LIN/design:fbp/feature to fbp/feature

* commit 'f5695dbbb565e1c780c8cc6d89f2340283033b85':
  无jira任务,修复打包
fbp/feature
Destiny.Lin-林锦龙 1 month ago
parent
commit
c0c46bceb0
  1. 2
      designer-realize/src/main/java/com/fanruan/boot/adaptation/ReportAdaptationComponent.java
  2. 42
      designer-realize/src/main/java/com/fanruan/boot/env/DesignCorePluginComponent.java
  3. 86
      designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java
  4. 2
      designer-realize/src/main/java/com/fanruan/boot/env/function/DesignUpdateComponent.java
  5. 3
      designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java

2
designer-realize/src/main/java/com/fanruan/boot/adaptation/ReportAdaptationComponent.java

@ -12,9 +12,9 @@ import com.fr.decision.ExtraDecisionClassManager;
import com.fr.decision.base.VirtualFilterChain;
import com.fr.decision.fun.EmbedRequestFilterProvider;
import com.fr.decision.fun.GlobalRequestFilterProvider;
import com.fr.decision.fun.PluginPortalModuleDevice;
import com.fr.decision.fun.SystemOptionProvider;
import com.fr.decision.plugin.PluginControllerManager;
import com.fr.decision.portal.PluginPortalModuleDevice;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;

42
designer-realize/src/main/java/com/fanruan/boot/env/DesignCorePluginComponent.java vendored

@ -1,42 +0,0 @@
package com.fanruan.boot.env;
import com.fanruan.boot.CorePluginComponent;
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.plugin.autonomy.AutonomyClassManagerGroup;
import com.fanruan.plugin.autonomy.AutonomyClassManagerProvider;
import com.fr.plugin.ExtraClassManager;
/**
* DesignCorePluginComponent
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/8/9
*/
@FineComponent(name = "design_plugin_core")
@DependsOn(dependencies = {"design_plugin"})
public class DesignCorePluginComponent extends CorePluginComponent {
/**
* prepare
*/
@Supplemental
public void supportFunctionDef() {
super.supportFunctionDef();
}
/**
* start
*/
@Start
public void start() {
/// 插件下沉不能直接调用fbp的逻辑,此时内置服务器未启动,一部分逻辑要拆到内置服务器启动的时候再做
// super.start();
}
}

86
designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java vendored

@ -7,15 +7,34 @@ import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start;
import com.fanruan.carina.annotions.Stop;
import com.fanruan.carina.annotions.Supplemental;
import com.fanruan.plugin.autonomy.AutonomyClassManagerFactory;
import com.fanruan.plugin.autonomy.AutonomyClassManagerGroup;
import com.fanruan.plugin.autonomy.AutonomyClassManagerProvider;
import com.fr.config.ConfigContext;
import com.fr.invoke.ClassFactory;
import com.fr.json.JSONObject;
import com.fr.plugin.ExtraClassManager;
import com.fr.plugin.beforeload.embed.PluginEmbedInfo;
import com.fr.plugin.config.PluginConfigContext;
import com.fr.plugin.injectable.PluginInjectionFilter;
import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.PluginSyncModuleType;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginListenerRegistration;
import com.fr.plugin.validate.PluginValidator;
import com.fr.stable.CommonUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.resource.ResourceLoader;
import com.fr.startup.web.annotation.MappingJackson2HttpMessageConverter;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.repository.plugin.PluginRepository;
import javax.servlet.ServletContext;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
@ -43,13 +62,35 @@ public class DesignPluginComponent extends PluginComponent {
*/
@Start
public void start() {
ExtraClassManager.getInstance().registerAutonomyClassManager(Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).getAll().toArray(new AutonomyClassManagerProvider[0]));
//收集插件对象的过滤器
Collection<PluginInjectionFilter> filters = Carina.getApplicationContext().group(PluginInjectionFilter.GroupKey.class).getAll();
for (PluginInjectionFilter filter: filters) {
PluginManager.addInjectionFilter(filter);
}
//装备外部的验证器
assembleValidator();
// 注册内置插件信息
registerEmbedPluginInfo();
// 注册插件配置类Provider
registerPluginConfigProvider();
AutonomyClassManagerFactory.getInstance().registerAutonomyClassManager(Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).getAll().toArray(new AutonomyClassManagerProvider[0]));
Supplier<List<JSONObject>> supplier = () -> PluginRepository.getInstance().getPluginStatus();
PluginManager.registerRemotePluginSupplier(supplier);
PluginManager.setSyncModuleType(PluginSyncModuleType.DESIGN);
//PluginManager要在环境切换和模块启动之前初始化
PluginManager.startEngine();
super.start();
PluginListenerRegistration.getInstance().listenRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
MappingJackson2HttpMessageConverter.KEY.refreshObjectMapper();
}
});
registerPluginClassFinder();
}
@Override
@ -57,6 +98,45 @@ public class DesignPluginComponent extends PluginComponent {
// do nothing
}
private void registerEmbedPluginInfo() {
Collection<PluginEmbedInfo> pluginEmbedInfos = Carina.getApplicationContext().group(PluginEmbedInfo.class).getAll();
PluginManager.getPluginEmbedManager().addPluginEmbedInfos(pluginEmbedInfos);
}
private void registerPluginConfigProvider() {
ConfigContext.setPluginConfigContextProvider(new PluginConfigContext());
}
private void assembleValidator() {
PluginManager.getValidatorManager().register(Carina.getApplicationContext().group(PluginValidator.GroupKey.class).getAll());
}
private void registerPluginClassFinder() {
ClassFactory.getInstance().addFinder(className -> {
//再找.
// alex:currentEnv可能是null
String envPath = WorkContext.getCurrent().getPath();
if (envPath == null) {
throw new ClassNotFoundException(className);
}
File clssesFile = new File(CommonUtils.pathJoin(envPath, ProjectConstants.CLASSES_NAME));
ClassLoader urlClassLoader;
try {
urlClassLoader = new URLClassLoader(new URL[]{clssesFile.toURI().toURL()}, CommonUtils.class.getClassLoader());
} catch (MalformedURLException malformedURLException) {
urlClassLoader = ClassLoader.getSystemClassLoader();
}
return Class.forName(className, true, urlClassLoader);
});
//从插件中拿
ClassFactory.getInstance().addFinder(ResourceLoader::classForName);
//从插件引擎中拿
ClassFactory.getInstance().addFinder(className -> Class.forName(className, true, PluginManager.getController().getClass().getClassLoader()));
}
/**
* stop
*/

2
designer-realize/src/main/java/com/fanruan/boot/env/function/DesignUpdateComponent.java vendored

@ -38,7 +38,7 @@ import java.util.List;
* Created on 2024/7/2
*/
@FineComponent(name = "design_function_update")
@DependsOn(dependencies = "design_plugin_core")
@DependsOn(dependencies = "design_plugin")
public class DesignUpdateComponent {
/**

3
designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java

@ -1,6 +1,5 @@
package com.fanruan.boot.init;
import com.fanruan.boot.ClassFindComponent;
import com.fanruan.boot.ExtraLocaleClassManager;
import com.fanruan.boot.key.StartupArgsShell;
import com.fanruan.carina.Carina;
@ -205,7 +204,7 @@ public class DesignPreLoadComponent {
ProjectConstants.CLASSES_NAME));
ClassLoader urlClassLoader;
try {
urlClassLoader = new URLClassLoader(new URL[]{clssesFile.toURI().toURL()}, ClassFindComponent.class.getClassLoader());
urlClassLoader = new URLClassLoader(new URL[]{clssesFile.toURI().toURL()}, DesignPreLoadComponent.class.getClassLoader());
} catch (MalformedURLException malformedURLException) {
urlClassLoader = ClassLoader.getSystemClassLoader();
}

Loading…
Cancel
Save