jdbishard.dropwizard.testapp.TestApp Maven / Gradle / Ivy
The newest version!
package jdbishard.dropwizard.testapp;
import com.google.common.annotations.VisibleForTesting;
import java.util.UUID;
import io.dropwizard.Application;
import io.dropwizard.jdbi.DBIFactory;
import io.dropwizard.setup.Environment;
import jdbishard.dropwizard.JDBIManager;
import jdbishard.dropwizard.testapp.dao.ClientDAO;
import jdbishard.dropwizard.testapp.dao.ClientShardDAO;
import jdbishard.dropwizard.testapp.staticsharding.StaticShardService;
import jdbishard.jdbi.DAORegistry;
import jdbishard.jdbi.DBIRegistry;
import jdbishard.jdbi.NoOpDBIInitializer;
import jdbishard.sharding.IdOnlyShardNamer;
import jdbishard.sharding.ShardRegistry;
public class TestApp extends Application {
private JDBIManager jdbiManager;
private ClientDAO clientDAO;
@Override
public void run(TestAppConfig configuration, Environment environment) throws Exception {
final ShardRegistry shardRegistry = new ShardRegistry<>();
final DAORegistry daoRegistry = new DAORegistry<>();
final DBIFactory dbiFactory = new DBIFactory();
jdbiManager = new JDBIManager<>(
new StaticShardService(),
shardRegistry,
new DBIRegistry<>(),
daoRegistry,
dbiFactory,
environment,
configuration.getDataSourceFactory(),
new NoOpDBIInitializer(),
new IdOnlyShardNamer());
clientDAO = new ClientDAO(shardRegistry, daoRegistry);
daoRegistry.registerType(ClientShardDAO.class);
jdbiManager.updateObjects();
}
@VisibleForTesting
public ClientDAO getClientDAO() {
return clientDAO;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy