All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.instaclustr.icarus.service.ServicesModule Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package com.instaclustr.icarus.service;

import static com.google.inject.multibindings.OptionalBinder.newOptionalBinder;
import static com.google.inject.util.Types.newParameterizedType;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
import com.instaclustr.esop.impl.backup.BackupOperationRequest;
import com.instaclustr.esop.impl.restore.RestoreOperationRequest;
import com.instaclustr.icarus.coordination.IcarusBackupOperationCoordinator;
import com.instaclustr.icarus.coordination.IcarusRestoreOperationCoordinator;
import com.instaclustr.operations.OperationCoordinator;
import jmx.org.apache.cassandra.service.CassandraJMXService;

public class ServicesModule extends AbstractModule {

    @Provides
    @Singleton
    public CassandraStatusService getCassandraStatusService(final CassandraJMXService cassandraJMXService) {
        return new CassandraStatusService(cassandraJMXService);
    }

    @Override
    protected void configure() {

        @SuppressWarnings("unchecked") final TypeLiteral> operationCoordinator =
                (TypeLiteral>) TypeLiteral.get(newParameterizedType(OperationCoordinator.class, RestoreOperationRequest.class));

        @SuppressWarnings("unchecked") final TypeLiteral> backupOperationCoordinator =
                (TypeLiteral>) TypeLiteral.get(newParameterizedType(OperationCoordinator.class, BackupOperationRequest.class));

        newOptionalBinder(binder(), operationCoordinator).setBinding().to(IcarusRestoreOperationCoordinator.class);
        newOptionalBinder(binder(), backupOperationCoordinator).setBinding().to(IcarusBackupOperationCoordinator.class);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy