mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
ScriptTransformationService: Implement missing script dependency tracking (#5062)
Closes #5046. Signed-off-by: Florian Hotze <dev@florianhotze.com>
This commit is contained in:
+15
-4
@@ -64,13 +64,14 @@ import org.slf4j.LoggerFactory;
|
||||
* language
|
||||
*
|
||||
* @author Jan N. Klug - Initial contribution
|
||||
* @author Florian Hotze - Implement script dependency tracking
|
||||
*/
|
||||
@NonNullByDefault
|
||||
@Component(factory = "org.openhab.core.automation.module.script.transformation.factory", service = {
|
||||
TransformationService.class, ScriptTransformationService.class, ConfigOptionProvider.class,
|
||||
ConfigDescriptionProvider.class })
|
||||
public class ScriptTransformationService implements TransformationService, ConfigOptionProvider,
|
||||
ConfigDescriptionProvider, RegistryChangeListener<Transformation> {
|
||||
TransformationService.class, ScriptTransformationService.class, ScriptDependencyTracker.Listener.class,
|
||||
ConfigOptionProvider.class, ConfigDescriptionProvider.class })
|
||||
public class ScriptTransformationService implements TransformationService, ScriptDependencyTracker.Listener,
|
||||
ConfigOptionProvider, ConfigDescriptionProvider, RegistryChangeListener<Transformation> {
|
||||
public static final String SCRIPT_TYPE_PROPERTY_NAME = "openhab.transform.script.scriptType";
|
||||
public static final String OPENHAB_TRANSFORMATION_SCRIPT = "openhab-transformation-script-";
|
||||
|
||||
@@ -298,6 +299,16 @@ public class ScriptTransformationService implements TransformationService, Confi
|
||||
.withParameterGroups(template.getParameterGroups()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDependencyChange(String scriptId) {
|
||||
String scriptUid = scriptId.substring(OPENHAB_TRANSFORMATION_SCRIPT.length());
|
||||
ScriptRecord scriptRecord = scriptCache.get(scriptUid);
|
||||
if (scriptRecord != null) {
|
||||
logger.debug("Clearing script cache for script {}", scriptUid);
|
||||
clearCache(scriptUid);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearCache(String uid) {
|
||||
ScriptRecord scriptRecord = scriptCache.remove(uid);
|
||||
if (scriptRecord != null) {
|
||||
|
||||
Reference in New Issue
Block a user