Package javax.script

Examples of javax.script.SimpleBindings


            Object result = null;

            String methodName = method.getName();
            if (methodName.equals(event)) {
                try {
                    SimpleBindings bindings = new SimpleBindings();
                    bindings.put(ARGUMENTS_KEY, args);
                    scriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
                    scriptEngine.eval(script);
                } catch (ScriptException exception) {
                    System.err.println(exception);
                    System.err.println(script);
View Full Code Here


                }

                Bindings bindings;
                if (element.parent.value instanceof ListenerList<?>) {
                    // Don't pollute the engine namespace with the listener functions
                    bindings = new SimpleBindings();
                } else {
                    bindings = scriptEngineManager.getBindings();
                }

                // Execute script
View Full Code Here

    private void init(ClassLoader loader) throws ScriptException {
        nameMap = new HashMap();
        extensionMap = new HashMap();
        mimetypeMap = new HashMap();
        globalMap = new SimpleBindings();
        try {
            factories =
                (HashSet<ScriptEngineFactory>) (new ServiceFinder(loader, service)).getServices();
            if (factories.isEmpty()) {
                System.err.println("no factory");
View Full Code Here

    public void setBindings(Bindings bindings, int scope) {
        context.setBindings(bindings, scope);
    }

    public Bindings createBindings() {
        return new SimpleBindings();
    }
View Full Code Here

    /**
     * Get the graphs list as a set of bindings.
     */
    public Bindings getGraphsAsBindings() {
        final Bindings bindings = new SimpleBindings();
        graphs.forEach(bindings::put);
        return bindings;
    }
View Full Code Here

    private final ConcurrentHashMap<String,Session> sessions;

    public Session(final String session, final Context context, final ConcurrentHashMap<String,Session> sessions) {
        logger.info("New session established for {}", session);
        this.session = session;
        this.bindings = new SimpleBindings();
        this.settings = context.getSettings();
        this.graphs = context.getGraphs();
        this.scheduledExecutorService = context.getScheduledExecutorService();
        this.sessions = sessions;
View Full Code Here

    }

    @Test
    public void shouldEvalScriptWithBindings() throws Exception {
        final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create();
        final Bindings b = new SimpleBindings();
        b.put("x", 1);
        assertEquals(2, gremlinExecutor.eval("1+x", b).get());
    }
View Full Code Here

        assertEquals(2, gremlinExecutor.eval("1+x", b).get());
    }

    @Test
    public void shouldEvalScriptWithGlobalBindings() throws Exception {
        final Bindings b = new SimpleBindings();
        b.put("x", 1);
        final GremlinExecutor gremlinExecutor = GremlinExecutor.build().globalBindings(b).create();
        assertEquals(2, gremlinExecutor.eval("1+x").get());
    }
View Full Code Here

        assertEquals(2, gremlinExecutor.eval("1+x").get());
    }

    @Test
    public void shouldEvalScriptWithGlobalAndLocalBindings() throws Exception {
        final Bindings g = new SimpleBindings();
        g.put("x", 1);
        final GremlinExecutor gremlinExecutor = GremlinExecutor.build().globalBindings(g).create();
        final Bindings b = new SimpleBindings();
        b.put("y", 1);
        assertEquals(2, gremlinExecutor.eval("y+x", b).get());
    }
View Full Code Here

        assertEquals(2, gremlinExecutor.eval("y+x", b).get());
    }

    @Test
    public void shouldEvalScriptWithLocalOverridingGlobalBindings() throws Exception {
        final Bindings g = new SimpleBindings();
        g.put("x", 1);
        final GremlinExecutor gremlinExecutor = GremlinExecutor.build().globalBindings(g).create();
        final Bindings b = new SimpleBindings();
        b.put("x", 10);
        assertEquals(11, gremlinExecutor.eval("x+1", b).get());
    }
View Full Code Here

TOP

Related Classes of javax.script.SimpleBindings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.