merged with master

This commit is contained in:
Ernir Erlingsson
2016-03-03 15:02:54 +01:00
parent ac5d68df81
commit 95d89553d5
15 changed files with 209 additions and 107 deletions

View File

@@ -1,7 +1,5 @@
package org.briarproject.clients;
import com.google.inject.Inject;
import org.briarproject.api.FormatException;
import org.briarproject.api.clients.ClientHelper;
import org.briarproject.api.data.BdfDictionary;
@@ -30,6 +28,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
class ClientHelperImpl implements ClientHelper {

View File

@@ -1,19 +1,36 @@
package org.briarproject.clients;
import com.google.inject.AbstractModule;
import org.briarproject.api.clients.ClientHelper;
import org.briarproject.api.clients.MessageQueueManager;
import org.briarproject.api.clients.PrivateGroupFactory;
import org.briarproject.api.clients.QueueMessageFactory;
import org.briarproject.api.data.BdfReaderFactory;
import org.briarproject.api.data.BdfWriterFactory;
import org.briarproject.api.data.MetadataEncoder;
import org.briarproject.api.data.MetadataParser;
import org.briarproject.api.db.DatabaseComponent;
import org.briarproject.api.sync.GroupFactory;
import org.briarproject.api.sync.MessageFactory;
public class ClientsModule extends AbstractModule {
import dagger.Module;
import dagger.Provides;
@Override
protected void configure() {
bind(ClientHelper.class).to(ClientHelperImpl.class);
bind(MessageQueueManager.class).to(MessageQueueManagerImpl.class);
bind(PrivateGroupFactory.class).to(PrivateGroupFactoryImpl.class);
bind(QueueMessageFactory.class).to(QueueMessageFactoryImpl.class);
@Module
public class ClientsModule {
@Provides
ClientHelper provideClientHelper(DatabaseComponent db,
MessageFactory messageFactory, BdfReaderFactory bdfReaderFactory,
BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
MetadataEncoder metadataEncoder) {
return new ClientHelperImpl(db, messageFactory, bdfReaderFactory,
bdfWriterFactory, metadataParser, metadataEncoder);
}
@Provides
PrivateGroupFactory providePrivateGroupFactory(GroupFactory groupFactory,
BdfWriterFactory bdfWriterFactory) {
return new PrivateGroupFactoryImpl(groupFactory, bdfWriterFactory);
}
bind(QueueMessageFactory.class).to(QueueMessageFactoryImpl.class);
}

View File

@@ -19,22 +19,9 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
<<<<<<< 08099714bab27d1ed48a8bee431a35a38098ecec
class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
=======
import javax.inject.Inject;
import static java.util.logging.Level.WARNING;
import static org.briarproject.api.db.StorageStatus.ACTIVE;
import static org.briarproject.api.db.StorageStatus.ADDING;
import static org.briarproject.api.db.StorageStatus.REMOVING;
class ContactManagerImpl implements ContactManager, Service,
RemoveIdentityHook {
private static final Logger LOG =
Logger.getLogger(ContactManagerImpl.class.getName());
>>>>>>> Switched Roboguice/Guice out for Dagger 2
class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
private final DatabaseComponent db;
private final KeyManager keyManager;

View File

@@ -17,7 +17,6 @@ public class ContactModule {
ContactManager getContactManager(LifecycleManager lifecycleManager,
IdentityManager identityManager,
ContactManagerImpl contactManager) {
lifecycleManager.register(contactManager);
identityManager.registerRemoveIdentityHook(contactManager);
return contactManager;
}

View File

@@ -27,11 +27,10 @@ public class ForumModule {
@Provides
@Singleton
ForumManager provideForumManager(DatabaseComponent db,
ContactManager contactManager,
BdfReaderFactory bdfReaderFactory, MetadataEncoder metadataEncoder,
MetadataParser metadataParser) {
return new ForumManagerImpl(db, contactManager, bdfReaderFactory,
metadataEncoder, metadataParser);
ContactManager contactManager, BdfReaderFactory bdfReaderFactory,
MetadataEncoder metadataEncoder, MetadataParser metadataParser) {
return new ForumManagerImpl(db, bdfReaderFactory, metadataEncoder,
metadataParser);
}
@Provides

View File

@@ -37,12 +37,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
<<<<<<< 08099714bab27d1ed48a8bee431a35a38098ecec
=======
import javax.inject.Inject;
import static java.util.logging.Level.WARNING;
>>>>>>> Switched Roboguice/Guice out for Dagger 2
import static org.briarproject.api.forum.ForumConstants.FORUM_SALT_LENGTH;
import static org.briarproject.api.forum.ForumConstants.MAX_FORUM_NAME_LENGTH;
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;

View File

@@ -11,22 +11,9 @@ import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
<<<<<<< 08099714bab27d1ed48a8bee431a35a38098ecec
class IdentityManagerImpl implements IdentityManager {
=======
import javax.inject.Inject;
import static java.util.logging.Level.WARNING;
import static org.briarproject.api.db.StorageStatus.ACTIVE;
import static org.briarproject.api.db.StorageStatus.ADDING;
import static org.briarproject.api.db.StorageStatus.REMOVING;
class IdentityManagerImpl implements IdentityManager, Service {
private static final Logger LOG =
Logger.getLogger(IdentityManagerImpl.class.getName());
>>>>>>> Switched Roboguice/Guice out for Dagger 2
class IdentityManagerImpl implements IdentityManager {
private final DatabaseComponent db;
private final List<AddIdentityHook> addHooks;
private final List<RemoveIdentityHook> removeHooks;

View File

@@ -1,8 +1,14 @@
package org.briarproject.identity;
import org.briarproject.api.crypto.CryptoComponent;
import org.briarproject.api.data.BdfWriterFactory;
import org.briarproject.api.data.ObjectReader;
import org.briarproject.api.db.DatabaseComponent;
import org.briarproject.api.event.EventBus;
import org.briarproject.api.identity.Author;
import org.briarproject.api.identity.AuthorFactory;
import org.briarproject.api.identity.IdentityManager;
import org.briarproject.api.system.Clock;
import javax.inject.Singleton;
@@ -13,8 +19,18 @@ import dagger.Provides;
public class IdentityModule {
@Provides
@Singleton
IdentityManager provideIdendityModule(DatabaseComponent db, EventBus eventBus) {
return new IdentityManagerImpl(db, eventBus);
AuthorFactory provideAuthorFactory(CryptoComponent crypto,
BdfWriterFactory bdfWriterFactory, Clock clock) {
return new AuthorFactoryImpl(crypto, bdfWriterFactory, clock);
}
@Provides
IdentityManager provideIdendityModule(DatabaseComponent db) {
return new IdentityManagerImpl(db);
}
@Provides
ObjectReader<Author> provideAuthorReader(AuthorFactory authorFactory) {
return new AuthorReader(authorFactory);
}
}

View File

@@ -30,13 +30,12 @@ public class InvitationModule {
BdfWriterFactory bdfWriterFactory,
StreamReaderFactory streamReaderFactory,
StreamWriterFactory streamWriterFactory,
AuthorFactory authorFactory, GroupFactory groupFactory,
KeyManager keyManager, ConnectionManager connectionManager,
AuthorFactory authorFactory, ConnectionManager connectionManager,
IdentityManager identityManager, ContactManager contactManager,
Clock clock, PluginManager pluginManager) {
return new InvitationTaskFactoryImpl(crypto, bdfReaderFactory,
bdfWriterFactory, streamReaderFactory, streamWriterFactory,
authorFactory, groupFactory, keyManager, connectionManager,
identityManager, contactManager, clock, pluginManager);
authorFactory, connectionManager, identityManager,
contactManager, clock, pluginManager);
}
}

View File

@@ -5,6 +5,7 @@ import javax.inject.Singleton;
import org.briarproject.api.event.EventBus;
import org.briarproject.api.lifecycle.IoExecutor;
import org.briarproject.api.lifecycle.LifecycleManager;
import org.briarproject.api.plugins.BackoffFactory;
import org.briarproject.api.plugins.ConnectionManager;
import org.briarproject.api.plugins.ConnectionRegistry;
import org.briarproject.api.plugins.PluginManager;
@@ -14,6 +15,7 @@ import org.briarproject.api.transport.KeyManager;
import org.briarproject.api.transport.StreamReaderFactory;
import org.briarproject.api.transport.StreamWriterFactory;
import java.security.SecureRandom;
import java.util.concurrent.Executor;
import dagger.Module;
@@ -23,10 +25,16 @@ import dagger.Provides;
@Module
public class PluginsModule {
@Provides
BackoffFactory provideBackoffFactory() {
return new BackoffFactoryImpl();
}
@Provides
Poller providePoller(@IoExecutor Executor ioExecutor,
ConnectionRegistry connectionRegistry, Timer timer) {
return new PollerImpl(ioExecutor, connectionRegistry, timer);
ConnectionRegistry connectionRegistry, SecureRandom random,
Timer timer) {
return new PollerImpl(ioExecutor, connectionRegistry, random, timer);
}
@Provides

View File

@@ -9,12 +9,10 @@ import org.briarproject.api.event.EventBus;
import org.briarproject.api.identity.Author;
import org.briarproject.api.identity.AuthorFactory;
import org.briarproject.api.lifecycle.LifecycleManager;
import org.briarproject.api.sync.Group;
import org.briarproject.api.sync.GroupFactory;
import org.briarproject.api.sync.MessageFactory;
import org.briarproject.api.sync.PacketReaderFactory;
import org.briarproject.api.sync.PacketWriterFactory;
import org.briarproject.api.sync.PrivateGroupFactory;
import org.briarproject.api.sync.SyncSessionFactory;
import org.briarproject.api.sync.ValidationManager;
import org.briarproject.api.system.Clock;
@@ -29,12 +27,6 @@ import dagger.Provides;
@Module
public class SyncModule {
@Provides
AuthorFactory provideAuthFactory(CryptoComponent crypto,
BdfWriterFactory bdfWriterFactory, Clock clock) {
return new AuthorFactoryImpl(crypto, bdfWriterFactory, clock);
}
@Provides
GroupFactory provideGroupFactory(CryptoComponent crypto) {
return new GroupFactoryImpl(crypto);
@@ -55,12 +47,6 @@ public class SyncModule {
return new PacketWriterFactoryImpl();
}
@Provides
PrivateGroupFactory providePrivateGroupFactory(GroupFactory groupFactory,
BdfWriterFactory bdfWriterFactory) {
return new PrivateGroupFactoryImpl(groupFactory, bdfWriterFactory);
}
@Provides
@Singleton
SyncSessionFactory provideSyncSessionFactory(DatabaseComponent db,
@@ -71,12 +57,6 @@ public class SyncModule {
packetReaderFactory, packetWriterFactory);
}
@Provides
ObjectReader<Author> getAuthorReader(AuthorFactory authorFactory) {
return new AuthorReader(authorFactory);
}
@Provides
@Singleton
ValidationManager getValidationManager(LifecycleManager lifecycleManager,