You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by sterg <st...@teiemt.gr> on 2017/01/24 15:22:46 UTC

timed interrupts for scripts in GroovyLab

Hi all,


finally I managed to have timed interrupted execution of scripts in 
GroovyLab, by adapting code from a Google search.


The following piece of code seems to make good work:


  if (GlobalValues.timedInterruptScriptingOn==true) {
      final Map<String, Object> timedInterruptAnnotationParams = new 
HashMap<>();
     timedInterruptAnnotationParams.put("value", 
GlobalValues.timedInterruptValue);
     timedInterruptAnnotationParams.put("unit", 
GeneralUtils.propX(GeneralUtils.classX(TimeUnit.class), 
TimeUnit.MILLISECONDS.toString()));


               ASTTransformationCustomizer  timedInterruptCustomizer = 
new ASTTransformationCustomizer(timedInterruptAnnotationParams, 
TimedInterrupt.class);

              cf.addCompilationCustomizers(timedInterruptCustomizer);
                  }




Thanks!


Best Regards

Stergios