]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/AcornDriver.java
Some Acorn improvements
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / AcornDriver.java
index 0e6d52b9abf0ef3f6912951424207f363bd38895..99ec490621edb30449380b7bf42e909fe90da7a9 100644 (file)
@@ -65,38 +65,7 @@ public class AcornDriver implements Driver {
 
     @Override
     public ServerI getServer(String address, Properties properties) throws DatabaseException {
-        return new ServerI() {
-            
-            @Override
-            public void stop() throws DatabaseException {
-                // nop
-            }
-            
-            @Override
-            public void start() throws DatabaseException {
-                // nop
-            }
-            
-            @Override
-            public boolean isActive() throws DatabaseException {
-                return true;
-            }
-            
-            @Override
-            public String getAddress() throws DatabaseException {
-                return address;
-            }
-            
-            @Override
-            public String executeAndDisconnect(String command) throws DatabaseException {
-                return "";
-            }
-            
-            @Override
-            public String execute(String command) throws DatabaseException {
-                return "";
-            }
-        };
+        return new AcornServerI(address);
     }
 
     @Override
@@ -104,5 +73,44 @@ public class AcornDriver implements Driver {
         Path dbFolder = Paths.get(address);
         return new AcornManagement(dbFolder, properties);
     }
+    
+    private static class AcornServerI implements ServerI {
+        
+        private String address;
+
+        public AcornServerI(String address) {
+            this.address = address;
+        }
+        
+        @Override
+        public void stop() throws DatabaseException {
+            AcornDatabaseManager.getDatabase(Paths.get(address)).tryToStop();
+        }
+        
+        @Override
+        public void start() throws DatabaseException {
+            AcornDatabaseManager.getDatabase(Paths.get(address)).start();
+        }
+        
+        @Override
+        public boolean isActive() throws DatabaseException {
+            return AcornDatabaseManager.getDatabase(Paths.get(address)).isRunning();
+        }
+        
+        @Override
+        public String getAddress() throws DatabaseException {
+            return address;
+        }
+        
+        @Override
+        public String executeAndDisconnect(String command) throws DatabaseException {
+            return "";
+        }
+        
+        @Override
+        public String execute(String command) throws DatabaseException {
+            return "";
+        }
+    }
 
 }