Package org.openhab.core.scriptengine

Examples of org.openhab.core.scriptengine.Script.execute()


    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 {
          console.println("OK");
View Full Code Here


      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 {
        throw new ScriptExecutionException("Script '" + scriptName + "' cannot be found.");
View Full Code Here

          try {
            Script script = scriptEngine.newScriptFromXExpression(rule.getScript());           
            logger.debug("Executing startup rule '{}'", rule.getName());
            RuleEvaluationContext context = new RuleEvaluationContext();
            context.setGlobalContext(RuleContextHelper.getContext(rule));
            script.execute(context);
            executedRules.add(rule);
          } catch (ScriptExecutionException e) {
            if(e.getCause() instanceof ItemNotFoundException || e.getCause().getMessage().contains("cannot be resolved to an item or type")) {
              // we do not seem to have all required items in place yet
              // so we keep the rule in the list and try it again later
View Full Code Here

        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());
          }
        } else {
          logger.debug("Scheduled rule '{}' does not exist", ruleName);
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.