2 * Copyright (c) 2010-2021 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.automation.jsscripting.internal.fs.watch;
17 import org.openhab.core.OpenHAB;
18 import org.openhab.core.automation.module.script.rulesupport.loader.DependencyTracker;
19 import org.osgi.service.component.annotations.Activate;
20 import org.osgi.service.component.annotations.Component;
21 import org.osgi.service.component.annotations.Deactivate;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * Tracks JS module dependencies
28 * @author Jonathan Gilbert - Initial contribution
30 @Component(immediate = true, service = JSDependencyTracker.class)
31 public class JSDependencyTracker extends DependencyTracker {
33 private final Logger logger = LoggerFactory.getLogger(JSDependencyTracker.class);
35 public static final String LIB_PATH = String.join(File.separator, OpenHAB.getConfigFolder(), "automation", "js",
38 public JSDependencyTracker() {
43 public void activate() {
44 File directory = new File(LIB_PATH);
45 if (!directory.exists()) {
46 if (!directory.mkdirs()) {
47 logger.warn("Failed to create watched directory: {}", LIB_PATH);
49 } else if (directory.isFile()) {
50 logger.warn("Trying to watch directory {}, however it is a file", LIB_PATH);
57 public void deactivate() {