File tree Expand file tree Collapse file tree 3 files changed +30
-6
lines changed
src/main/java/org/scijava Expand file tree Collapse file tree 3 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -55,15 +55,17 @@ public class CommandCodeRunner extends AbstractCodeRunner {
5555 // -- CodeRunner methods --
5656
5757 @ Override
58- public void run (final Object code , final Object ... args ) {
59- commandService .run (getCommandClass (code ), true , args );
58+ public void run (final Object code , final Object ... args )
59+ throws InvocationTargetException
60+ {
61+ waitFor (commandService .run (getCommandClass (code ), true , args ));
6062 }
6163
6264 @ Override
6365 public void run (final Object code , final Map <String , Object > inputMap )
6466 throws InvocationTargetException
6567 {
66- commandService .run (getCommandClass (code ), true , inputMap );
68+ waitFor ( commandService .run (getCommandClass (code ), true , inputMap ) );
6769 }
6870
6971 // -- Typed methods --
Original file line number Diff line number Diff line change @@ -57,15 +57,17 @@ public class ModuleCodeRunner extends AbstractCodeRunner {
5757 // -- CodeRunner methods --
5858
5959 @ Override
60- public void run (final Object code , final Object ... args ) {
61- moduleService .run (getModuleInfo (code ), true , args );
60+ public void run (final Object code , final Object ... args )
61+ throws InvocationTargetException
62+ {
63+ waitFor (moduleService .run (getModuleInfo (code ), true , args ));
6264 }
6365
6466 @ Override
6567 public void run (final Object code , final Map <String , Object > inputMap )
6668 throws InvocationTargetException
6769 {
68- moduleService .run (getModuleInfo (code ), true , inputMap );
70+ waitFor ( moduleService .run (getModuleInfo (code ), true , inputMap ) );
6971 }
7072
7173 // -- Typed methods --
Original file line number Diff line number Diff line change 3131
3232package org .scijava .run ;
3333
34+ import java .lang .reflect .InvocationTargetException ;
35+ import java .util .concurrent .ExecutionException ;
36+ import java .util .concurrent .Future ;
37+
3438import org .scijava .plugin .AbstractHandlerPlugin ;
3539
3640/**
@@ -49,4 +53,20 @@ public Class<Object> getType() {
4953 return Object .class ;
5054 }
5155
56+ // -- Internal methods --
57+
58+ protected <T > T waitFor (final Future <T > future )
59+ throws InvocationTargetException
60+ {
61+ try {
62+ return future .get ();
63+ }
64+ catch (final InterruptedException exc ) {
65+ throw new InvocationTargetException (exc );
66+ }
67+ catch (final ExecutionException exc ) {
68+ throw new InvocationTargetException (exc );
69+ }
70+ }
71+
5272}
You can’t perform that action at this time.
0 commit comments