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

com.github.zhengframework.jdbc.jdbi.JdbiProvider Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.github.zhengframework.jdbc.jdbi;

import java.util.List;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.sql.DataSource;
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.core.spi.JdbiPlugin;

public class JdbiProvider implements Provider {

  private final Provider dataSourceProvider;
  private final Provider> jdbiPluginListProvider;

  @Inject
  public JdbiProvider(Provider dataSourceProvider,
      Provider> jdbiPluginListProvider) {
    this.dataSourceProvider = dataSourceProvider;
    this.jdbiPluginListProvider = jdbiPluginListProvider;
  }

  @Override
  public Jdbi get() {
    List jdbiPluginList = jdbiPluginListProvider.get();
    Jdbi jdbi = Jdbi.create(dataSourceProvider.get());
    for (JdbiPlugin jdbiPlugin : jdbiPluginList) {
      jdbi.installPlugin(jdbiPlugin);
    }
    return jdbi;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy