Examples of ScriptEngine


Examples of javax.script.ScriptEngine

    }

    @Override
    public ScriptEngine getEngineByMimeType(String mimeType) {
        //TODO this is a hack to deal with context class loader issues
        ScriptEngine engine = null;
        for (ScriptEngineManager manager : classLoaders.keySet()) {
            Thread currentThread = Thread.currentThread();
            ClassLoader old = currentThread.getContextClassLoader();
            currentThread.setContextClassLoader(classLoaders.get(manager));
            engine = manager.getEngineByMimeType(mimeType);
View Full Code Here

Examples of net.grinder.scriptengine.ScriptEngineService.ScriptEngine

      // to
      // call StreamRecevier.waitForMessage(), and so also synchronises on
      // that
      // monitor. See bug 2936167.

      final ScriptEngine scriptEngine = scriptEngineContainer
          .getScriptEngine(m_initialisationMessage.getScript());

      m_logger.info("Running \"{}\" using {}", m_initialisationMessage.getScript(),
          scriptEngine.getDescription());

      m_messagePump.start();

      // Don't write out the data log header until now as the script may
      // declare new statistics.

      final StringBuilder dataLogHeader = new StringBuilder("Thread, Run, Test, Start time (ms since Epoch)");

      final ExpressionView[] detailExpressionViews = m_statisticsServices.getDetailStatisticsView()
          .getExpressionViews();

      for (final ExpressionView detailExpressionView : detailExpressionViews) {
        dataLogHeader.append(", ");
        dataLogHeader.append(detailExpressionView.getDisplayName());
      }

      m_dataLogger.info(dataLogHeader.toString());

      sendStatusMessage(ProcessReport.STATE_STARTED, (short) 0, numberOfThreads);
      boolean threadRampUp = properties.getBoolean("grinder.threadRampUp", false);
      final ThreadSynchronisation threadSynchronisation = threadRampUp ?
          new ThreadRampUpEnabledThreadSynchronisation(m_eventSynchronisation, m_sleeper) :
          new ThreadSynchronisation(m_eventSynchronisation);

      m_terminalLogger.info("Starting threads");

      synchronized (m_eventSynchronisation) {
        m_threadStarter = new ThreadStarterImplementation(threadSynchronisation, scriptEngine);

        for (int i = 0; i < numberOfThreads; i++) {
          m_threadStarter.startThread(null);
        }
      }

      threadSynchronisation.startThreads();

      m_times.setExecutionStartTime();

      m_logger.info("Start time is {} ms since Epoch", m_times.getExecutionStartTime());

      final TimerTask reportTimerTask = new ReportToConsoleTimerTask(threadSynchronisation);
      final TimerTask shutdownTimerTask = new ShutdownTimerTask();

      // Schedule a regular statistics report to the console. We don't
      // need to schedule this at a fixed rate. Each report contains the
      // work done since the last report.

      // First (empty) report to console to start it recording if its
      // not already.
      reportTimerTask.run();

      final Timer timer = new Timer(true);

      timer.schedule(reportTimerTask, reportToConsoleInterval, reportToConsoleInterval);

      try {
        if (duration > 0) {
          m_terminalLogger.info("This test will shut down after {} ms", duration);

          timer.schedule(shutdownTimerTask, duration);
        }

        // Wait for a termination event.
        synchronized (m_eventSynchronisation) {
          while (!threadSynchronisation.isFinished()) {

            if (m_consoleListener.checkForMessage(ConsoleListener.ANY ^ ConsoleListener.START)) {
              break;
            }

            if (m_shutdownTriggered) {
              m_terminalLogger.info("Specified duration exceeded, Test is shut down");
              break;
            }

            m_eventSynchronisation.waitNoInterrruptException();
          }
        }

        synchronized (m_eventSynchronisation) {
          if (!threadSynchronisation.isFinished()) {

            m_terminalLogger.info("Waiting for threads to terminate");

            m_threadStarter = m_invalidThreadStarter;
            m_threadContexts.shutdownAll();

            // Interrupt any sleepers.
            SleeperImplementation.shutdownAllCurrentSleepers();

            final long time = System.currentTimeMillis();
            final long maximumShutdownTime = 10000;

            while (!threadSynchronisation.isFinished()) {
              if (System.currentTimeMillis() - time > maximumShutdownTime) {
                m_terminalLogger.info("Ignoring unresponsive threads");
                break;
              }

              m_eventSynchronisation.waitNoInterrruptException(maximumShutdownTime);
            }
          }
        }
      } finally {
        reportTimerTask.cancel();
        shutdownTimerTask.cancel();
      }

      scriptEngine.shutdown();

      // Final report to the console.
      reportTimerTask.run();

      if (!m_communicationShutdown) {
View Full Code Here

Examples of org.apache.pig.scripting.ScriptEngine

            String msg = "Can't read file: " + path;
            throw new FrontendException(msg, errCode,
                    PigException.USER_ENVIRONMENT);
        }
        if(scriptingLang != null) {
            ScriptEngine se = ScriptEngine.getInstance(scriptingLang);
            se.registerFunctions(path, namespace, pigContext);
        }
        pigContext.addScriptFile(path);
    }
View Full Code Here

Examples of org.criticalfailure.torchlight.core.application.script.ScriptEngine

            throw new ObjectPropertyException("Language not specified for script validator!");
        }
        logger.trace("lang: " + lang);

        logger.debug("requesting script engine for: " + lang);
        ScriptEngine engine = scriptEngineManager.getEngineByName(lang);
        logger.trace("engine: " + engine);
       
        if(engine == null) {
            logger.warn("No script engine found for: " + lang);
            throw new ObjectPropertyException("No script engine available for language: " + lang);
        }
       
        // bind useful variables
        logger.debug("binding variables");
