+/*******************************************************************************\r
+ * Copyright (c) 2014, 2016 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
package org.simantics.r.scl;\r
\r
import java.util.UUID;\r
\r
import org.rosuda.REngine.Rserve.RConnection;\r
import org.rosuda.REngine.Rserve.RserveException;\r
+import org.simantics.db.layer0.variable.NodeSupport;\r
import org.simantics.scl.runtime.function.Function;\r
\r
public class RSessionManager {\r
static ConcurrentHashMap<String, RSession> CONNECTIONS =\r
new ConcurrentHashMap<String, RSession>(); \r
+\r
+ static ConcurrentHashMap<String, NodeSupport<String>> SUPPORTS =\r
+ new ConcurrentHashMap<String, NodeSupport<String>>(); \r
\r
public static RSession getSession(String id) {\r
// CONNECTIONS is ConcurrentHashMap so no synchronization is needed here\r
return managedConnection;\r
}\r
}\r
+ \r
+ public static NodeSupport<String> getOrCreateNodeSupport(String id) {\r
+ synchronized(SUPPORTS) {\r
+ NodeSupport<String> result = SUPPORTS.get(id);\r
+ if(result == null) {\r
+ RSession session = getSession(id);\r
+ result = new NodeSupport<String>(session.getNodeManager());\r
+ SUPPORTS.put(id, result);\r
+ }\r
+ return result;\r
+ }\r
+ }\r
}\r