Use start/stop lifecycle callbacks rather than pause/resume.

Also fixed a couple of bugs.
This commit is contained in:
akwizgran
2016-10-12 16:55:00 +01:00
parent b3e5d1ff85
commit 50a70f7649
51 changed files with 563 additions and 538 deletions

View File

@@ -1,17 +1,25 @@
package org.briarproject.api.crypto;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/** Annotation for injecting the executor for long-running crypto tasks. */
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Annotation for injecting the executor for long-running crypto tasks. Also
* used for annotating methods that should run on the crypto executor.
* <p>
* The contract of this executor is that tasks may be run concurrently, and
* submitting a task will never block. Tasks must not run indefinitely. Tasks
* submitted during shutdown are discarded.
*/
@Qualifier
@Target({FIELD, METHOD, PARAMETER})
@Retention(RUNTIME)
public @interface CryptoExecutor {}
public @interface CryptoExecutor {
}

View File

@@ -1,21 +1,23 @@
package org.briarproject.api.db;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Annotation for injecting the executor for database tasks.
* Annotation for injecting the executor for database tasks. Also used for
* annotating methods that should run on the database executor.
* <p>
* The contract of this executor is that tasks are executed in the order
* they're submitted, tasks are not executed concurrently, and submitting a
* task will never block.
* The contract of this executor is that tasks are run in the order they're
* submitted, tasks are not run concurrently, and submitting a task will never
* block. Tasks must not run indefinitely. Tasks submitted during shutdown are
* discarded.
*/
@Qualifier
@Target({ FIELD, METHOD, PARAMETER })

View File

@@ -1,5 +1,6 @@
package org.briarproject.api.event;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.messaging.PrivateMessageHeader;
import org.briarproject.api.sync.GroupId;
@@ -9,11 +10,13 @@ import org.briarproject.api.sync.GroupId;
public class PrivateMessageReceivedEvent extends Event {
private final PrivateMessageHeader messageHeader;
private final ContactId contactId;
private final GroupId groupId;
public PrivateMessageReceivedEvent(PrivateMessageHeader messageHeader,
GroupId groupId) {
ContactId contactId, GroupId groupId) {
this.messageHeader = messageHeader;
this.contactId = contactId;
this.groupId = groupId;
}
@@ -21,6 +24,10 @@ public class PrivateMessageReceivedEvent extends Event {
return messageHeader;
}
public ContactId getContactId() {
return contactId;
}
public GroupId getGroupId() {
return groupId;
}

View File

@@ -1,17 +1,25 @@
package org.briarproject.api.lifecycle;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/** Annotation for injecting the executor used by long-lived IO tasks. */
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Annotation for injecting the executor for long-running IO tasks. Also used
* for annotating methods that should run on the UI executor.
* <p>
* The contract of this executor is that tasks may be run concurrently, and
* submitting a task will never block. Tasks may run indefinitely. Tasks
* submitted during shutdown are discarded.
*/
@Qualifier
@Target({ FIELD, METHOD, PARAMETER })
@Target({FIELD, METHOD, PARAMETER})
@Retention(RUNTIME)
public @interface IoExecutor {}
public @interface IoExecutor {
}