Package org.openhab.core.scriptengine

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


      if (!StringUtils.endsWith(scriptName, Script.SCRIPT_FILEEXT)) {
        scriptNameWithExt = scriptName + "." + Script.SCRIPT_FILEEXT;
      }
      XExpression expr = (XExpression) repo.getModel(scriptNameWithExt);
      if(expr!=null) {
        ScriptEngine scriptEngine = ScriptActivator.scriptEngineTracker.getService();
        if(scriptEngine!=null) {
          Script script = scriptEngine.newScriptFromXExpression(expr);
          return script.execute();
        } else {
          throw new ScriptExecutionException("Script engine is not available.");
        }
      } else {
View Full Code Here

  public void execute(JobExecutionContext context) throws JobExecutionException {
    String modelName = (String) context.getJobDetail().getJobDataMap().get(JOB_DATA_RULEMODEL);       
    String ruleName = (String) context.getJobDetail().getJobDataMap().get(JOB_DATA_RULENAME);
   
    ModelRepository modelRepository = RuleModelActivator.modelRepositoryTracker.getService();
    ScriptEngine scriptEngine = RuleModelActivator.scriptEngineTracker.getService();
   
    if(modelRepository!=null && scriptEngine!=null) {
      EObject model = modelRepository.getModel(modelName);
      if (model instanceof RuleModel) {
        RuleModel ruleModel = (RuleModel) model;
        Rule rule = getRule(ruleModel, ruleName);
        if(rule!=null) {
          Script script = scriptEngine.newScriptFromXExpression(rule.getScript());
          logger.debug("Executing scheduled rule '{}'", rule.getName());
          try {
            script.execute(RuleContextHelper.getContext(rule));
          } catch (ScriptExecutionException e) {
            logger.error("Error during the execution of rule {}", rule.getName(), e.getCause());
View Full Code Here

TOP

Related Classes of org.openhab.core.scriptengine.ScriptEngine

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.