
de.zalando.sprocwrapper.dsprovider.SingleDataSourceProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zalando-sprocwrapper Show documentation
Show all versions of zalando-sprocwrapper Show documentation
Library to make PostgreSQL stored procedures available through simple Java "*SProcService" interfaces
including automatic object serialization and deserialization (using typemapper and
convention-over-configuration). Supports sharding, advisory locking, statement timeouts and PostgreSQL types
such as enums and hstore.
package de.zalando.sprocwrapper.dsprovider;
import java.util.List;
import javax.sql.DataSource;
import com.google.common.collect.Lists;
public class SingleDataSourceProvider implements DataSourceProvider {
private DataSource dataSource;
public SingleDataSourceProvider() { }
public SingleDataSourceProvider(final DataSource ds) {
dataSource = ds;
}
@Override
public int getDataSourceId(final int virtualShardId) {
return 1;
}
@Override
public DataSource getDataSource(final int id) {
return dataSource;
}
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(final DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public List getDistinctShardIds() {
return Lists.newArrayList(1);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy