Java Code Examples for org.springframework.jdbc.datasource.lookup.DataSourceLookup

The following examples show how to use org.springframework.jdbc.datasource.lookup.DataSourceLookup. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   Source File: PersistenceUnitReader.java    License: MIT License 5 votes vote down vote up
/**
 * Create a new PersistenceUnitReader.
 * @param resourcePatternResolver the ResourcePatternResolver to use for loading resources
 * @param dataSourceLookup the DataSourceLookup to resolve DataSource names in
 * {@code persistence.xml} files against
 */
public PersistenceUnitReader(ResourcePatternResolver resourcePatternResolver, DataSourceLookup dataSourceLookup) {
	Assert.notNull(resourcePatternResolver, "ResourceLoader must not be null");
	Assert.notNull(dataSourceLookup, "DataSourceLookup must not be null");
	this.resourcePatternResolver = resourcePatternResolver;
	this.dataSourceLookup = dataSourceLookup;
}
 
Example 2
Source Project: java-technology-stack   Source File: PersistenceUnitReader.java    License: MIT License 5 votes vote down vote up
/**
 * Create a new PersistenceUnitReader.
 * @param resourcePatternResolver the ResourcePatternResolver to use for loading resources
 * @param dataSourceLookup the DataSourceLookup to resolve DataSource names in
 * {@code persistence.xml} files against
 */
public PersistenceUnitReader(ResourcePatternResolver resourcePatternResolver, DataSourceLookup dataSourceLookup) {
	Assert.notNull(resourcePatternResolver, "ResourceLoader must not be null");
	Assert.notNull(dataSourceLookup, "DataSourceLookup must not be null");
	this.resourcePatternResolver = resourcePatternResolver;
	this.dataSourceLookup = dataSourceLookup;
}
 
Example 3
Source Project: n2o-framework   Source File: JndiRoutingDataSourceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAddDataSource() throws Exception {
    JndiRoutingDataSource jndiRoutingDataSource = new JndiRoutingDataSource();
    DataSourceLookup dataSourceLookup = mock(DataSourceLookup.class);
    when(dataSourceLookup.getDataSource("test")).thenReturn(mock(DataSource.class));
    jndiRoutingDataSource.setLazyDetermineDS(true);
    jndiRoutingDataSource.setDataSourceLookup(dataSourceLookup);
    jndiRoutingDataSource.addDataSource("test");
    DataSource dataSource1 = dataSourceLookup.getDataSource("test");
    jndiRoutingDataSource.addDataSource("test");
    DataSource dataSource2 = dataSourceLookup.getDataSource("test");
    Assert.assertTrue(dataSource1 == dataSource2);
}
 
Example 4
Source Project: lams   Source File: PersistenceUnitReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new PersistenceUnitReader.
 * @param resourcePatternResolver the ResourcePatternResolver to use for loading resources
 * @param dataSourceLookup the DataSourceLookup to resolve DataSource names in
 * {@code persistence.xml} files against
 */
public PersistenceUnitReader(ResourcePatternResolver resourcePatternResolver, DataSourceLookup dataSourceLookup) {
	Assert.notNull(resourcePatternResolver, "ResourceLoader must not be null");
	Assert.notNull(dataSourceLookup, "DataSourceLookup must not be null");
	this.resourcePatternResolver = resourcePatternResolver;
	this.dataSourceLookup = dataSourceLookup;
}
 
Example 5
/**
 * Create a new PersistenceUnitReader.
 * @param resourcePatternResolver the ResourcePatternResolver to use for loading resources
 * @param dataSourceLookup the DataSourceLookup to resolve DataSource names in
 * {@code persistence.xml} files against
 */
public PersistenceUnitReader(ResourcePatternResolver resourcePatternResolver, DataSourceLookup dataSourceLookup) {
	Assert.notNull(resourcePatternResolver, "ResourceLoader must not be null");
	Assert.notNull(dataSourceLookup, "DataSourceLookup must not be null");
	this.resourcePatternResolver = resourcePatternResolver;
	this.dataSourceLookup = dataSourceLookup;
}
 
Example 6
Source Project: n2o-framework   Source File: RuntimeRoutingDataSource.java    License: Apache License 2.0 4 votes vote down vote up
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
    this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}
 
Example 7
Source Project: azeroth   Source File: MutiRouteDataSource.java    License: Apache License 2.0 4 votes vote down vote up
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
    this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}
 
Example 8
Source Project: jeesuite-libs   Source File: MutiRouteDataSource.java    License: Apache License 2.0 4 votes vote down vote up
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
	this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}
 
Example 9
Source Project: cuba   Source File: DataSourceProvider.java    License: Apache License 2.0 4 votes vote down vote up
protected DataSource getJndiDataSource(String jndiName) {
    Preconditions.checkNotNull(jndiName, "Jndi name is null");
    DataSourceLookup lookup = new JndiDataSourceLookup();
    return new ProxyDataSource(lookup.getDataSource(jndiName));
}
 
Example 10
Source Project: jeewx   Source File: DynamicDataSource.java    License: Apache License 2.0 4 votes vote down vote up
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
	super.setDataSourceLookup(dataSourceLookup);
}
 
Example 11
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
	this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}
 
