1 package org.simantics.acorn;
3 import java.io.IOException;
4 import java.nio.file.Files;
5 import java.nio.file.Path;
6 import java.util.HashMap;
9 import org.simantics.acorn.internal.AcornDatabase;
10 import org.simantics.db.Database;
11 import org.simantics.db.server.ProCoreException;
14 * @author Tuukka Lehtonen
16 public class AcornDatabaseManager {
18 private static Map<String, Database> dbs = new HashMap<String, Database>();
20 public static synchronized Database getDatabase(Path folder) throws ProCoreException {
23 if (!Files.exists(folder))
24 Files.createDirectories(folder);
25 canonical = folder.toRealPath();
26 } catch (IOException e) {
27 throw new ProCoreException("Could not get canonical path.", e);
30 String canonicalPath = canonical.toString();
31 Database db = dbs.get(canonicalPath);
35 db = new AcornDatabase(canonical);
36 dbs.put(canonicalPath, db);