Browse Source

REPORT-114392 FR-FBP版本本地设计适配 去除支线且暂不支持的逻辑,保证测试

fbp-1.0
Destiny.Lin 6 months ago
parent
commit
7b222a8731
  1. 8
      designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java
  2. 128
      designer-realize/src/main/java/com/fanruan/boot/env/function/DesignAnalyzerComponent.java

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

@ -1,9 +1,13 @@
package com.fanruan.boot.env; package com.fanruan.boot.env;
import com.fanruan.boot.PluginComponent; import com.fanruan.boot.PluginComponent;
import com.fanruan.carina.Carina;
import com.fanruan.carina.annotions.DependsOn; import com.fanruan.carina.annotions.DependsOn;
import com.fanruan.carina.annotions.FineComponent; import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start; import com.fanruan.carina.annotions.Start;
import com.fanruan.plugin.autonomy.AutonomyClassManagerGroup;
import com.fanruan.plugin.autonomy.AutonomyClassManagerProvider;
import com.fr.plugin.ExtraClassManager;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
@ -23,7 +27,9 @@ public class DesignPluginComponent extends PluginComponent {
*/ */
@Start @Start
public void start() { public void start() {
super.start(); // 暂不启动,预留接口
ExtraClassManager.getInstance().registerAutonomyClassManager(Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).getAll().toArray(new AutonomyClassManagerProvider[0]));
} }
@Override @Override

128
designer-realize/src/main/java/com/fanruan/boot/env/function/DesignAnalyzerComponent.java vendored

@ -65,41 +65,41 @@ public class DesignAnalyzerComponent extends ResourceAffiliate {
*/ */
@Start @Start
public void start() { public void start() {
/// 埋点分析模块等fbp那边把逻辑理顺了再加上去
OptimizeUtil.open(OptimizeUtil.Module.ANALYZER,() -> { // OptimizeUtil.open(OptimizeUtil.Module.ANALYZER,() -> {
//
AnalyzerAssemblyFactory basicFactory = createBasicFactory(); // AnalyzerAssemblyFactory basicFactory = createBasicFactory();
//
// 兼容逻辑 // // 兼容逻辑
List<AnalyzerConfiguration> backwardsConfigurations = new ArrayList<>(Carina.getApplicationContext().group(AnalyzerKey.class).getAll()); // List<AnalyzerConfiguration> backwardsConfigurations = new ArrayList<>(Carina.getApplicationContext().group(AnalyzerKey.class).getAll());
if (!CollectionUtils.isEmpty(backwardsConfigurations)) { // if (!CollectionUtils.isEmpty(backwardsConfigurations)) {
// 直接初始化,不添加默认值,防止和下面的冲突 // // 直接初始化,不添加默认值,防止和下面的冲突
FineAnalyzer.initDirectly(FineAssist.findInstrumentation(), basicFactory, backwardsConfigurations.toArray(new AnalyzerConfiguration[0])); // FineAnalyzer.initDirectly(FineAssist.findInstrumentation(), basicFactory, backwardsConfigurations.toArray(new AnalyzerConfiguration[0]));
} // }
//
// 等页面完全打开后,再进行 retransform, 别影响了启动速度 // // 等页面完全打开后,再进行 retransform, 别影响了启动速度
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() { // EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
//
@Override // @Override
public void on(Event event, Null param) { // public void on(Event event, Null param) {
//
ExecutorService es = newSingleThreadExecutor(new NamedThreadFactory("designer-analyzer", true)); // ExecutorService es = newSingleThreadExecutor(new NamedThreadFactory("designer-analyzer", true));
try { // try {
// 加入 retransform 部分的逻辑 // // 加入 retransform 部分的逻辑
List<FineAdviceAssistant> adviceConfigurations = new ArrayList<>(Carina.getApplicationContext().group(AnalyzerAdviceKey.class).getAll()); // List<FineAdviceAssistant> adviceConfigurations = new ArrayList<>(Carina.getApplicationContext().group(AnalyzerAdviceKey.class).getAll());
//
if (!CollectionUtils.isEmpty(adviceConfigurations)) { // if (!CollectionUtils.isEmpty(adviceConfigurations)) {
AnalyzerConfiguration[] configurations = convertConfigurations(adviceConfigurations); // AnalyzerConfiguration[] configurations = convertConfigurations(adviceConfigurations);
es.submit(() -> { // es.submit(() -> {
DesignerAnalyzer.init(basicFactory, configurations); // DesignerAnalyzer.init(basicFactory, configurations);
}); // });
} // }
} finally { // } finally {
es.shutdown(); // es.shutdown();
} // }
} // }
}); // });
}); // });
} }
@NotNull @NotNull
@ -116,35 +116,37 @@ public class DesignAnalyzerComponent extends ResourceAffiliate {
*/ */
@Supplemental @Supplemental
public void prepare() { public void prepare() {
Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
ElementMatchers.isAnnotatedWith(Focus.class),
FocusAdvice.class
));
Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
ElementMatchers.isAnnotatedWith(Compute.class),
MonitorAdvice.class
));
Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
ElementMatchers.isAnnotatedWith(DBMetrics.class),
DBMonitorAdvice.class
));
Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
ElementMatchers.isAnnotatedWith(PerformancePoint.class),
PerformancePointAdvice.class
));
Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
ElementMatchers.isAnnotatedWith(FaultTolerance.class),
FaultToleranceAdvice.class
));
// 保持M1 可用
Carina.getApplicationContext().group(AnalyzerKey.class).add(AnalyzerConfiguration.create((builder, typeDescription, classLoader, module) -> builder
.method(ElementMatchers.isAnnotatedWith(Collect.class))
.intercept(MethodDelegation.to(CollectInterceptor.class))));
Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create( /// 埋点分析模块等fbp那边把逻辑理顺了再加上去
ElementMatchers.isAnnotatedWith(Collect.class), // Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
CollectAdvice.class // ElementMatchers.isAnnotatedWith(Focus.class),
)); // FocusAdvice.class
// ));
// Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
// ElementMatchers.isAnnotatedWith(Compute.class),
// MonitorAdvice.class
// ));
// Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
// ElementMatchers.isAnnotatedWith(DBMetrics.class),
// DBMonitorAdvice.class
// ));
// Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
// ElementMatchers.isAnnotatedWith(PerformancePoint.class),
// PerformancePointAdvice.class
// ));
// Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
// ElementMatchers.isAnnotatedWith(FaultTolerance.class),
// FaultToleranceAdvice.class
// ));
// // 保持M1 可用
// Carina.getApplicationContext().group(AnalyzerKey.class).add(AnalyzerConfiguration.create((builder, typeDescription, classLoader, module) -> builder
// .method(ElementMatchers.isAnnotatedWith(Collect.class))
// .intercept(MethodDelegation.to(CollectInterceptor.class))));
//
// Carina.getApplicationContext().group(AnalyzerAdviceKey.class).add(FineAdviceAssistant.create(
// ElementMatchers.isAnnotatedWith(Collect.class),
// CollectAdvice.class
// ));
} }

Loading…
Cancel
Save