Class AbstractScriptDependencyTracker
java.lang.Object
org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptDependencyTracker
- All Implemented Interfaces:
ScriptDependencyTracker
,WatchService.WatchEventListener
@NonNullByDefault
public abstract class AbstractScriptDependencyTracker
extends Object
implements ScriptDependencyTracker, WatchService.WatchEventListener
The
AbstractScriptDependencyTracker
tracks dependencies between scripts and reloads dependees
It needs to be sub-classed for each ScriptEngineFactory
that wants to support dependency tracking- Author:
- Jonathan Gilbert - Initial contribution, Jan N. Klug - Refactored to OSGi service
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.openhab.core.automation.module.script.ScriptDependencyTracker
ScriptDependencyTracker.Listener
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractScriptDependencyTracker
(WatchService watchService, String fileDirectory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a dependency change listener Since this is done via service injection and OSGi annotations are not inherited it is required that subclasses expose this method with proper annotationvoid
protected void
dependencyChanged
(String dependency) getTracker
(String scriptId) Get the tracker for a given script identifiervoid
processWatchEvent
(WatchService.Kind kind, Path path) Notify Listener about watch eventvoid
void
removeTracking
(String scriptId) Remove all tracking data for a given scipt identifierprotected void
startTracking
(String scriptId, String libPath)
-
Field Details
-
libraryPath
-
-
Constructor Details
-
AbstractScriptDependencyTracker
-
-
Method Details
-
deactivate
public void deactivate() -
getLibraryPath
-
processWatchEvent
Description copied from interface:WatchService.WatchEventListener
Notify Listener about watch event- Specified by:
processWatchEvent
in interfaceWatchService.WatchEventListener
- Parameters:
kind
- theWatchService.Kind
of this eventpath
- the relative path of the file associated with this event
-
dependencyChanged
-
getTracker
Description copied from interface:ScriptDependencyTracker
Get the tracker for a given script identifier- Specified by:
getTracker
in interfaceScriptDependencyTracker
- Parameters:
scriptId
- the unique id of the script- Returns:
- a
Consumer<String>
that accepts a the path to a dependency
-
removeTracking
Description copied from interface:ScriptDependencyTracker
Remove all tracking data for a given scipt identifier- Specified by:
removeTracking
in interfaceScriptDependencyTracker
- Parameters:
scriptId
- the uniwue id of the script
-
startTracking
-
addChangeTracker
Add a dependency change listener Since this is done via service injection and OSGi annotations are not inherited it is required that subclasses expose this method with proper annotation- Parameters:
listener
- the dependency change listener
-
removeChangeTracker
-