Package org.jaggeryjs.scriptengine.cache

Examples of org.jaggeryjs.scriptengine.cache.ScriptCachingContext


            };
        } 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);
        sctx.setSourceModifiedTime(lastModified);

        includedScripts.put(fileURL, true);
        includesCallstack.push(fileURL);
        if (isJSON) {
            scope = (ScriptableObject) engine.eval(source, scope, sctx);
View Full Code Here


         * tenantId = tenantId
         * context = webapp context
         * path = relative path to the directory of *.js file
         * cacheKey = name of the *.js file being cached
         */
        ScriptCachingContext sctx = new ScriptCachingContext(tenantId, parts[0], parts[1], parts[2]);
        ServletContext servletContext = request.getServletContext();
        sctx.setSecurityDomain(new JaggerySecurityDomain(getNormalizedScriptPath(parts), servletContext));
        long lastModified = getScriptLastModified(servletContext, scriptPath);
        sctx.setSourceModifiedTime(lastModified);
        return sctx;
    }
View Full Code Here

                        new QName(MODULE_NAMESPACE, "path")).getText();
                script = new JavaScriptScript(name);

                Reader reader;
                final String fileName;
                ScriptCachingContext sctx;
                if (isCustom) {
                    String filteredPath = filterPath(path);
                    fileName = modulesDir + File.separator + module.getName() +
                            File.separator + filterPath(path);
                    reader = new FileReader(fileName);
                    int endIndex = filteredPath.lastIndexOf(File.separator);
                    sctx = new ScriptCachingContext(
                            String.valueOf(MultitenantConstants.SUPER_TENANT_ID),
                            '<' + module.getName() + '>',
                            filteredPath.substring(0, endIndex),
                            filteredPath.substring(endIndex));
                } else {
                    reader = new InputStreamReader(ModuleManager.class.getClassLoader().getResourceAsStream(path));
                    fileName = modulesDir + File.separator + name;
                    int endIndex = path.lastIndexOf('/');
                     sctx = new ScriptCachingContext(
                            String.valueOf(MultitenantConstants.SUPER_TENANT_ID),
                            "<<" +  name + ">>",
                            '/' + path.substring(0, endIndex),
                            path.substring(endIndex));
                }
                CacheManager cacheManager = new CacheManager(null);

                sctx.setSecurityDomain(new RhinoSecurityDomain() {
                    @Override
                    public CodeSource getCodeSource() throws ScriptException {
                        try {
                            URL url = new File(fileName).getCanonicalFile().toURI().toURL();
                            return new CodeSource(url, (Certificate[]) null);
                        } catch (MalformedURLException e) {
                            throw new ScriptException(e);
                        } catch (IOException e) {
                            throw new ScriptException(e);
                        }
                    }
                });
                sctx.setSourceModifiedTime(1);

                Script cachedScript = cacheManager.getScriptObject(reader, sctx);
                if (cachedScript == null) {
                    cacheManager.cacheScript(reader, sctx);
                    cachedScript = cacheManager.getScriptObject(reader, sctx);
View Full Code Here

                    String path = (String) script;
                    path = path.startsWith("/") ? path : "/" + path;
                    Stack<String> callstack = CommonManager.getCallstack(sharedContext);
                    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));
View Full Code Here

TOP

Related Classes of org.jaggeryjs.scriptengine.cache.ScriptCachingContext

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.