/*
 * 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.metastore.glue;

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

import static io.airlift.configuration.ConfigBinder.configBinder;
import static org.weakref.jmx.guice.ExportBinder.newExporter;

public class GlueMetastoreModule
        implements Module
{
    @Override
    public void configure(Binder binder)
    {
        configBinder(binder).bindConfig(GlueHiveMetastoreConfig.class);
        binder.bind(ExtendedHiveMetastore.class).to(GlueHiveMetastore.class).in(Scopes.SINGLETON);
        newExporter(binder).export(ExtendedHiveMetastore.class)
                .as(generator -> generator.generatedNameOf(GlueHiveMetastore.class));
    }
}

@@ -663,22 +663,22 @@
 .inject.
-Module
+Scopes
 ;%0Aimport
@@ -700,81 +700,538 @@
 ect.
-Scopes;%0Aimport io.prestosql.plugin.hive.metastore.ExtendedHiveMetastore;%0A
+multibindings.Multibinder;%0Aimport io.airlift.configuration.AbstractConfigurationAwareModule;%0Aimport io.prestosql.plugin.hive.ForRecordingHiveMetastore;%0Aimport io.prestosql.plugin.hive.HiveClientConfig;%0Aimport io.prestosql.plugin.hive.metastore.ExtendedHiveMetastore;%0Aimport io.prestosql.plugin.hive.metastore.RecordingHiveMetastore;%0Aimport io.prestosql.plugin.hive.metastore.WriteHiveMetastoreRecordingProcedure;%0Aimport io.prestosql.spi.procedure.Procedure;%0A%0Aimport static com.google.inject.multibindings.Multibinder.newSetBinder;
 %0Aimp
@@ -1401,19 +1401,42 @@
     
-implement
+extend
 s 
+AbstractConfigurationAware
 Modu
@@ -1463,28 +1463,27 @@
    p
-ublic void configure
+rotected void setup
 (Bin
@@ -1576,56 +1576,234 @@
 s);%0A
-        binder.bind(ExtendedHiveMetastore.class)
+%0A        if (buildConfigObject(HiveClientConfig.class).getRecordingPath() != null) %7B%0A            binder.bind(ExtendedHiveMetastore.class)%0A                    .annotatedWith(ForRecordingHiveMetastore.class)%0A                    
 .to(
@@ -1826,16 +1826,37 @@
 e.class)
+%0A                    
 .in(Scop
@@ -1882,64 +1882,832 @@
     
-newExporter(binder).export(ExtendedHiveMetastore.class)%0A
+    binder.bind(GlueHiveMetastore.class).in(Scopes.SINGLETON);%0A            newExporter(binder).export(GlueHiveMetastore.class).withGeneratedName();%0A%0A            binder.bind(ExtendedHiveMetastore.class).to(RecordingHiveMetastore.class).in(Scopes.SINGLETON);%0A            binder.bind(RecordingHiveMetastore.class).in(Scopes.SINGLETON);%0A            newExporter(binder).export(RecordingHiveMetastore.class).withGeneratedName();%0A%0A            Multibinder%3CProcedure%3E procedures = newSetBinder(binder, Procedure.class);%0A            procedures.addBinding().toProvider(WriteHiveMetastoreRecordingProcedure.class).in(Scopes.SINGLETON);%0A        %7D%0A        else %7B%0A            binder.bind(ExtendedHiveMetastore.class).to(GlueHiveMetastore.class).in(Scopes.SINGLETON);%0A            newExporter(binder).export(ExtendedHiveMetastore.class)%0A    
     
@@ -2788,16 +2788,26 @@
 lass));%0A
+        %7D%0A
     %7D%0A%7D%0A

Add metadata recorder support to Glue