mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Switched Roboguice/Guice out for Dagger 2
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package org.briarproject;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
import org.briarproject.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.lifecycle.Service;
|
||||
@@ -11,37 +9,70 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class TestLifecycleModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(LifecycleManager.class).toInstance(new LifecycleManager() {
|
||||
@Module
|
||||
public class TestLifecycleModule {
|
||||
|
||||
public void register(Service s) {}
|
||||
@Provides
|
||||
LifecycleManager provideLifecycleManager() {
|
||||
return new LifecycleManager() {
|
||||
@Override
|
||||
public void register(Service s) {
|
||||
|
||||
public void registerForShutdown(ExecutorService e) {}
|
||||
}
|
||||
|
||||
public StartResult startServices() { return StartResult.SUCCESS; }
|
||||
@Override
|
||||
public void registerForShutdown(ExecutorService e) {
|
||||
|
||||
public void stopServices() {}
|
||||
}
|
||||
|
||||
public void waitForDatabase() throws InterruptedException {}
|
||||
@Override
|
||||
public StartResult startServices() {
|
||||
return StartResult.SUCCESS;
|
||||
}
|
||||
|
||||
public void waitForStartup() throws InterruptedException {}
|
||||
@Override
|
||||
public void stopServices() {
|
||||
|
||||
public void waitForShutdown() throws InterruptedException {}
|
||||
});
|
||||
bind(ShutdownManager.class).toInstance(new ShutdownManager() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitForDatabase() throws InterruptedException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitForStartup() throws InterruptedException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitForShutdown() throws InterruptedException {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ShutdownManager provideShutdownManager() {
|
||||
return new ShutdownManager() {
|
||||
@Override
|
||||
public int addShutdownHook(Runnable hook) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeShutdownHook(int handle) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
bind(Executor.class).annotatedWith(IoExecutor.class).toInstance(
|
||||
Executors.newCachedThreadPool());
|
||||
};
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IoExecutor
|
||||
Executor provideExecutor() {
|
||||
return Executors.newCachedThreadPool();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user