Semi-encapsulated the core/api dependency graphs and created a proper structure to load eager singletons

This commit is contained in:
Ernir Erlingsson
2016-03-10 22:31:08 +01:00
parent 10764d727b
commit 6f233070fe
28 changed files with 483 additions and 225 deletions

View File

@@ -6,6 +6,13 @@ import java.util.logging.Logger;
import android.app.Application;
import android.content.Context;
import org.briarproject.CoreComponent;
import org.briarproject.CoreEagerSingletons;
import org.briarproject.DaggerCoreComponent;
import org.briarproject.plugins.PluginsModuleExtension;
import org.briarproject.system.PlatformModuleExtension;
import org.briarproject.system.SystemModuleExtension;
public class BriarApplication extends Application {
private static final Logger LOG =
@@ -23,14 +30,21 @@ public class BriarApplication extends Application {
CrashHandler newHandler = new CrashHandler(ctx, oldHandler);
Thread.setDefaultUncaughtExceptionHandler(newHandler);
CoreComponent coreComponent = DaggerCoreComponent.builder()
.systemModule(new SystemModuleExtension(this))
.platformModule(new PlatformModuleExtension(this))
.pluginsModule(new PluginsModuleExtension(this))
.build();
applicationComponent = DaggerAndroidComponent.builder()
.appModule(new AppModule(this))
.androidModule(new AndroidModule())
.coreComponent(coreComponent)
.build();
// We need to load the eager singletons directly after making the
// dependency graph
AndroidModule.injectEager(applicationComponent);
// We need to load the eager singletons directly after making the
// dependency graphs
CoreEagerSingletons.initEagerSingletons(coreComponent);
AndroidEagerSingletons.initEagerSingletons(applicationComponent);
}
public AndroidComponent getApplicationComponent() {