diff --git a/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/.classpath b/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/.classpath
index a95e0906ca0..6566c1e3a03 100644
--- a/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/.classpath
+++ b/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/.classpath
@@ -1,7 +1,7 @@
-
+
diff --git a/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/.settings/org.eclipse.jdt.core.prefs b/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 0c68a61dca8..00000000000
--- a/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.8
diff --git a/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/src/main/java/org/eclipse/smarthome/automation/module/script/rulesupport/internal/loader/ScriptFileWatcher.java b/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/src/main/java/org/eclipse/smarthome/automation/module/script/rulesupport/internal/loader/ScriptFileWatcher.java
index 705a4bec6a2..e145581b4cf 100644
--- a/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/src/main/java/org/eclipse/smarthome/automation/module/script/rulesupport/internal/loader/ScriptFileWatcher.java
+++ b/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/src/main/java/org/eclipse/smarthome/automation/module/script/rulesupport/internal/loader/ScriptFileWatcher.java
@@ -23,6 +23,7 @@
import org.eclipse.smarthome.automation.module.script.ScriptEngineContainer;
import org.eclipse.smarthome.automation.module.script.ScriptEngineManager;
+import org.eclipse.smarthome.config.core.ConfigConstants;
import org.eclipse.smarthome.core.common.ThreadPoolManager;
import org.eclipse.smarthome.core.service.AbstractWatchService;
@@ -34,7 +35,7 @@
*
*/
public class ScriptFileWatcher extends AbstractWatchService {
- private static final String FILE_DIRECTORY = "automation/jsr223";
+ private static final String FILE_DIRECTORY = "automation" + File.separator + "jsr223";
private static final String SCRIPT_FILE_WATCH_POOL = "SCRIPT_FILE_WATCH_POOL";
private static final long INITIAL_DELAY = 25;
private static final long RECHECK_INTERVAL = 20;
@@ -47,7 +48,7 @@ public class ScriptFileWatcher extends AbstractWatchService {
private Set loaded = new HashSet<>();
public ScriptFileWatcher() {
- super(FILE_DIRECTORY);
+ super(ConfigConstants.getConfigFolder() + File.separator + FILE_DIRECTORY);
}
public void setScriptEngineManager(ScriptEngineManager manager) {
@@ -57,7 +58,7 @@ public void setScriptEngineManager(ScriptEngineManager manager) {
@Override
public void activate() {
super.activate();
- importResources(new File(FILE_DIRECTORY));
+ importResources(new File(pathToWatch));
startScheduler();
}
@@ -134,19 +135,19 @@ private synchronized void importFile(URL url) {
} else {
if (manager.isSupported(scriptType)) {
try (InputStreamReader reader = new InputStreamReader(new BufferedInputStream(url.openStream()))) {
- logger.info("script loading: {}", url.toString());
+ logger.info("loading script '{}'", url);
ScriptEngineContainer container = manager.createScriptEngine(scriptType, url.toString());
if (container != null) {
manager.loadScript(container.getIdentifier(), reader);
loaded.add(url);
- logger.debug("script successfully loaded: {}", url.toString());
+ logger.debug("script successfully loaded: {}", url);
} else {
logger.error("script ERROR, ignore file: {}", url);
}
} catch (IOException e) {
- logger.error("url=" + url, e);
+ logger.error("url={}", url, e);
}
} else {
enqueueUrl(url, scriptType);
@@ -207,7 +208,7 @@ private String getScriptIdentifier(URL url) {
private void startScheduler() {
ScheduledExecutorService scheduler = ThreadPoolManager.getScheduledPool(SCRIPT_FILE_WATCH_POOL);
- scheduler.scheduleAtFixedRate(this::checkFiles, INITIAL_DELAY, RECHECK_INTERVAL, TimeUnit.SECONDS);
+ scheduler.scheduleWithFixedDelay(this::checkFiles, INITIAL_DELAY, RECHECK_INTERVAL, TimeUnit.SECONDS);
}
private void checkFiles() {
diff --git a/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/src/main/java/org/eclipse/smarthome/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java b/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/src/main/java/org/eclipse/smarthome/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java
index 15009256f16..253884d641a 100644
--- a/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/src/main/java/org/eclipse/smarthome/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java
+++ b/bundles/automation/org.eclipse.smarthome.automation.module.script.rulesupport/src/main/java/org/eclipse/smarthome/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java
@@ -9,6 +9,7 @@
import java.util.Collection;
import java.util.HashSet;
+import java.util.Map;
import org.eclipse.smarthome.automation.Rule;
import org.eclipse.smarthome.automation.RuleRegistry;
@@ -137,8 +138,8 @@ public void runNow(String ruleUID) {
}
@Override
- public void runNow(String ruleUID, boolean considerConditions) {
- ruleRegistry.runNow(ruleUID, considerConditions);
+ public void runNow(String ruleUID, boolean considerConditions, Map context) {
+ ruleRegistry.runNow(ruleUID, considerConditions, context);
}
}
diff --git a/bundles/automation/org.eclipse.smarthome.automation.provider.file/src/main/java/org/eclipse/smarthome/automation/internal/provider/file/AbstractFileProvider.java b/bundles/automation/org.eclipse.smarthome.automation.provider.file/src/main/java/org/eclipse/smarthome/automation/internal/provider/file/AbstractFileProvider.java
index ce44147def9..8bf20dfb489 100644
--- a/bundles/automation/org.eclipse.smarthome.automation.provider.file/src/main/java/org/eclipse/smarthome/automation/internal/provider/file/AbstractFileProvider.java
+++ b/bundles/automation/org.eclipse.smarthome.automation.provider.file/src/main/java/org/eclipse/smarthome/automation/internal/provider/file/AbstractFileProvider.java
@@ -27,6 +27,7 @@
import org.eclipse.smarthome.automation.template.TemplateProvider;
import org.eclipse.smarthome.automation.type.ModuleType;
import org.eclipse.smarthome.automation.type.ModuleTypeProvider;
+import org.eclipse.smarthome.config.core.ConfigConstants;
import org.eclipse.smarthome.core.common.registry.Provider;
import org.eclipse.smarthome.core.common.registry.ProviderChangeListener;
import org.slf4j.Logger;
@@ -79,7 +80,7 @@ public abstract class AbstractFileProvider implements Provider {
public AbstractFileProvider(String root) {
this.rootSubdirectory = root;
- configurationRoots = new String[] { "automation" };
+ configurationRoots = new String[] { ConfigConstants.getConfigFolder() + File.separator + "automation" };
}
public void activate(Map config) {
diff --git a/bundles/core/org.eclipse.smarthome.core/src/main/java/org/eclipse/smarthome/core/service/WatchQueueReader.java b/bundles/core/org.eclipse.smarthome.core/src/main/java/org/eclipse/smarthome/core/service/WatchQueueReader.java
index dc6fa796579..5c5cec00d42 100644
--- a/bundles/core/org.eclipse.smarthome.core/src/main/java/org/eclipse/smarthome/core/service/WatchQueueReader.java
+++ b/bundles/core/org.eclipse.smarthome.core/src/main/java/org/eclipse/smarthome/core/service/WatchQueueReader.java
@@ -15,6 +15,7 @@
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.WatchEvent;
@@ -97,6 +98,8 @@ protected void customizeWatchQueueReader(AbstractWatchService watchService, Path
} else {
registerDirectoryInternal(watchService, watchService.getWatchEventKinds(toWatch), toWatch);
}
+ } catch (NoSuchFileException e) {
+ logger.debug("Not watching folder '{}' as it does not exist.", toWatch);
} catch (IOException e) {
logger.warn("Cannot customize folder watcher for folder '{}'", toWatch, e);
}
@@ -132,8 +135,7 @@ private synchronized void registerDirectoryInternal(AbstractWatchService service
try {
registrationKey = directory.register(this.watchService, kinds);
} catch (IOException e) {
- e.printStackTrace();
- logger.debug("The directory '{}' was not registered in the watch service", directory, e);
+ logger.debug("The directory '{}' was not registered in the watch service: {}", directory, e.getMessage());
}
if (registrationKey != null) {
registeredKeys.put(registrationKey, directory);
diff --git a/features/karaf/esh-core/src/main/feature/feature.xml b/features/karaf/esh-core/src/main/feature/feature.xml
index 132f1feefe4..41d8e64f1ef 100644
--- a/features/karaf/esh-core/src/main/feature/feature.xml
+++ b/features/karaf/esh-core/src/main/feature/feature.xml
@@ -115,6 +115,13 @@
mvn:org.eclipse.smarthome.automation/org.eclipse.smarthome.automation.module.script.defaultscope/${project.version}
+
+ esh-base
+ esh-automation-api
+ esh-automation-module-script
+ mvn:org.eclipse.smarthome.automation/org.eclipse.smarthome.automation.module.script.rulesupport/${project.version}
+
+
esh-base
esh-automation-api
diff --git a/features/org.eclipse.smarthome.feature.runtime.automation/feature.xml b/features/org.eclipse.smarthome.feature.runtime.automation/feature.xml
index aca4ebb951f..2fa6612382b 100644
--- a/features/org.eclipse.smarthome.feature.runtime.automation/feature.xml
+++ b/features/org.eclipse.smarthome.feature.runtime.automation/feature.xml
@@ -20,7 +20,7 @@ Automation support
- Copyright (c) 2014-2016 by the respective copyright holders.
+ Copyright (c) 2014-2017 by the respective copyright holders.
@@ -80,6 +80,13 @@ Automation support
version="0.0.0"
unpack="false"/>
+
+