Spring Framework AbstractRoutingDataSource - 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 AbstractRoutingDataSource class.

This code example shows how to use the following methods:
package org.dayatang.dsrouter.datasource.examples; 
 
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
 
import java.sql.Connection;
import java.sql.SQLException;
 
public class CustomerRoutingDataSource extends AbstractRoutingDataSource {
 
	private static final Logger logger = LoggerFactory 
			.getLogger(CustomerRoutingDataSource.class); 
 
	@Override 
	protected Object determineCurrentLookupKey() {
		return CustomerContextHolder.getCustomerType(); 
	} 
 
	public Connection getConnection() throws SQLException {

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
package expenses.context; 
 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; 
 
public class TenantRoutingDataSource extends AbstractRoutingDataSource { 
	@Autowired 
	private TenantContext tenantContext; 
 
	@Override 
	protected Object determineCurrentLookupKey() { 
		return tenantContext.getTenantId(); 
	} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 *  
 * @author Regunath B 
 * @version 1.0, 23/05/2012 
 */ 
 
public class ShardRoutingDataSource extends AbstractRoutingDataSource implements InfrastructureProxy {
 
	/** 
	 * Overriden superclass method. Determines the lookup key by calling {@link ShardedEntity#getShardHint()}  
	 * on the object returned from {@link ShardedEntityContextHolder#getShardedEntity()} 
	 * @see org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource#determineCurrentLookupKey() 
	 */ 
	protected Object determineCurrentLookupKey() {
		// Returns an empty string as the shard hint if the context holder doesnot have any sharded entity. Usually the case during server startup 
		// when used in conjunction with frameworks like Hibernate. The default data source will be used in this case. 
		return ShardedEntityContextHolder.getShardedEntity()== null ? "" : ShardedEntityContextHolder.getShardedEntity().getShardHint(); 
	} 
	 
	/** 
	 * Interface method implementation. This InfrastructureProxy returns the underlying target data source - unwrapping it if it is a 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
import org.sentilo.agent.relational.utils.ThreadLocalProperties; 
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
 
public class SentiloRoutingDataSource extends AbstractRoutingDataSource {
 
  private final Logger logger = LoggerFactory.getLogger(SentiloRoutingDataSource.class); 
 
  @Override 
  protected Object determineCurrentLookupKey() {
    final String dsName = ThreadLocalProperties.get();
    logger.debug("Ds to use {}", dsName);
    return dsName;
  } 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 * Experimental 
 *  
 * @author janv 
 * @since 4.2 
 */ 
public class TenantRoutingDataSource extends AbstractRoutingDataSourceMap<String, DataSource> tenantDataSources = new HashMap<String, DataSource>();
     
    private BasicDataSource baseDataSource;
     
    private TenantService tenantService;
     
    public void setTenantService(TenantService tenantService)
    { 
        this.tenantService = tenantService;
    } 
     
    public void setBaseDataSource(BasicDataSource baseDataSource)
    { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
/** 
 *类名:DynamicDataSource.java 
 *功能:动态数据源类 
 */ 
public class DynamicDataSource extends AbstractRoutingDataSource { 
 
	/*  
	 * 该方法必须要重写  方法是为了根据数据库标示符取得当前的数据库 
	 */ 
	@Override 
	protected Object determineCurrentLookupKey() { 
		DataSourceType dataSourceType= DataSourceContextHolder.getDataSourceType(); 
		return dataSourceType; 
	} 
 
	@Override 
	public void setDataSourceLookup(DataSourceLookup dataSourceLookup) { 
		super.setDataSourceLookup(dataSourceLookup); 
	} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
package com.zhaidaosi.game.jgframework.common.spring; 
 
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; 
 
public class DynamicDataSource extends AbstractRoutingDataSource { 
 
    private String defaultDatabase; 
 
    @Override 
    protected Object determineCurrentLookupKey() { 
        return DataSourceSwitcher.getDataSource(); 
    } 
 
    public void setDefaultDatabase(String defaultDatabase) { 
        this.defaultDatabase = defaultDatabase; 
        DataSourceSwitcher.setDefaultDatabase(this.defaultDatabase); 
    } 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Spring Framework AbstractRoutingDataSource Methods: