Package javax.script

Examples of javax.script.Bindings


        // dynamically create VerbsTestAPI class with verbs methods
        TestAPI testAPI = TestAPIImpl.getInstance();
        Collection<String> registeredComponents = testAPI.getRegisteredComponents();

        if (engine != null) {
            Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
            if (bindings != null) {
                bindings.clear();
            }
        }

        globalBindings = engine.createBindings();
        globalBindings.put(ScriptEngine.FILENAME, "embedded_jython");
View Full Code Here


        tagsDoc.put(tag, Strings.join(textLines, "\n"));
        return tagsDoc;
    }

    public static void addToGlobalJythonScope(String name, Object value) {
        Bindings globalContext = engine.getBindings(ScriptContext.ENGINE_SCOPE);
        globalContext.put(name, value);
    }
View Full Code Here

                logger.error("Exception raised while handling breakpoint action: " + ex.getMessage());
            }
        }

        private ArrayList<DebugVariable> getPythonVariablesDump() {
            Bindings globalContext = engine.getBindings(ScriptContext.ENGINE_SCOPE);
            ArrayList<DebugVariable> debugVariables = new ArrayList<DebugVariable>();
            for (String variableName : new TreeSet<String>(globalContext.keySet())) {
                Object variableValue = globalContext.get(variableName);
                if (!variableName.startsWith("__") &&
                        !(variableValue instanceof PySystemState) &&
                        !(variableValue instanceof com.sun.script.jython.JythonScriptEngine) &&
                        !(variableValue instanceof javax.script.SimpleScriptContext) &&
                        !variableName.equals("javax.script.filename")
View Full Code Here

      MemcacheService syncCache = MemcacheServiceFactory
          .getMemcacheService();
      syncCache.put("test", compiledscript);
      long begin = System.nanoTime();

      Bindings b = compiledscript.getEngine().getBindings(
          ScriptContext.ENGINE_SCOPE);
      b.put("abc", "def");
      Date date = Calendar.getInstance().getTime();
      b.put("abc", date);

      for (int i = 0; i < 1000; i++) {
        String str;
        try {
          str = (String) compiledscript.eval();
View Full Code Here

          CompiledScript compiledscript = CompileScriptEngine
              .getCompileScript(config.getApplicationId(),
                  "search", template.getSearch());

          Bindings bind = compiledscript.getEngine().getBindings(
              ScriptContext.ENGINE_SCOPE);
          bind.put("title_for_layout", config.getTitle());
          bind.put("description_for_layout", config.getDescription());
          bind.put("keyword_for_layout", config.getKeyword());
          bind.put("css_for_layout", template.getCss());
          bind.put("js_for_layout", template.getJs());

          CategoryModel cateModel = new CategoryModel();
          cateModel.prepareAll();
          TagModel tagModel = new TagModel();
          tagModel.prepareList();

          bind.put("keyword", keyword);
          bind.put("recent_view", RecentViewHelper.getRecentView());
          bind.put("list_tag", tagModel.getListResult());
          bind.put("list_category", cateModel.getListResult());

          bind.put("current_page", model.getPage());
          bind.put("total_page", model.getTotalPage());
          bind.put("articles", model.getListResult());
          try {
            resp.getWriter().print((String) compiledscript.eval());
          } catch (Exception e) {
            e.printStackTrace();
            log.warning(e.toString());
View Full Code Here

            }
            CompiledScript compiledscript = CompileScriptEngine
                .getCompileScript(config.getApplicationId(),
                    "tag", template.getTag());

            Bindings bind = compiledscript.getEngine().getBindings(
                ScriptContext.ENGINE_SCOPE);
            bind.put("title_for_layout", config.getTitle());
            bind.put("description_for_layout",
                config.getDescription());
            bind.put("keyword_for_layout", config.getKeyword());
            bind.put("css_for_layout", template.getCss());
            bind.put("js_for_layout", template.getJs());

            CategoryModel cateModel = new CategoryModel();
            cateModel.prepareAll();
            TagModel tagModel = new TagModel();
            tagModel.prepareList();

            bind.put("current_tag", obj);
            bind.put("recent_view",
                RecentViewHelper.getRecentView());
            bind.put("list_tag", tagModel.getListResult());
            bind.put("list_category", cateModel.getListResult());

            List<News> listResult = new ArrayList<News>();
            listResult = obj.recoverListNews();
            int start = (page - 1) * limit;
            double dLimit = limit;
            bind.put("total_page",
                (int) Math.ceil(listResult.size() / dLimit));
            try {
              listResult = listResult
                  .subList(start, page * limit);
            } catch (Exception e) {
              try {
                listResult = listResult.subList(start,
                    listResult.size());
              } catch (Exception e2) {

              }
            }
            bind.put("articles", listResult);
            bind.put("current_page", page);

            try {
              resp.getWriter().print(
                  (String) compiledscript.eval());
            } catch (Exception e) {
View Full Code Here

          CompiledScript compiledscript = CompileScriptEngine
              .getCompileScript(config.getApplicationId(),
                  "home", template.getHome());
          if (compiledscript != null) {
            Bindings bind = compiledscript.getEngine().getBindings(
                ScriptContext.ENGINE_SCOPE);
            bind.put("title_for_layout", config.getTitle());
            bind.put("description_for_layout",
                config.getDescription());
            bind.put("keyword_for_layout", config.getKeyword());
            bind.put("css_for_layout", template.getCss());
            bind.put("js_for_layout", template.getJs());

            bind.put("recent_view",
                RecentViewHelper.getRecentView());
            bind.put("list_tag", tagModel.getListResult());
            bind.put("list_category", cateModel.getListResult());

            bind.put("current_page", model.getPage());
            bind.put("total_page", model.getTotalPage());
            bind.put("articles", model.getListResult());
            try {
              resp.getWriter().print(
                  (String) compiledscript.eval());
            } catch (Exception e) {
              e.printStackTrace();
View Full Code Here

            tagModel.prepareList();
            CompiledScript compiledscript = CompileScriptEngine
                .getCompileScript(config.getApplicationId(),
                    "detail", template.getDetail());

            Bindings bind = compiledscript.getEngine().getBindings(
                ScriptContext.ENGINE_SCOPE);
            bind.put("title_for_layout", config.getTitle());
            bind.put("description_for_layout",
                config.getDescription());
            bind.put("keyword_for_layout", config.getKeyword());
            bind.put("css_for_layout", template.getCss());
            bind.put("js_for_layout", template.getJs());

            RecentViewHelper.addRecentView(obj);
            bind.put("recent_view",
                RecentViewHelper.getRecentView());
            bind.put("list_tag", tagModel.getListResult());
            bind.put("list_category", cateModel.getListResult());
            bind.put("article", obj);
            try {
              String result = (String) compiledscript.eval();
              treeCache.put(alias, result);
              resp.getWriter().print(result);
            } catch (Exception e) {
View Full Code Here

                byName = null;
            }
            if (byName != null) {
                final List<JahiaTemplatesPackage> forModule = ServicesRegistry.getInstance().getJahiaTemplateManagerService().getAvailableTemplatePackagesForModule(
                        epd.getDeclaringNodeType().getName().replace(":", "_"));
                final Bindings bindings = byName.getBindings(ScriptContext.ENGINE_SCOPE);
                bindings.put("values", values);
                for (JahiaTemplatesPackage template : forModule) {
                    final File scriptPath = new File(
                            template.getFilePath() + File.separator + "scripts" + File.separator + param);
                    if (scriptPath.exists()) {
                        FileReader scriptContent = null;
View Full Code Here

      logger.info("Start executing JSR223 script job {}", jobScriptPath);
     
        ScriptEngine scriptEngine = ScriptEngineUtils.getInstance().scriptEngine(FilenameUtils.getExtension(jobScriptPath));
        if (scriptEngine != null) {
            ScriptContext scriptContext = scriptEngine.getContext();
            final Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
            bindings.put("jobDataMap", map);
            InputStream scriptInputStream = JahiaContextLoaderListener.getServletContext().getResourceAsStream(jobScriptPath);
            if (scriptInputStream != null) {
                Reader scriptContent = null;
                try {
                    scriptContent = new InputStreamReader(scriptInputStream);
                    StringWriter out = new StringWriter();
                    scriptContext.setWriter(out);
                    // The following binding is necessary for Javascript, which doesn't offer a console by default.
                    bindings.put("out", new PrintWriter(scriptContext.getWriter()));
                    scriptEngine.eval(scriptContent, bindings);
                    map.put(JOB_SCRIPT_OUTPUT, out.toString());
                  logger.info("...JSR-223 script job {} execution finished", jobScriptPath);
                } catch (ScriptException e) {
                  logger.error("Error during execution of the JSR-223 script job " + jobScriptPath + " execution failed with error " + e.getMessage(), e);
View Full Code Here

TOP

Related Classes of javax.script.Bindings

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.