//        engine.put("object", obj);
//        engine.put("creature", attr.getv);

        // binding value
//        if("integer".equals(prop.getType())) {
//            logger.debug("binding value as integer");
//            engine.put("value", new Integer(value));
//        }
//        else if("string".equals(attr.getType())) {
//            logger.debug("binding value as string");
//            engine.put("value", value);
//        }
//        else if("float".equals(attr.getType()))
//        {
//            logger.debug("binding value as float");
//            engine.put("value", new Float(value));
//        }
//        else if("boolean".equals(attr.getType()))
//        {
//            logger.debug("binding value as boolean");
//            engine.put("value", new Boolean(value));
//        }

        try {
            logger.debug("evaluating script");
            Object ret = engine.eval(prop.getValidatorBody());
            logger.trace("ret: " + ret);
           
            result.setValid(Boolean.parseBoolean(String.valueOf(ret)));
            logger.trace("isValid: " + result.isValid());
            result.setReason("");
View Full Code Here

Examples of org.openbp.server.engine.script.ScriptEngine

    String expression = node.getExpression();
    if (expression != null)
    {
      // Evaluate a script expression
      ScriptEngine scriptEngine = getEngine().getScriptEngineFactory().obtainScriptEngine(context);
      try
      {
        // Evaluate the expression
        scriptEngine.prepareNodeSocketExecution(entrySocket);
        Object value = scriptEngine.executeScript(expression, "Decision node script", entrySocket.getNode()
                              .getQualifier().toString());
        scriptEngine.finishNodeSocketExecution(entrySocket);

        // Assign the result to the parameter
        if (value != null && ! value.equals(Boolean.FALSE))
          result = true;
      }
View Full Code Here

Examples of org.openhab.core.scriptengine.ScriptEngine

      console.println("Could not perform command as no TTS service is available.");
    }
  }

  public static void handleScript(String[] args, Console console) {
    ScriptEngine scriptEngine = ConsoleActivator.scriptEngineTracker.getService();
    if(scriptEngine!=null) {
      String scriptString = Joiner.on(" ").join(args);
      Script script;
      try {
        script = scriptEngine.newScriptFromString(scriptString);
        Object result = script.execute();
       
        if(result!=null) {
          console.println(result.toString());
        } else {
View Full Code Here

Examples of org.webharvest.runtime.scripting.ScriptEngine

    public ScriptEngine getScriptEngine() {
        return runningFunctions.size() > 0 ? getRunningFunction().getScriptEngine() : this.scriptEngine;
    }

    public synchronized ScriptEngine getScriptEngine(String engineType) {
        ScriptEngine engine = (ScriptEngine) this.usedScriptEngines.get(engineType);
        if (engine == null) {
            engine = configuration.createScriptEngine(this.context, engineType);
            this.usedScriptEngines.put(engineType, engine);
        }
View Full Code Here

Examples of org.webharvest.runtime.scripting.ScriptEngine

        // releases script engines
        if (this.usedScriptEngines != null) {
            Iterator iterator = this.usedScriptEngines.values().iterator();
            while (iterator.hasNext()) {
                ScriptEngine engine = (ScriptEngine) iterator.next();
                if (engine != null) {
                    engine.dispose();
                }
            }
        }

        this.logger.removeAllAppenders();
       
        Iterator iterator = usedScriptEngines.values().iterator();
        while (iterator.hasNext()) {
            ScriptEngine engine = (ScriptEngine) iterator.next();
            engine.dispose();
        }
    }
View Full Code Here

Examples of org.webharvest.runtime.scripting.ScriptEngine

        super(httpHeaderDef);
        this.httpHeaderDef = httpHeaderDef;
    }

    public Variable execute(Scraper scraper, ScraperContext context) {
        ScriptEngine scriptEngine = scraper.getScriptEngine();
        String name = BaseTemplater.execute( httpHeaderDef.getName(), scriptEngine);
      Variable value = getBodyTextContent(httpHeaderDef, scraper, context);
       
      HttpProcessor httpProcessor = scraper.getRunningHttpProcessor();
      if (httpProcessor != null) {
View Full Code Here

Examples of org.webharvest.runtime.scripting.ScriptEngine

        super(regexpDef);
        this.regexpDef = regexpDef;
    }

    public Variable execute(Scraper scraper, ScraperContext context) {
        ScriptEngine scriptEngine = scraper.getScriptEngine();

        BaseElementDef patternDef = regexpDef.getRegexpPatternDef();
        Variable patternVar = getBodyTextContent(patternDef, scraper, context, true);
        debug(patternDef, scraper, patternVar);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.