// Path: headlands/src/main/java/com/airhacks/headlands/processors/boundary/EntryProcessorExecutor.java
// public class EntryProcessorExecutor {
// 
//     @Inject
//     Initializer discoverer;
// 
//     @Inject
//     NashornEngine engine;
// 
//     public Map<String, EntryProcessorResult<String>> execute(String cacheName,
//             String script, Set<String> keys, Set<String> arguments) {
//         Cache<String, String> cache = discoverer.getCache(cacheName);
//         if (cache == null) {
//             throw new IllegalArgumentException("Cache " + cacheName + " does not exist!");
//         }
//         Object[] args = arguments.toArray();
//         EntryProcessor<String, String, String> processor = engine.evalScript(script, EntryProcessor.class);
//         return cache.invokeAll(keys, processor, args);
//     }
// 
//     public boolean cacheExists(String name) {
//         return discoverer.cacheExists(name);
//     }
// 
// }


import com.airhacks.headlands.processors.boundary.EntryProcessorExecutor;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
package com.airhacks.headlands.engine.control;


/**
 *
 * @author airhacks.com
 */
public class NashornEngine {

    private Invocable invocable;
    private ScriptEngine scriptEngine;

    @PostConstruct
    public void initializeEngine() {
        ScriptEngineManager manager = new ScriptEngineManager();
        this.scriptEngine = manager.getEngineByName("javascript");
        this.invocable = (Invocable) scriptEngine;
    }

    public <T> T evalScript(String script, Class<T> interfaze) {
        try {
            this.scriptEngine.eval(script);
        } catch (ScriptException ex) {
// Path: headlands/src/main/java/com/airhacks/headlands/processors/boundary/EntryProcessorExecutor.java
// public class EntryProcessorExecutor {
// 
//     @Inject
//     Initializer discoverer;
// 
//     @Inject
//     NashornEngine engine;
// 
//     public Map<String, EntryProcessorResult<String>> execute(String cacheName,
//             String script, Set<String> keys, Set<String> arguments) {
//         Cache<String, String> cache = discoverer.getCache(cacheName);
//         if (cache == null) {
//             throw new IllegalArgumentException("Cache " + cacheName + " does not exist!");
//         }
//         Object[] args = arguments.toArray();
//         EntryProcessor<String, String, String> processor = engine.evalScript(script, EntryProcessor.class);
//         return cache.invokeAll(keys, processor, args);
//     }
// 
//     public boolean cacheExists(String name) {
//         return discoverer.cacheExists(name);
//     }
// 
// }


// Path: headlands/src/main/java/com/airhacks/headlands/engine/control/NashornEngine.java
import com.airhacks.headlands.processors.boundary.EntryProcessorExecutor;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

package com.airhacks.headlands.engine.control;


/**
 *
 * @author airhacks.com
 */
public class NashornEngine {

    private Invocable invocable;
    private ScriptEngine scriptEngine;

    @PostConstruct
    public void initializeEngine() {
        ScriptEngineManager manager = new ScriptEngineManager();
        this.scriptEngine = manager.getEngineByName("javascript");
        this.invocable = (Invocable) scriptEngine;
    }

    public <T> T evalScript(String script, Class<T> interfaze) {
        try {
            this.scriptEngine.eval(script);
        } catch (ScriptException ex) {
            Logger.getLogger(EntryProcessorExecutor.class.getName()).log(Level.SEVERE, null, ex);