Package jdk.nashorn.api.scripting

Examples of jdk.nashorn.api.scripting.ScriptObjectMirror


     */
    void init() {
        try {
            if(Logger.isDebugEnabled()) Logger.debug("Initializing prelude");
            // get access to prelude and save mirror.
            ScriptObjectMirror mirror = (ScriptObjectMirror)mEngine.eval(ResLoader.jsPrelude());
            mRootAccess = mirror;
            mMapper.setMirror(mRootAccess);
        } catch (ScriptException e){
            //fixme this should never throw
            throw new RuntimeException(e);
View Full Code Here


     * @return
     * @throws ScriptEvalException
     */
    ScriptResult eval(ScriptCall call) throws ScriptEvalException{
        try {
            ScriptObjectMirror moduleRef = getModule(call);

            if (call.event == null) {
                return null;
            }

View Full Code Here


    public Object require(String name) {
        if (Logger.isTraceEnabled()) Logger.trace("Required: %s",name);
        syncCache();
        ScriptObjectMirror cached = cachedModules.get(name);
        if (cached == null) {
            try {
                cached = loadModule(name);
            } catch (com.baasbox.dao.exception.ScriptException e) {
                throw new RuntimeException(e);
View Full Code Here

        ODocument doc = ScriptingService.get(name,true,true);
        if (doc == null){
            return null;
        }
        ScriptCall req=ScriptCall.require(doc);
        ScriptObjectMirror mirror = makeModule(req.scriptName, req.source);
        mirror=compileModule(mirror);
        return mirror;
    }
View Full Code Here

        if (source == null){
            Logger.warn("Module not found");
            return null;
        } else {
            Logger.trace("Module loading");
            ScriptObjectMirror mirror = makeModule(name, source);
            Logger.trace("ModuleReady");
            mirror=compileModule(mirror);
            return mirror;
        }
    }
View Full Code Here

    }

    private ScriptObjectMirror getModule(ScriptCall call) {
        syncCache();

        ScriptObjectMirror cached = cachedModules.get(call.scriptName);
        if (cached == null){
            if (Logger.isTraceEnabled()) Logger.trace("Loading module: %s",call.scriptName);
            cached = makeModule(call.scriptName,call.source);
            cached = compileModule(cached);
            if(Logger.isTraceEnabled()) Logger.trace("Module compiled: %s",call.scriptName);
View Full Code Here

     * @param id
     * @param sourceCode
     * @return
     */
    private ScriptObjectMirror makeModule(String id,String sourceCode){
        ScriptObjectMirror o =(ScriptObjectMirror) mRootAccess.callMember(MAKE_MODULE_FUNCTION, id, sourceCode);
        return o;
    }
View Full Code Here

        Product product = new Product();
        product.setName("Rubber");
        product.setPrice(1.99);
        product.setStock(1337);

        ScriptObjectMirror result = (ScriptObjectMirror)
                invocable.invokeFunction("calculate", product);
        System.out.println(result.get("name") + ": " + result.get("valueOfGoods"));
    }
View Full Code Here

        try {
            scriptEngine.eval(new InputStreamReader(sourceMap
            .openConnection().getInputStream()));
            scriptEngine.eval(new InputStreamReader(env.openConnection()
            .getInputStream()));
            ScriptObjectMirror lessenv = (ScriptObjectMirror) scriptEngine.get("lessenv");
            lessenv.put("charset", options.getCharset());
            lessenv.put("css", options.isCss());
            lessenv.put("lineNumbers", options.getLineNumbers());
            lessenv.put("optimization", options.getOptimization());
            lessenv.put("sourceMap", options.isSourceMap());
            lessenv.put("sourceMapRootpath", options.getSourceMapRootpath());
            lessenv.put("sourceMapBasepath", options.getSourceMapBasepath());
            lessenv.put("sourceMapURL", options.getSourceMapUrl());
            lessenv.put("loader", loader);
            lessenv.put("paths", options.getPaths());
            scriptEngine.eval(new InputStreamReader(less
            .openConnection().getInputStream()));
            scriptEngine.eval(new InputStreamReader(cssmin.openConnection()
            .getInputStream()));       
            scriptEngine.eval(new InputStreamReader(engine.openConnection()
View Full Code Here

TOP

Related Classes of jdk.nashorn.api.scripting.ScriptObjectMirror

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.