mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Expose transactions through DatabaseComponent interface.
This commit is contained in:
@@ -39,6 +39,21 @@ public interface DatabaseComponent {
|
||||
/** Waits for any open transactions to finish and closes the database. */
|
||||
void close() throws DbException, IOException;
|
||||
|
||||
/** Starts a new transaction and returns an object representing it. */
|
||||
Transaction startTransaction() throws DbException;
|
||||
|
||||
/**
|
||||
* Aborts the given transaction - no changes made during the transaction
|
||||
* will be applied to the database.
|
||||
*/
|
||||
void abortTransaction(Transaction txn);
|
||||
|
||||
/**
|
||||
* Commits the given transaction - all changes made during the transaction
|
||||
* will be applied to the database.
|
||||
*/
|
||||
void commitTransaction(Transaction txn) throws DbException;
|
||||
|
||||
/**
|
||||
* Stores a contact associated with the given local and remote pseudonyms,
|
||||
* and returns an ID for the contact.
|
||||
|
||||
15
briar-api/src/org/briarproject/api/db/Transaction.java
Normal file
15
briar-api/src/org/briarproject/api/db/Transaction.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package org.briarproject.api.db;
|
||||
|
||||
/** A wrapper around a database transaction. */
|
||||
public class Transaction {
|
||||
|
||||
private final Object txn;
|
||||
|
||||
public Transaction(Object txn) {
|
||||
this.txn = txn;
|
||||
}
|
||||
|
||||
public Object unbox() {
|
||||
return txn;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user