@@ -23,18 +23,20 @@ public void runWithOnlyReflects(App app) {
2323 ParameterImplementor implementor = new ParameterImplementor (method .getParameters ());
2424 implementor .matchArgumentsOnlyReflect (app );
2525 try {
26- implementor .invoke (SystenInstanceRecord .getInstance (method .getDeclaringClass ()), method );
26+ implementor .invoke (SystemInstanceRecord .getInstance (method .getDeclaringClass ()), method );
2727 } catch (Exception e ) {
2828 e .printStackTrace ();
2929 }
3030 }
3131 }
3232
33- public void run (App app ) {
33+ public CompletableFuture <?> run (App app ) {
3434 if (Objects .isNull (app .table )) {
35- return ;
35+ return CompletableFuture . completedFuture ( null ) ;
3636 }
3737
38+ List <CompletableFuture <?>> futureList = new ArrayList <>();
39+
3840 for (Method system : this .systems ) {
3941 SystemConfig sysConfig = configRecord .get (system );
4042
@@ -48,23 +50,26 @@ public void run(App app) {
4850 implementor .matchArguments (app , row .getRowId ());
4951 try {
5052 if (sysConfig .asynchronous ()) {
51- CompletableFuture .supplyAsync (() -> {
53+ var future = CompletableFuture .supplyAsync (() -> {
5254 try {
53- return implementor .invoke (SystenInstanceRecord .getInstance (system .getDeclaringClass ()), system );
55+ return implementor .invoke (SystemInstanceRecord .getInstance (system .getDeclaringClass ()), system );
5456 } catch (Exception e ) {
5557 e .printStackTrace ();
5658 return null ;
5759 }
5860 });
61+
62+ futureList .add (future );
5963 } else {
60- implementor .invoke (SystenInstanceRecord .getInstance (system .getDeclaringClass ()), system );
64+ implementor .invoke (SystemInstanceRecord .getInstance (system .getDeclaringClass ()), system );
6165 }
62- Logger .info ("tick" , FontColors .GREEN , "system: " + system .getName ());
6366 } catch (Exception e ) {
6467 Logger .info ("tick" , FontColors .RED , "system failed: " + system .getName ());
6568 }
6669 }
6770 }
71+
72+ return CompletableFuture .allOf (futureList .toArray (new CompletableFuture [0 ]));
6873 }
6974
7075 public void addSystem (Method system ) {
0 commit comments