Search in sources :

Example 1 with DAO

use of io.divide.shared.server.DAO in project divide by HiddenStage.

the class BackendModule method configure.

@Override
protected final void configure() {
    logConfiguration();
    if (config == null)
        throw new IllegalStateException("Config can not be null");
    // ORDER MATTER
    bind(type).toInstance(config);
    bind(Config.class).toInstance(config);
    bind(Backend.class).in(Singleton.class);
    bind(Storage.class).toInstance(new XmlStorage(new File(config.fileSavePath + "storage.xml"), Storage.MODE_WORLD_WRITEABLE));
    bind(AccountStorage.class).toInstance(new XmlAccoutStorage(new File(config.fileSavePath + "accounts.xml")));
    bind(new TypeLiteral<DAO<BackendObject, BackendObject>>() {
    }).to(new TypeLiteral<LocalStorageIBoxDb<BackendObject, BackendObject>>() {
    }).in(Singleton.class);
    // ugly but required, doesnt allow binding to itself
    if (AuthManager.class.equals(getAuthManagerClass())) {
        bind(AuthManager.class).in(Singleton.class);
    } else {
        bind(AuthManager.class).to(getAuthManagerClass()).in(Singleton.class);
    }
    if (DataManager.class.equals(getDataManagerClass())) {
        bind(DataManager.class).in(Singleton.class);
    } else {
        bind(DataManager.class).to(getDataManagerClass()).in(Singleton.class);
    }
    if (ObjectManager.class.equals(getObjectManagerClass())) {
        bind(ObjectManager.class).in(Singleton.class);
    } else {
        bind(ObjectManager.class).to(getObjectManagerClass()).in(Singleton.class);
    }
    requestStaticInjection(Backend.class);
    requestStaticInjection(BackendUser.class);
    requestStaticInjection(BackendServices.class);
    additionalConfig(config);
}
Also used : AuthManager(io.divide.client.auth.AuthManager) DataManager(io.divide.client.data.DataManager) XmlStorage(io.divide.shared.file.XmlStorage) XmlAccoutStorage(io.divide.client.auth.credentials.XmlAccoutStorage) AccountStorage(io.divide.client.auth.AccountStorage) ObjectManager(io.divide.client.data.ObjectManager) XmlAccoutStorage(io.divide.client.auth.credentials.XmlAccoutStorage) Storage(io.divide.shared.file.Storage) AccountStorage(io.divide.client.auth.AccountStorage) XmlStorage(io.divide.shared.file.XmlStorage) DAO(io.divide.shared.server.DAO) TypeLiteral(com.google.inject.TypeLiteral) File(java.io.File)

Example 2 with DAO

use of io.divide.shared.server.DAO in project divide by HiddenStage.

the class MockAndroidModule method additionalConfig.

@Override
protected void additionalConfig(AndroidConfig config) {
    super.additionalConfig(config);
    // ORDER MATTER
    try {
        bind(KeyManager.class).toInstance(new MockKeyManager("someKey"));
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }
    bind(new TypeLiteral<DAO<TransientObject, TransientObject>>() {
    }).to(new TypeLiteral<MockLocalStorage<TransientObject, TransientObject>>() {
    }).in(Singleton.class);
}
Also used : DAO(io.divide.shared.server.DAO) TypeLiteral(com.google.inject.TypeLiteral) MockKeyManager(io.divide.client.auth.MockKeyManager) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) TransientObject(io.divide.shared.transitory.TransientObject) MockKeyManager(io.divide.client.auth.MockKeyManager) KeyManager(io.divide.shared.server.KeyManager)

Aggregations

TypeLiteral (com.google.inject.TypeLiteral)2 DAO (io.divide.shared.server.DAO)2 AccountStorage (io.divide.client.auth.AccountStorage)1 AuthManager (io.divide.client.auth.AuthManager)1 MockKeyManager (io.divide.client.auth.MockKeyManager)1 XmlAccoutStorage (io.divide.client.auth.credentials.XmlAccoutStorage)1 DataManager (io.divide.client.data.DataManager)1 ObjectManager (io.divide.client.data.ObjectManager)1 Storage (io.divide.shared.file.Storage)1 XmlStorage (io.divide.shared.file.XmlStorage)1 KeyManager (io.divide.shared.server.KeyManager)1 TransientObject (io.divide.shared.transitory.TransientObject)1 File (java.io.File)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1