Java 8 Bindings - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Bindings class.

This code example shows how to use the following methods:put
        // prepare engine 
        StringWriter rawString = new StringWriter(); 
        PrintWriter rawOut = new PrintWriter(rawString);
        Exception ex = null;
        Bindings bindings = new BeanLookupBindings(appCtx);
        bindings.put("rawOut", rawOut);
        bindings.put("appCtx", appCtx);
         
        // evaluate and record any exception 
        try { 
            String script = FileUtils.readFileToString(actionFile);
            engine.eval(script, bindings);
        } catch (IOException e) {
            ex = e;
        } catch (ScriptException e) {
            ex = e;
        } catch (RuntimeException e) {
            ex = e;
        } finally { 
            // the script could create an object that persists and retains a reference to the Bindings 

6
CodeRank
This code example shows how to use the following methods:put
 
        String engineName = getEngine();
        ScriptEngine engine = ScriptUtils.getEngine(engineName);
 
        Bindings bindings = engine.createBindings();
        bindings.put("variation", variation);
        bindings.put("profile", profile);
        bindings.put("object", object);
 
        try { 
            return Boolean.TRUE.equals(engine.eval(getScript(), bindings));
 
        } catch (ScriptException ex) {
            throw new RuntimeException(String.format(
                    "Unable to evaluate [%s] script!", engineName), ex);
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:get, put
 
    /** 
     * {@inheritDoc} 
     */ 
    public void addBindings(final Bindings bindings) {
        final Resource resource = (Resource) bindings.get("resource");
        if (resource != null) {
            final Node node = resource.adaptTo(Node.class);
            if (node != null) { 
                bindings.put(PROP_CURRENT_NODE, node);
            } 
            if (bindings.get(PROP_CURRENT_SESSION) == null) {
                final Session session = resource.getResourceResolver().adaptTo(
                        Session.class);
                if (session != null) {
                    bindings.put(PROP_CURRENT_SESSION, session);
                } 
            } 
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:put
 
        String engineName = getEngine();
        ScriptEngine engine = ScriptUtils.getEngine(engineName);
 
        Bindings bindings = engine.createBindings();
        bindings.put("variation", variation);
        bindings.put("profile", profile);
        bindings.put("object", object);
 
        try { 
            engine.eval(getScript(), bindings);
        } catch (ScriptException ex) {
            throw new RuntimeException(String.format(
                    "Unable to evaluate [%s] script!", engineName), ex);
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:put
    public static List<String> getEvaluates() {
        return Imports.evaluates;
    } 
 
    public static Bindings getEvaluateBindings() throws IOException {
        Bindings bindings = new SimpleBindings();
        bindings.put(Imports.HDFS, FileSystem.get(new Configuration()));
        bindings.put(Imports.LOCAL, FileSystem.getLocal(new Configuration()));
        return bindings;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:put, remove
        addGlobalVariable("scriptResource", 
                "the ScriptResource implementing this page, which offers utility methods"); 
    } 
     
    public void bind(String name, Object obj) {
        bindings.put(name, obj);
    } 
    public Object unbind(String name) {
        return bindings.remove(name);
    } 
    public void execute(ScriptEngine eng, String script) {
        // TODO: update through setter rather than passing as method arguments? 
        this.eng = eng;
        this.script = script;
         
        bind("job", cj);
        rawString = new StringWriter();
        htmlString = new StringWriter();
        PrintWriter rawOut = new PrintWriter(rawString);
        PrintWriter htmlOut = new PrintWriter(htmlString);

6
CodeRank
This code example shows how to use the following methods:put
        } 
        if (bindings == null) {
            bindings = engine.createBindings();
        } 
        addBindings(bindings);
        return engine.eval(script, bindings);
    } 
 
    private void addBindings(Bindings bindings) {
        bindings.put("contentGraphProvider", cgProvider);
        bindings.put("contentHandler", contentHandler);
        bindings.put("tcManager", tcManager);
        bindings.put("parser", parser);
    } 
 
    private ScriptEngine getScriptEngine(String language, String languageVersion) {
        List<ScriptEngineFactory> factoryList = null;
 
        try { 
            factoryList = languageToFactoryMap.get(
6
CodeRank
This code example shows how to use the following methods:put
    public static List<String> getEvaluates() {
        return Imports.evaluates;
    } 
 
    public static Bindings getEvaluateBindings() throws IOException {
        Bindings bindings = new SimpleBindings();
        bindings.put(Imports.HDFS, FileSystem.get(new Configuration()));
        bindings.put(Imports.LOCAL, FileSystem.getLocal(new Configuration()));
        return bindings;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:put
    public AssertionResult getResult(SampleResult response) {
        AssertionResult result = new AssertionResult(getName());
        try { 
            ScriptEngine scriptEngine = getScriptEngine();
            Bindings bindings = scriptEngine.createBindings();
            bindings.put("SampleResult", response);
            bindings.put("AssertionResult", result);
            processFileOrScript(scriptEngine, bindings);
            result.setError(false);
        } catch (IOException e) {
            log.error("Problem in JSR223 script "+getName(), e);
            result.setError(true);
            result.setFailureMessage(e.toString());
        } catch (ScriptException e) {
            log.error("Problem in JSR223 script "+getName(), e);
            result.setError(true);
            result.setFailureMessage(e.toString());
        } 
        return result;
    } 
5
CodeRank
This code example shows how to use the following methods:put
    @Override 
    public void sampleOccurred(SampleEvent event) {
        try { 
            ScriptEngine scriptEngine = getScriptEngine();
            Bindings bindings = scriptEngine.createBindings();
            bindings.put("sampleEvent", event);
            bindings.put("sampleResult", event.getResult());
            processFileOrScript(scriptEngine, bindings);
        } catch (ScriptException e) {
            log.error("Problem in JSR223 script "+getName(), e);
        } catch (IOException e) {
            log.error("Problem in JSR223 script "+getName(), e);
        } 
    } 
 
    @Override 
    public void sampleStarted(SampleEvent e) {
        // NOOP 
    } 
 
5
CodeRank
See Code Examples for Java 8 Bindings Methods: