Pass database key into LifecycleManager.

This commit is contained in:
akwizgran
2018-07-27 15:38:48 +01:00
parent 58d09d0742
commit 287f3760cd
14 changed files with 31 additions and 51 deletions

View File

@@ -16,7 +16,7 @@ public interface ContactManager {
/**
* Registers a hook to be called whenever a contact is added or removed.
* This method should be called before
* {@link LifecycleManager#startServices()}.
* {@link LifecycleManager#startServices(SecretKey)}.
*/
void registerContactHook(ContactHook hook);

View File

@@ -1,5 +1,6 @@
package org.briarproject.bramble.api.lifecycle;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DatabaseComponent;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.sync.Client;
@@ -16,7 +17,7 @@ import java.util.concurrent.ExecutorService;
public interface LifecycleManager {
/**
* The result of calling {@link #startServices()}.
* The result of calling {@link #startServices(SecretKey)}.
*/
enum StartResult {
ALREADY_RUNNING,
@@ -42,27 +43,27 @@ public interface LifecycleManager {
/**
* Registers a {@link Service} to be started and stopped. This method
* should be called before {@link #startServices()}.
* should be called before {@link #startServices(SecretKey)}.
*/
void registerService(Service s);
/**
* Registers a {@link Client} to be started. This method should be called
* before {@link #startServices()}.
* before {@link #startServices(SecretKey)}.
*/
void registerClient(Client c);
/**
* Registers an {@link ExecutorService} to be shut down. This method
* should be called before {@link #startServices()}.
* should be called before {@link #startServices(SecretKey)}.
*/
void registerForShutdown(ExecutorService e);
/**
* Opens the {@link DatabaseComponent} and starts any registered
* {@link Client Clients} and {@link Service Services}.
* Opens the {@link DatabaseComponent} using the given key and starts any
* registered {@link Client Clients} and {@link Service Services}.
*/
StartResult startServices();
StartResult startServices(SecretKey dbKey);
/**
* Stops any registered {@link Service Services}, shuts down any

View File

@@ -1,5 +1,6 @@
package org.briarproject.bramble.api.sync;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.db.Metadata;
import org.briarproject.bramble.api.db.Transaction;
@@ -35,7 +36,8 @@ public interface ValidationManager {
/**
* Registers the message validator for the given client. This method
* should be called before {@link LifecycleManager#startServices()}.
* should be called before
* {@link LifecycleManager#startServices(SecretKey)}.
*/
void registerMessageValidator(ClientId c, int majorVersion,
MessageValidator v);
@@ -43,7 +45,8 @@ public interface ValidationManager {
/**
* Registers the incoming message hook for the given client. The hook will
* be called once for each incoming message that passes validation. This
* method should be called before {@link LifecycleManager#startServices()}.
* method should be called before
* {@link LifecycleManager#startServices(SecretKey)}.
*/
void registerIncomingMessageHook(ClientId c, int majorVersion,
IncomingMessageHook hook);

View File

@@ -2,6 +2,7 @@ package org.briarproject.bramble.api.versioning;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.db.Transaction;
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
@@ -25,7 +26,7 @@ public interface ClientVersioningManager {
/**
* Registers a client that will be advertised to contacts. The hook will
* be called when the visibility of the client changes. This method should
* be called before {@link LifecycleManager#startServices()}.
* be called before {@link LifecycleManager#startServices(SecretKey)}.
*/
void registerClient(ClientId clientId, int majorVersion, int minorVersion,
ClientVersioningHook hook);