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