Spring Framework AbstractDataSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework AbstractDataSource class.

This code example shows how to use the following methods:
 * 
 * <p>All methods throw {@link UnsupportedOperationException}. 
 * 
 * @author Rick Evans 
 */ 
class StubDataSource extends AbstractDataSource { 
 
	@Override 
	public Connection getConnection() throws SQLException { 
		throw new UnsupportedOperationException(); 
	} 
 
	@Override 
	public Connection getConnection(String username, String password) throws SQLException { 
		throw new UnsupportedOperationException(); 
	} 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 * @since 2.0.1 
 * @see #setTargetDataSources 
 * @see #setDefaultTargetDataSource 
 * @see #determineCurrentLookupKey() 
 */ 
public abstract class AbstractRoutingDataSource extends AbstractDataSource implements InitializingBean {
 
	private Map<Object, Object> targetDataSources;
 
	private Object defaultTargetDataSource;
 
	private boolean lenientFallback = true;
 
	private DataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
 
	private Map<Object, DataSource> resolvedDataSources;
 
	private DataSource resolvedDefaultDataSource;
 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 *  
 * The {@link RoutingDataSourceService} is responsible for returning the 
 * appropriate {@link DataSource} for the tenant of this request. 
 */ 
@Service(value = "routingDataSource") 
public class RoutingDataSource extends AbstractDataSource {
 
    @Autowired 
    private RoutingDataSourceServiceFactory dataSourceServiceFactory;
 
    @Override 
    public Connection getConnection() throws SQLException {
        return determineTargetDataSource().getConnection();
    } 
 
    private DataSource determineTargetDataSource() {
        return this.dataSourceServiceFactory.determineDataSourceService().retrieveDataSource();
    } 
 
    @Override 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
    private static class TwoConnectionsDataSource extends AbstractDataSource {
        private final DataSource[] dataSources;
        private int count;
 
        public TwoConnectionsDataSource(DataSource dataSource) throws SQLException {
            dataSources = new DataSource[] {
                    new SingleConnectionDataSource(dataSource.getConnection(), true),
                    new SingleConnectionDataSource(dataSource.getConnection(), true)
            }; 
        } 
 
        public Connection getConnection() throws SQLException {
            return dataSources[count++ % dataSources.length].getConnection();
        } 
 
        public Connection getConnection(String username, String password) throws SQLException {
            return null; 
        } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
/** 
 * This class is an implementation of an DataSource that delegates 
 * the work to a dynamically changeable inner DataSource. 
 * @author Thomas Krause <krauseto@hu-berlin.de> 
 */ 
public class DynamicDataSource extends AbstractDataSource 
{ 
  private DataSource innerDataSource; 
   
  @Override 
  public Connection getConnection() throws SQLException 
  { 
    if(innerDataSource != null) 
    { 
      return innerDataSource.getConnection(); 
    } 
    return null; 
  } 
 
  @Override 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
@Component 
public class SourceAwareDataSource extends AbstractDataSource {
    private final BasicSourceContext sourceContext;
 
    @Autowired 
    public SourceAwareDataSource(final BasicSourceContext sourceContext) {
        this.sourceContext = sourceContext;
    } 
 
    @Override 
    public Connection getConnection() throws SQLException {
        return getActualDataSource().getConnection();
    } 
 
    @Override 
    public Connection getConnection(final String username, final String password) throws SQLException {
        return getActualDataSource().getConnection(username, password);
    } 
 
    private DataSource getActualDataSource() {
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
{ 
    private final DataSource dataSource;
 
    private final ConnectionDecorator decorator;
 
    public DecoratedDataSource( final DataSource dataSource, final ConnectionDecorator decorator )
    { 
        this.dataSource = dataSource;
        this.decorator = decorator;
    } 
 
    private DataSource getInnerDataSource()
    { 
        if (this.dataSource instanceof DecoratedDataSource) {
            return ((DecoratedDataSource)this.dataSource).dataSource;
        } else { 
            return this.dataSource;
        } 
    } 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java