From 3048bf7b4b4494a5a904c1a678bad2dab6d711f1 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Sat, 11 Apr 2020 14:15:58 +0200 Subject: [PATCH] IndirectModelComponentCreator no longer caches jsonfile: components --- .../serializing/IndirectModelComponentCreator.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectModelComponentCreator.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectModelComponentCreator.java index 926e48b5..13205b28 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectModelComponentCreator.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectModelComponentCreator.java @@ -95,7 +95,7 @@ public class IndirectModelComponentCreator if (id == null) throw new NullPointerException("Component ID is null"); if (componentCache.containsKey(id)) - return loadComponentFromJsonObject(model, id, name, componentCache.get(id)); + return loadComponentFromJsonObject(model, id, name, componentCache.get(id), false); String resolvedID = resolveID(id); if (resolvedID == null) throw new IllegalArgumentException("Unknown standard ID or illegal resolved ID: " + id); @@ -113,7 +113,7 @@ public class IndirectModelComponentCreator { throw new UncheckedIOException("Error loading JSON file", e); } - return loadComponentFromJsonObject(model, id, name, jsonContents); + return loadComponentFromJsonObject(model, id, name, jsonContents, false); } ResourceLoader loader; String resTypeID; @@ -149,7 +149,7 @@ public class IndirectModelComponentCreator { throw new UncheckedIOException("Error loading JSON resource", e); } - return loadComponentFromJsonObject(model, id, name, jsonContents); + return loadComponentFromJsonObject(model, id, name, jsonContents, true); } else if (resTypeID.equals("class")) { ComponentSupplier componentSupplier = componentSuppliers.get(resID); @@ -184,9 +184,10 @@ public class IndirectModelComponentCreator } private static SubmodelComponent loadComponentFromJsonObject(LogicModelModifiable model, String id, String name, - SubmodelComponentParams jsonContents) + SubmodelComponentParams jsonContents, boolean cache) { - componentCache.putIfAbsent(id, jsonContents); + if (cache) + componentCache.putIfAbsent(id, jsonContents); return SubmodelComponentSerializer.deserialize(model, jsonContents, name, id, null); } -- 2.17.1