Package org.jaggeryjs.scriptengine.exceptions

Examples of org.jaggeryjs.scriptengine.exceptions.ScriptException


    public Object eval(Reader scriptReader, ScriptableObject scope, ScriptCachingContext sctx)
            throws ScriptException {
        if (scope == null) {
            String msg = "ScriptableObject value for scope, can not be null.";
            log.error(msg);
            throw new ScriptException(msg);
        }
        return evalScript(scriptReader, scope, sctx);
    }
View Full Code Here


    public void exec(Reader scriptReader, ScriptableObject scope, ScriptCachingContext sctx)
            throws ScriptException {
        if (scope == null) {
            String msg = "ScriptableObject value for scope, can not be null.";
            log.error(msg);
            throw new ScriptException(msg);
        }
        execScript(scriptReader, scope, sctx);
    }
View Full Code Here

    public Object call(Reader scriptReader, String funcName, Object[] args, ScriptableObject thiz,
                       ScriptCachingContext sctx) throws ScriptException {
        if (thiz == null) {
            String msg = "ScriptableObject value for thiz, can not be null.";
            log.error(msg);
            throw new ScriptException(msg);
        }
        return execFunc(scriptReader, funcName, args, thiz, getRuntimeScope(), sctx);
    }
View Full Code Here

    public Object call(Reader scriptReader, String funcName, Object[] args, ScriptableObject thiz,
                       ScriptableObject scope, ScriptCachingContext sctx) throws ScriptException {
        if (scope == null) {
            String msg = "ScriptableObject value for scope, can not be null.";
            log.error(msg);
            throw new ScriptException(msg);
        }
        if (thiz == null) {
            String msg = "ScriptableObject value for thiz, can not be null.";
            log.error(msg);
            throw new ScriptException(msg);
        }
        return execFunc(scriptReader, funcName, args, thiz, scope, sctx);
    }
View Full Code Here

                }
                script.exec(cx, scope);
            }
            return execFunc(funcName, args, thiz, scope, cx);
        } catch (Exception e) {
            throw new ScriptException(e);
        } finally {
            exitContext();
        }
    }
View Full Code Here

                                   ScriptableObject scope, Context cx) throws ScriptException {
        Object object = scope.get(funcName, scope);
        if (!(object instanceof Function)) {
            String msg = "Function cannot be found with the name '" + funcName + "', but a " + object.toString();
            log.error(msg);
            throw new ScriptException(msg);
        }
        try {
            return ((Function) object).call(cx, scope, thiz, args);
        } catch (Exception e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

                }
                result = script.exec(cx, scope);
            }
            return result;
        } catch (Exception e) {
            throw new ScriptException(e);
        } finally {
            exitContext();
        }
    }
View Full Code Here

                }
                script.exec(cx, scope);
            }
            return scope;
        } catch (Exception e) {
            throw new ScriptException(e);
        } finally {
            exitContext();
        }
    }
View Full Code Here

        String moduleId = (String) args[0];
        int dotIndex = moduleId.lastIndexOf(".");
        if (moduleId.length() == dotIndex + 1) {
            String msg = "Invalid file path for require method : " + moduleId;
            log.error(msg);
            throw new ScriptException(msg);
        }

        JaggeryContext jaggeryContext = CommonManager.getJaggeryContext();
        Map<String, ScriptableObject> requiredModules = (Map<String, ScriptableObject>) jaggeryContext.getProperty(
                Constants.JAGGERY_REQUIRED_MODULES);
        ScriptableObject object = requiredModules.get(moduleId);
        if (object != null) {
            return object;
        }

        if (dotIndex == -1) {
            object = CommonManager.require(cx, thisObj, args, funObj);
            initModule(cx, jaggeryContext, moduleId, object);
        } else {
            object = (ScriptableObject) cx.newObject(thisObj);
            object.setPrototype(thisObj);
            object.setParentScope(thisObj);
            //sharedJaggeryContext((ServletContext) jaggeryContext.getProperty(Constants.SERVLET_CONTEXT)).getScope()
            //object.setParentScope(sharedJaggeryContext((ServletContext) jaggeryContext.getProperty(Constants.SERVLET_CONTEXT)).getScope());
            String ext = moduleId.substring(dotIndex + 1);
            if (ext.equalsIgnoreCase("json")) {
                object = executeScript(jaggeryContext, object, moduleId, true, true, false);
            } else if (ext.equalsIgnoreCase("js")) {
                object = executeScript(jaggeryContext, object, moduleId, false, true, false);
            } else if (ext.equalsIgnoreCase("jag")) {
                object = executeScript(jaggeryContext, object, moduleId, false, false, false);
            } else {
                String msg = "Unsupported file type for require() method : ." + ext;
                log.error(msg);
                throw new ScriptException(msg);
            }
        }
        requiredModules.put(moduleId, object);
        return object;
    }
View Full Code Here

        try {
            URL scriptUrl = context.getResource(canonicalURI(scriptPath));
            if (scriptUrl == null) {
                String msg = "Requested resource " + scriptPath + " cannot be found";
                log.error(msg);
                throw new ScriptException(msg);
            }
            uc = scriptUrl.openConnection();
            if (uc instanceof JarURLConnection) {
                result = ((JarURLConnection) uc).getJarEntry().getTime();
            } else {
View Full Code Here

TOP

Related Classes of org.jaggeryjs.scriptengine.exceptions.ScriptException

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.