-
-// static ConcurrentHashMap<String, SpreadsheetRealm> REALMS =
-// new ConcurrentHashMap<String, SpreadsheetRealm>();
-//
-// static ConcurrentHashMap<String, NodeSupport<String>> SUPPORTS =
-// new ConcurrentHashMap<String, NodeSupport<String>>();
-//
-// public static SpreadsheetRealm sclRealmById(String id) {
-// // CONNECTIONS is ConcurrentHashMap so no synchronization is needed here
-// return REALMS.get(id);
-// }
-//
-// public static NodeSupport<String> getOrCreateNodeSupport(String id) {
-// synchronized(SUPPORTS) {
-// NodeSupport<String> result = SUPPORTS.get(id);
-// if(result == null) {
-// SpreadsheetRealm realm = getOrCreateSCLRealm(id);
-// result = new NodeSupport<String>(realm.getNodeManager());
-// SUPPORTS.put(id, result);
-// }
-// return result;
-// }
-// }
-//
-// public static SpreadsheetRealm createRealm() {
-// synchronized(REALMS) {
-// String id = UUID.randomUUID().toString();
-// return createRealm(id);
-// }
-// }
-//
-// public static SpreadsheetRealm getOrCreateSCLRealm(String id) {
-// synchronized(REALMS) {
-// SpreadsheetRealm session = sclRealmById(id);
-// if(session == null)
-// return createRealm(id);
-// else
-// return session;
-// }
-// }
-//
-// private static SpreadsheetRealm createRealm(String id) {
-// SpreadsheetBook book = new SpreadsheetBook();
-// SpreadsheetRealm realm = new SpreadsheetRealm(book, id);
-// REALMS.put(id, realm);
-// return realm;
-// }
-//
-// public static void removeRealm(String id) {
-// REALMS.remove(id);
-// }
-
+
+ @Override
+ public void removeRealm(WriteGraph graph, String id) throws DatabaseException {
+ StandardRealm<SheetNode, SpreadsheetBook> realm = getOrCreateRealm(graph, id);
+ SpreadsheetEvaluationEnvironment.removeInstance(realm.getEngine());
+ super.removeRealm(graph, id);
+ }
+
+ // Utility function for SCL, this should maybe be replaced with something better in the future
+ public static void removeSpreadsheetSession(WriteGraph graph, Variable runVariable) throws DatabaseException {
+ String uri = runVariable.getParent(graph).getURI(graph);
+ getInstance().removeRealm(graph, uri);
+ }