Examples of Bindings


Examples of javax.script.Bindings

        configuration = new Configuration();
    }

    public Object eval(Reader reader, ScriptContext scriptContext)
            throws ScriptException {
        Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
        SlingScriptHelper helper = (SlingScriptHelper) bindings.get(SlingBindings.SLING);
        if (helper == null) {
            throw new ScriptException("SlingScriptHelper missing from bindings");
        }

        // ensure GET request
        if (!"GET".equals(helper.getRequest().getMethod())) {
            throw new ScriptException(
                "FreeMarker templates only support GET requests");
        }

        String scriptName = helper.getScript().getScriptResource().getPath();

        try {
            Template tmpl = new Template(scriptName, reader, configuration);
            bindings.put("currentNode", new NodeModel((Node) bindings.get("currentNode")));
            tmpl.process(bindings, scriptContext.getWriter());
        } catch (Throwable t) {
            log.error("Failure running Freemarker script.", t);
            throw new ScriptException("Failure running FreeMarker script "
                + scriptName);
View Full Code Here

Examples of javax.script.Bindings

  @Override
  public Object evaluate(ScriptSource script, Map<String, Object> arguments) {
    ScriptEngine engine = discoverEngine(script, arguments);

    Bindings bindings = (!CollectionUtils.isEmpty(arguments) ? new SimpleBindings(arguments) : null);

    try {
      return (bindings == null ? engine.eval(script.getScriptAsString()) : engine.eval(
          script.getScriptAsString(), bindings));
    } catch (IOException ex) {
View Full Code Here

Examples of javax.script.Bindings

        this.thymeleafScriptEngineFactory = thymeleafScriptEngineFactory;
    }

    @Override
    public Object eval(final Reader reader, final ScriptContext scriptContext) throws ScriptException {
        final Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
        final SlingScriptHelper helper = (SlingScriptHelper) bindings.get(SlingBindings.SLING);

        if (helper == null) {
            throw new ScriptException("SlingScriptHelper missing from bindings");
        }
View Full Code Here

Examples of javax.script.Bindings

    public void test() throws Exception {
        QueryBuilderBindingsValuesProvider provider = new QueryBuilderBindingsValuesProvider();
        QueryBuilder qb = mock(QueryBuilder.class);
        PrivateAccessor.setField(provider, "queryBuilder", qb);

        Bindings bindings = mock(Bindings.class);
        provider.addBindings(bindings);
        verify(bindings).put("queryBuilder", qb);
    }
View Full Code Here

Examples of lupos.datastructures.bindings.Bindings

        this.commentLabelElement.remove();
      }
      final Vector<Vector<String>> data = new Vector<Vector<String>>();
      final Vector<String> columnNames = new Vector<String>();
      if (stepContainer.getObject() instanceof Bindings) {
        final Bindings b = (Bindings) stepContainer.getObject();
        final Vector<String> columns = new Vector<String>();
        for (final Variable v : b.getVariableSet()) {
          columnNames.add(v.getName());
          columns.add(b.get(v).toString(
              this.operatorGraphViewer.getOperatorGraph()
              .getPrefix()));
        }
        data.add(columns);
        this.commentLabelElement = new CommentLabelElement(
View Full Code Here

Examples of net.tomp2p.connection.Bindings

    public static PeerDHT[] createNodesDHT(int nrOfPeers, Random rnd, int port, AutomaticFuture automaticFuture,
            boolean maintenance) throws Exception {
        if (nrOfPeers < 1) {
            throw new IllegalArgumentException("Cannot create less than 1 peer");
        }
        Bindings bindings = new Bindings();// .addInterface("lo");
        PeerDHT[] peers = new PeerDHT[nrOfPeers];
        final Peer master;
        if (automaticFuture != null) {
          Number160 peerId = new Number160(rnd);
          PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
View Full Code Here

Examples of org.erlide.util.erlang.Bindings

    private final IoRequestKind kind;
    private Charset encoding;

    public IoRequest(final OtpErlangTuple obj) {
        try {
            final Bindings b = OtpErlang.match(
                    "{Payload, Encoding, Leader, From, Tstamp}", obj);
            encoding = getEncoding(b.getAtom("Encoding"));

            final OtpErlangObject o = b.get("Payload");
            if (o instanceof OtpErlangString) {
                message = ((OtpErlangString) o).stringValue();
            } else if (o instanceof OtpErlangList) {
                final OtpErlangList l = (OtpErlangList) o;
                if (l.arity() == 0) {
                    message = "";
                } else {
                    try {
                        message = l.stringValue();
                    } catch (final Exception e) {
                        message = o.toString();
                    }
                }
            } else {
                message = o.toString();
            }
            message = convertEncoding(message, encoding);

            leader = b.getPid("Leader");
            final OtpErlangObject s = b.get("From");
            if (s instanceof OtpErlangPid) {
                sender = (OtpErlangPid) s;
            } else {
                sender = new OtpErlangPid("s", 0, 0, 0);
            }
View Full Code Here

Examples of org.erlide.util.erlang.Bindings

    public ErlEvent parse(final OtpErlangObject msg, final IOtpNodeProxy nodeProxy) {
        if (msg == null) {
            return null;
        }
        try {
            final Bindings b = OtpErlang.match("{event,Topic,Event,Sender}", msg);
            if (b == null) {
                return null;
            }
            final String topic = b.getAtom("Topic");
            final OtpErlangObject event = b.get("Event");
            final OtpErlangPid sender = b.getPid("Sender");
            return new ErlEvent(topic, nodeProxy, event, sender);
        } catch (final TermParserException e) {
            return null;
        } catch (final OtpErlangException e) {
            ErlLogger.warn("Unrecognized event: " + msg);
View Full Code Here

Examples of org.erlide.util.erlang.Bindings

    private OtpErlangObject processRequest(final OtpErlangPid from,
            final OtpErlangObject arequest) {
        if (callback == null) {
            return error;
        }
        Bindings b;
        try {
            if (arequest instanceof OtpErlangTuple) {
                final OtpErlangTuple request = (OtpErlangTuple) arequest;
                final String tag = ((OtpErlangAtom) request.elementAt(0)).atomValue();
                if ("put_chars".equals(tag)) {
                    b = OtpErlang.match("{put_chars, Chars}", request);
                    if (b != null) {
                        return callback.putChars(from, IOEncoding.latin1, b.get("Chars"));
                    }

                    b = OtpErlang.match("{put_chars, Enc:a, Chars}", request);
                    if (b != null) {
                        final String enc = b.getAtom("Enc");
                        return callback.putChars(from, IOEncoding.valueOf(enc),
                                b.get("Chars"));
                    }

                    b = OtpErlang.match("{put_chars, M:a, F:a, A}", request);
                    if (b != null) {
                        final String m = b.getAtom("M");
                        final String f = b.getAtom("F");
                        final Collection<OtpErlangObject> a = b.getList("A");
                        return callback.putChars(from, IOEncoding.latin1, m, f, a);
                    }

                    b = OtpErlang.match("{put_chars, Enc:a, M:a, F:a, A}", request);
                    if (b != null) {
                        final String enc = b.getAtom("Enc");
                        final String m = b.getAtom("M");
                        final String f = b.getAtom("F");
                        final Collection<OtpErlangObject> a = b.getList("A");
                        return callback.putChars(from, IOEncoding.valueOf(enc), m, f, a);
                    }
                    return error;
                } else if ("get_until".equals(tag)) {
                    b = OtpErlang.match("{get_until, Prompt}", request);
                    if (b != null) {
                        return callback.getUntil(IOEncoding.latin1, b.get("Prompt"));
                    }
                    b = OtpErlang.match("{get_until, Prompt, N:i}", request);
                    if (b != null) {
                        final long n = b.getLong("N");
                        return callback.getUntil(IOEncoding.latin1, b.get("Prompt"), n);
                    }
                    b = OtpErlang.match("{get_until, Enc:a, Prompt}", request);
                    if (b != null) {
                        final String enc = b.getAtom("Enc");
                        return callback
                                .getUntil(IOEncoding.valueOf(enc), b.get("Prompt"));
                    }
                    b = OtpErlang.match("{get_until, Enc:a, Prompt, N:i}", request);
                    if (b != null) {
                        final String enc = b.getAtom("Enc");
                        final long n = b.getLong("N");
                        return callback.getUntil(IOEncoding.valueOf(enc),
                                b.get("Prompt"), n);
                    }
                    b = OtpErlang.match("{get_until, Prompt, M:a, F:a, A}", request);
                    if (b != null) {
                        final String m = b.getAtom("M");
                        final String f = b.getAtom("F");
                        final Collection<OtpErlangObject> a = b.getList("A");
                        return callback.getUntil(IOEncoding.latin1, b.get("Prompt"), m,
                                f, a);
                    }
                    b = OtpErlang.match("{get_until, Enc: a, Prompt, M:a, F:a, A}",
                            request);
                    if (b != null) {
                        final String enc = b.getAtom("Enc");
                        final String m = b.getAtom("M");
                        final String f = b.getAtom("F");
                        final Collection<OtpErlangObject> a = b.getList("A");
                        return callback.getUntil(IOEncoding.valueOf(enc),
                                b.get("Prompt"), m, f, a);
                    }
                } else if ("requests".equals(tag)) {
                    b = OtpErlang.match("{requests, Reqs:lx}", request);
                    if (b != null) {
                        final Collection<OtpErlangObject> reqs = b.getList("Reqs");
                        OtpErlangObject val = null;
                        for (final OtpErlangObject r : reqs) {
                            val = processRequest(from, r);
                            if (val.equals(error)) {
                                return error;
                            }
                        }
                        return val == null ? error : val;
                    }
                } else if ("setopts".equals(tag)) {
                    b = OtpErlang.match("{setopts, Opts:lx}", request);
                    if (b != null) {
                        final Collection<OtpErlangObject> opts = b.getList("Opts");
                        return callback.setOpts(opts);
                    }
                } else if ("get_geometry".equals(tag)) {
                    return OtpErlang.mkTuple(new OtpErlangAtom("error"),
                            new OtpErlangAtom("enotsup"));
View Full Code Here

Examples of org.erlide.util.erlang.Bindings

        if (!event.getTopic().equals(getTopic())) {
            return;
        }
        final OtpErlangObject data = event.getEvent();
        try {
            final Bindings b = OtpErlang.match("{K:a,M}", data);
            final String kind = ((OtpErlangAtom) b.get("K")).atomValue();
            final OtpErlangObject amsg = b.get("M");
            ErlLogger.debug("%s: %s", kind, OtpErlang.asString(amsg));
        } catch (final Exception e) {
            ErlLogger.error("erroneous log msg: %s", data);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.