Package org.jaggeryjs.jaggery.core

Examples of org.jaggeryjs.jaggery.core.ScriptReader


            jaggeryContext.addProperty(CommonManager.JAGGERY_OUTPUT_STREAM, System.out);
         
          RhinoEngine.putContextProperty("jaggeryContext", jaggeryContext);

            //Parsing the script
          final Reader source = new ScriptReader(new BufferedInputStream(fstream));
            out.println("\n");
            ShellUtilityService.initializeUtilityServices();
            engine.exec(source, scope, null);
            ShellUtilityService.destroyUtilityServices();
            out.flush();
View Full Code Here


        }
        if (isIncludeOnce && includedScripts.get(fileURL) != null) {
            return scope;
        }

        ScriptReader source;
        RhinoEngine engine = jaggeryContext.getEngine();
        if (isBuilt) {
            source = new ScriptReader(context.getResourceAsStream(fileURL)) {
                @Override
                protected void build() throws IOException {
                    try {
                        if (isJSON) {
                            sourceReader = new StringReader("(" + HostObjectUtil.streamToString(sourceIn) + ")");
                        } else {
                            sourceReader = new StringReader(HostObjectUtil.streamToString(sourceIn));
                        }
                    } catch (ScriptException e) {
                        throw new IOException(e);
                    }
                }
            };
        } else {
            source = new ScriptReader(context.getResourceAsStream(fileURL));
        }

        ScriptCachingContext sctx = new ScriptCachingContext(jaggeryContext.getTenantId(), keys[0], keys[1], keys[2]);
        sctx.setSecurityDomain(new JaggerySecurityDomain(fileURL, context));
        long lastModified = WebAppManager.getScriptLastModified(context, fileURL);
View Full Code Here

                            }
                            String path = (String) script;
                            path = path.startsWith("/") ? path : "/" + path;
                            Stack<String> callstack = CommonManager.getCallstack(sharedContext);
                            callstack.push(path);
                            engine.exec(new ScriptReader(servletContext.getResourceAsStream(path)) {
                                @Override
                                protected void build() throws IOException {
                                    try {
                                        sourceReader = new StringReader(HostObjectUtil.streamToString(sourceIn));
                                    } catch (ScriptException e) {
                                        throw new IOException(e);
                                    }
                                }
                            }, sharedScope, null);
                            callstack.pop();
                        }
                    }
                }
            }

            Object serveFunction = request.getServletContext().getAttribute(SERVE_FUNCTION_JAGGERY);
            if (serveFunction != null) {
                Function function = (Function) serveFunction;
                ScriptableObject scope = context.getScope();
                function.call(cx, scope, scope, new Object[]{
                        scope.get("request", scope),
                        scope.get("response", scope),
                        scope.get("session", scope)
                });
            } else {
                //resource rendering model proceeding
                sourceIn = request.getServletContext().getResourceAsStream(scriptPath);
                if (sourceIn == null) {
                    response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI());
                    return;
                }
                CommonManager.getInstance().getEngine()
                        .exec(new ScriptReader(sourceIn), context.getScope(),
                                getScriptCachingContext(request, scriptPath));
            }
        } catch (ScriptException e) {
            String msg = e.getMessage();
            log.error(msg, e);
View Full Code Here

        RhinoEngine.defineProperty(clonedScope, session);

        for (Object jsListener : jsListeners) {
            CommonManager.getCallstack(context).push((String) jsListener);
            try {
                ScriptReader sr = new ScriptReader(ctx.getResourceAsStream((String) jsListener)) {
                    @Override
                    protected void build() throws IOException {
                        try {
                            sourceReader = new StringReader(HostObjectUtil.streamToString(sourceIn));
                        } catch (ScriptException e) {
View Full Code Here

        RhinoEngine.defineProperty(clonedScope, session);

        for (Object jsListener : jsListeners) {
            CommonManager.getCallstack(context).push((String) jsListener);
            try {
                ScriptReader sr = new ScriptReader(ctx.getResourceAsStream((String) jsListener)) {
                    @Override
                    protected void build() throws IOException {
                        try {
                            sourceReader = new StringReader(HostObjectUtil.streamToString(sourceIn));
                        } catch (ScriptException e) {
View Full Code Here

                    callstack.push(path);
                    String[] parts = WebAppManager.getKeys(servletContext.getContextPath(), path, path);
                    ScriptCachingContext sctx = new ScriptCachingContext(sharedContext.getTenantId(),
                            parts[0], parts[1], parts[2]);
                    sctx.setSecurityDomain(new JaggerySecurityDomain(path, servletContext));
                    engine.exec(new ScriptReader(servletContext.getResourceAsStream(path)) {
                        @Override
                        protected void build() throws IOException {
                            try {
                                sourceReader = new StringReader(HostObjectUtil.streamToString(sourceIn));
                            } catch (ScriptException e) {
View Full Code Here

        }
        fileURL = FilenameUtils.normalize(fileURL);
        if (includesCallstack.search(fileURL) != -1) {
            return;
        }
        ScriptReader source = null;
        try {
            source = new ScriptReader(new FileInputStream(fileURL));
            includedScripts.put(fileURL, true);
            includesCallstack.push(fileURL);
            engine.exec(source, scope, null);
            includesCallstack.pop();
        } catch (FileNotFoundException e) {
View Full Code Here

        if (includedScripts.get(fileURL) != null) {
            return;
        }

        try {
            ScriptReader source = new ScriptReader(new FileInputStream(fileURL));
            includedScripts.put(fileURL, true);
            includesCallstack.push(fileURL);
            engine.exec(source, scope, null);
            includesCallstack.pop();
        } catch (FileNotFoundException e) {
View Full Code Here

                fileURL = parent + fileURL;
            }
            if (includesCallstack.search(fileURL) != -1) {
                return;
            }
            ScriptReader source;
            ScriptableObject scope;
            if (argsCount == 2) {
                scope = (ScriptableObject) args[1];
            } else {
                scope = jaggeryContext.getScope();
            }
            //this is a remote file url
            try {
                URL url = new URL(fileURL);
                url.openConnection();
                source = new ScriptReader(url.openStream());
                includedScripts.put(fileURL, true);
                includesCallstack.push(fileURL);
                engine.exec(source, scope, null);
                includesCallstack.pop();
            } catch (MalformedURLException e) {
View Full Code Here

            Map<String, Boolean> includedScripts = getIncludes(jaggeryContext);
            if (includedScripts.get(fileURL)) {
                return;
            }

            ScriptReader source;
            ScriptableObject scope;
            if (argsCount == 2) {
                scope = (ScriptableObject) args[1];
            } else {
                scope = jaggeryContext.getScope();
            }
            //this is a remote file url
            try {
                URL url = new URL(fileURL);
                url.openConnection();
                source = new ScriptReader(url.openStream());
                includedScripts.put(fileURL, true);
                includesCallstack.push(fileURL);
                engine.exec(source, scope, null);
                includesCallstack.pop();
            } catch (MalformedURLException e) {
View Full Code Here

TOP

Related Classes of org.jaggeryjs.jaggery.core.ScriptReader

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.