X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.backup%2Fsrc%2Forg%2Fsimantics%2Fbackup%2FIBackupProvider.java;fp=bundles%2Forg.simantics.backup%2Fsrc%2Forg%2Fsimantics%2Fbackup%2FIBackupProvider.java;h=9bab31b8b41725f6851b06ed7c173f8b6920cf29;hb=4e40f9793cc18f08f1fa6c96d9bb4f42408997b4;hp=0000000000000000000000000000000000000000;hpb=9a175feb652b2b7bba7afa540831b9076be3c10e;p=simantics%2Fplatform.git 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 index 000000000..9bab31b8b --- /dev/null +++ b/bundles/org.simantics.backup/src/org/simantics/backup/IBackupProvider.java @@ -0,0 +1,49 @@ +package org.simantics.backup; + +import java.nio.file.Path; +import java.util.concurrent.Future; + +/** + * Interface for providing backup capabilities to Simantics products. + * BackupProviders are used in {@link BackupProviderService}. + * + * @author Jani Simomaa + */ +public interface IBackupProvider { + + /** + * Lock the resources that are going to be backed up in a way that allows + * making an atomic and consistent copy of the backed up resources. + */ + void lock() throws BackupException; + + /** + * Initiates or executes the backing up procedure of this provider. The + * backup procedure is allowed to return from this method and complete + * asynchronously. A {@link Future} is returned to allow waiting for backup + * to complete. + * + * @param targetPath + * @param revision + * @return a future that can be waited upon to wait for the backup procedure + * to complete. + */ + Future backup(Path targetPath, int revision) throws BackupException; + + /** + * The counterpart of {@link #lock()} that must be invoked and invoked only + * after {@link #lock()} has been successfully invoked + */ + void unlock() throws BackupException; + + /** + * Restore implementation for this provider. + * + * @param fromPath + * @param revision + * + * TODO: change to return {@link Future} that can be waited upon + */ + void restore(Path fromPath, int revision) throws BackupException; + +}