com.github.zhengframework.jdbc.jdbi.JdbiProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zheng-jdbc-jdbi Show documentation
Show all versions of zheng-jdbc-jdbi Show documentation
zheng framework module: jdbc jdbi support
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;
}
}