|
64 | 64 | * language |
65 | 65 | * |
66 | 66 | * @author Jan N. Klug - Initial contribution |
| 67 | + * @author Florian Hotze - Implement script dependency tracking |
67 | 68 | */ |
68 | 69 | @NonNullByDefault |
69 | 70 | @Component(factory = "org.openhab.core.automation.module.script.transformation.factory", service = { |
70 | | - TransformationService.class, ScriptTransformationService.class, ConfigOptionProvider.class, |
71 | | - ConfigDescriptionProvider.class }) |
72 | | -public class ScriptTransformationService implements TransformationService, ConfigOptionProvider, |
73 | | - ConfigDescriptionProvider, RegistryChangeListener<Transformation> { |
| 71 | + TransformationService.class, ScriptTransformationService.class, ScriptDependencyTracker.Listener.class, |
| 72 | + ConfigOptionProvider.class, ConfigDescriptionProvider.class }) |
| 73 | +public class ScriptTransformationService implements TransformationService, ScriptDependencyTracker.Listener, |
| 74 | + ConfigOptionProvider, ConfigDescriptionProvider, RegistryChangeListener<Transformation> { |
74 | 75 | public static final String SCRIPT_TYPE_PROPERTY_NAME = "openhab.transform.script.scriptType"; |
75 | 76 | public static final String OPENHAB_TRANSFORMATION_SCRIPT = "openhab-transformation-script-"; |
76 | 77 |
|
@@ -298,6 +299,16 @@ public Collection<ConfigDescription> getConfigDescriptions(@Nullable Locale loca |
298 | 299 | .withParameterGroups(template.getParameterGroups()).build(); |
299 | 300 | } |
300 | 301 |
|
| 302 | + @Override |
| 303 | + public void onDependencyChange(String scriptId) { |
| 304 | + String scriptUid = scriptId.substring(OPENHAB_TRANSFORMATION_SCRIPT.length()); |
| 305 | + ScriptRecord scriptRecord = scriptCache.get(scriptUid); |
| 306 | + if (scriptRecord != null) { |
| 307 | + logger.debug("Clearing script cache for script {}", scriptUid); |
| 308 | + clearCache(scriptUid); |
| 309 | + } |
| 310 | + } |
| 311 | + |
301 | 312 | private void clearCache(String uid) { |
302 | 313 | ScriptRecord scriptRecord = scriptCache.remove(uid); |
303 | 314 | if (scriptRecord != null) { |
|
0 commit comments