/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.prestosql.plugin.hive.rubix;

import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Scopes;
import io.prestosql.plugin.hive.DynamicConfigurationProvider;

import static com.google.inject.multibindings.Multibinder.newSetBinder;
import static io.airlift.configuration.ConfigBinder.configBinder;

public class RubixModule
        implements Module
{
    @Override
    public void configure(Binder binder)
    {
        configBinder(binder).bindConfig(RubixConfig.class);
        binder.bind(RubixConfigurationInitializer.class).in(Scopes.SINGLETON);
        newSetBinder(binder, DynamicConfigurationProvider.class).addBinding().to(RubixConfigurationInitializer.class).in(Scopes.SINGLETON);
        binder.bind(RubixInitializer.class).in(Scopes.SINGLETON);
    }
}

@@ -691,78 +691,407 @@
 ect.
-Scopes;%0Aimport io.prestosql.plugin.hive.DynamicConfigurationProvider;%0A
+Provides;%0Aimport com.google.inject.Scopes;%0Aimport io.prestosql.plugin.base.CatalogName;%0Aimport io.prestosql.plugin.hive.DynamicConfigurationProvider;%0Aimport io.prestosql.plugin.hive.HdfsConfigurationInitializer;%0A%0Aimport javax.inject.Singleton;%0A%0Aimport java.util.Set;%0A%0Aimport static com.google.common.base.Preconditions.checkArgument;%0Aimport static com.google.common.collect.Iterables.getOnlyElement;
 %0Aimp
@@ -1627,67 +1627,600 @@
     
+%7D%0A%0A
     
-binder.bind(RubixInitializer.class).in(Scopes.SINGLETON
+@Provides%0A    @Singleton%0A    public RubixInitializer createRubixInitializer(%0A            CatalogName catalogName,%0A            Set%3CDynamicConfigurationProvider%3E configProviders,%0A            HdfsConfigurationInitializer hdfsConfigurationInitializer)%0A    %7B%0A        checkArgument(configProviders.size() == 1, %22Rubix cache does not work with dynamic configuration providers%22);%0A        RubixConfigurationInitializer configProvider = (RubixConfigurationInitializer) getOnlyElement(configProviders);%0A        return new RubixInitializer(catalogName, configProvider, hdfsConfigurationInitializer
 );%0A 

Make sure Rubix cache is not used with dynamic config providers