]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.backup/src/org/simantics/backup/IBackupProvider.java
added org.simantics.backup
[simantics/platform.git] / bundles / org.simantics.backup / src / org / simantics / backup / IBackupProvider.java
diff --git a/bundles/org.simantics.backup/src/org/simantics/backup/IBackupProvider.java b/bundles/org.simantics.backup/src/org/simantics/backup/IBackupProvider.java
new file mode 100644 (file)
index 0000000..9bab31b
--- /dev/null
@@ -0,0 +1,49 @@
+package org.simantics.backup;\r
+\r
+import java.nio.file.Path;\r
+import java.util.concurrent.Future;\r
+\r
+/**\r
+ * Interface for providing backup capabilities to Simantics products.\r
+ * BackupProviders are used in {@link BackupProviderService}.\r
+ * \r
+ * @author Jani Simomaa\r
+ */\r
+public interface IBackupProvider {\r
+\r
+    /**\r
+     * Lock the resources that are going to be backed up in a way that allows\r
+     * making an atomic and consistent copy of the backed up resources.\r
+     */\r
+    void lock() throws BackupException;\r
+\r
+    /**\r
+     * Initiates or executes the backing up procedure of this provider. The\r
+     * backup procedure is allowed to return from this method and complete\r
+     * asynchronously. A {@link Future} is returned to allow waiting for backup\r
+     * to complete.\r
+     * \r
+     * @param targetPath\r
+     * @param revision\r
+     * @return a future that can be waited upon to wait for the backup procedure\r
+     *         to complete.\r
+     */\r
+    Future<BackupException> backup(Path targetPath, int revision) throws BackupException;\r
+\r
+    /**\r
+     * The counterpart of {@link #lock()} that must be invoked and invoked only\r
+     * after {@link #lock()} has been successfully invoked\r
+     */\r
+    void unlock() throws BackupException;\r
+\r
+    /**\r
+     * Restore implementation for this provider.\r
+     * \r
+     * @param fromPath\r
+     * @param revision\r
+     * \r
+     * TODO: change to return {@link Future} that can be waited upon\r
+     */\r
+    void restore(Path fromPath, int revision) throws BackupException;\r
+\r
+}\r