]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.acorn/src/org/simantics/acorn/AcornManagement.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / AcornManagement.java
1 package org.simantics.acorn;
2
3 import java.util.Properties;
4
5 import org.simantics.db.Database;
6 import org.simantics.db.Driver.Management;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.db.server.ProCoreException;
9
10 public class AcornManagement implements Management {
11
12     private final Database db;
13     private final Properties properties;
14
15     AcornManagement(Database db, Properties properties) throws ProCoreException {
16         this.db = db;
17         this.properties = properties;
18     }
19
20     @Override
21     public boolean exist() throws DatabaseException {
22         return db.isFolderOk();
23     }
24
25     @Override
26     public void delete() throws DatabaseException {
27         db.deleteFiles();
28         if (exist())
29             throw new DatabaseException("Failed to delete database. folder=" + db.getFolder());
30     }
31
32     @Override
33     public void create() throws DatabaseException {
34         db.initFolder(properties);
35         if (!exist())
36             throw new DatabaseException("Failed to create Acorn database. folder=" + db.getFolder());
37     }
38
39     @Override
40     public void purge() throws DatabaseException {
41         db.purgeDatabase();
42     }
43
44     @Override
45     public void shutdown() throws DatabaseException {
46         db.tryToStop();
47         db.disconnect();
48     }
49
50 }