View Javadoc

1   package delight.nashornsandbox;
2   
3   import java.util.concurrent.ExecutorService;
4   
5   @SuppressWarnings("all")
6   public interface NashornSandbox {
7     /**
8      * <p>Add a new class to the list of allowed classes.
9      * <p>WARNING: Adding a new class, AFTER a script has been evaluated, will destroy the engine and recreate it. The script context will thus be lost.
10     */
11    public abstract NashornSandbox allow(final Class<?> clazz);
12    
13    /**
14     * Sets the maximum CPU time in milliseconds allowed for script execution.
15     */
16    public abstract NashornSandbox setMaxCPUTime(final long limit);
17    
18    /**
19     * Specifies the executor service which is used to run scripts when a CPU time limit is specified.
20     */
21    public abstract NashornSandbox setExecutor(final ExecutorService executor);
22    
23    public abstract ExecutorService getExecutor();
24    
25    public abstract Object eval(final String js);
26  }