Example 12
Source Project: jeecg   Source File: DynamicDataSource.java    License: Apache License 2.0 4 votes vote down vote up
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
	super.setDataSourceLookup(dataSourceLookup);
}
 
Example 13
/**
 * Specify the JDBC DataSourceLookup that provides DataSources for the
 * persistence provider, resolving data source names in {@code persistence.xml}
 * against Spring-managed DataSource instances.
 * <p>Default is JndiDataSourceLookup, which resolves DataSource names as
 * JNDI names (as defined by standard JPA). Specify a BeanFactoryDataSourceLookup
 * instance if you want DataSource names to be resolved against Spring bean names.
 * <p>Alternatively, consider passing in a map from names to DataSource instances
 * via the "dataSources" property. If the {@code persistence.xml} file
 * does not define DataSource names at all, specify a default DataSource
 * via the "defaultDataSource" property.
 * @see org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup
 * @see org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup
 * @see #setDataSources
 * @see #setDefaultDataSource
 */
public void setDataSourceLookup(@Nullable DataSourceLookup dataSourceLookup) {
	this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}
 
Example 14
/**
 * Return the JDBC DataSourceLookup that provides DataSources for the
 * persistence provider, resolving data source names in {@code persistence.xml}
 * against Spring-managed DataSource instances.
 */
@Nullable
public DataSourceLookup getDataSourceLookup() {
	return this.dataSourceLookup;
}
 
Example 15
/**
 * Specify the JDBC DataSourceLookup that provides DataSources for the
 * persistence provider, resolving data source names in {@code persistence.xml}
 * against Spring-managed DataSource instances.
 * <p>Default is JndiDataSourceLookup, which resolves DataSource names as
 * JNDI names (as defined by standard JPA). Specify a BeanFactoryDataSourceLookup
 * instance if you want DataSource names to be resolved against Spring bean names.
 * <p>Alternatively, consider passing in a map from names to DataSource instances
 * via the "dataSources" property. If the {@code persistence.xml} file
 * does not define DataSource names at all, specify a default DataSource
 * via the "defaultDataSource" property.
 * @see org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup
 * @see org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup
 * @see #setDataSources
 * @see #setDefaultDataSource
 */
public void setDataSourceLookup(@Nullable DataSourceLookup dataSourceLookup) {
	this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}
 
Example 16
/**
 * Return the JDBC DataSourceLookup that provides DataSources for the
 * persistence provider, resolving data source names in {@code persistence.xml}
 * against Spring-managed DataSource instances.
 */
@Nullable
public DataSourceLookup getDataSourceLookup() {
	return this.dataSourceLookup;
}
 
Example 17
/**
 * Specify the JDBC DataSourceLookup that provides DataSources for the
 * persistence provider, resolving data source names in {@code persistence.xml}
 * against Spring-managed DataSource instances.
 * <p>Default is JndiDataSourceLookup, which resolves DataSource names as
 * JNDI names (as defined by standard JPA). Specify a BeanFactoryDataSourceLookup
 * instance if you want DataSource names to be resolved against Spring bean names.
 * <p>Alternatively, consider passing in a map from names to DataSource instances
 * via the "dataSources" property. If the {@code persistence.xml} file
 * does not define DataSource names at all, specify a default DataSource
 * via the "defaultDataSource" property.
 * @see org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup
 * @see org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup
 * @see #setDataSources
 * @see #setDefaultDataSource
 */
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
	this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}
 
Example 18
/**
 * Return the JDBC DataSourceLookup that provides DataSources for the
 * persistence provider, resolving data source names in {@code persistence.xml}
 * against Spring-managed DataSource instances.
 */
public DataSourceLookup getDataSourceLookup() {
	return this.dataSourceLookup;
}
 
Example 19
/**
 * Specify the JDBC DataSourceLookup that provides DataSources for the
 * persistence provider, resolving data source names in {@code persistence.xml}
 * against Spring-managed DataSource instances.
 * <p>Default is JndiDataSourceLookup, which resolves DataSource names as
 * JNDI names (as defined by standard JPA). Specify a BeanFactoryDataSourceLookup
 * instance if you want DataSource names to be resolved against Spring bean names.
 * <p>Alternatively, consider passing in a map from names to DataSource instances
 * via the "dataSources" property. If the {@code persistence.xml} file
 * does not define DataSource names at all, specify a default DataSource
 * via the "defaultDataSource" property.
 * @see org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup
 * @see org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup
 * @see #setDataSources
 * @see #setDefaultDataSource
 */
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
	this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}
 
Example 20
/**
 * Return the JDBC DataSourceLookup that provides DataSources for the
 * persistence provider, resolving data source names in {@code persistence.xml}
 * against Spring-managed DataSource instances.
 */
public DataSourceLookup getDataSourceLookup() {
	return this.dataSourceLookup;
}
 
Example 21
/**
 * Set the DataSourceLookup implementation to use for resolving data source
 * name Strings in the {@link #setTargetDataSources targetDataSources} map.
 * <p>Default is a {@link JndiDataSourceLookup}, allowing the JNDI names
 * of application server DataSources to be specified directly.
 */
public void setDataSourceLookup(DataSourceLookup dataSourceLookup) {
	this.dataSourceLookup = (dataSourceLookup != null ? dataSourceLookup : new JndiDataSourceLookup());
}