Java Code Examples for org.hibernate.MultiTenancyStrategy#requiresMultiTenantConnectionProvider()
The following examples show how to use
org.hibernate.MultiTenancyStrategy#requiresMultiTenantConnectionProvider() .
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 File: JdbcEnvironmentInitiator.java From lams with GNU General Public License v2.0 | 5 votes |
private JdbcConnectionAccess buildJdbcConnectionAccess(Map configValues, ServiceRegistryImplementor registry) { final MultiTenancyStrategy multiTenancyStrategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configValues ); if ( !multiTenancyStrategy.requiresMultiTenantConnectionProvider() ) { ConnectionProvider connectionProvider = registry.getService( ConnectionProvider.class ); return new ConnectionProviderJdbcConnectionAccess( connectionProvider ); } else { final MultiTenantConnectionProvider multiTenantConnectionProvider = registry.getService( MultiTenantConnectionProvider.class ); return new MultiTenantConnectionProviderJdbcConnectionAccess( multiTenantConnectionProvider ); } }
Example 2
Source File: JdbcEnvironmentInitiator.java From lams with GNU General Public License v2.0 | 5 votes |
public static JdbcConnectionAccess buildBootstrapJdbcConnectionAccess( MultiTenancyStrategy multiTenancyStrategy, ServiceRegistryImplementor registry) { if ( !multiTenancyStrategy.requiresMultiTenantConnectionProvider() ) { ConnectionProvider connectionProvider = registry.getService( ConnectionProvider.class ); return new ConnectionProviderJdbcConnectionAccess( connectionProvider ); } else { final MultiTenantConnectionProvider multiTenantConnectionProvider = registry.getService( MultiTenantConnectionProvider.class ); return new MultiTenantConnectionProviderJdbcConnectionAccess( multiTenantConnectionProvider ); } }
Example 3
Source File: MultiTenantConnectionProviderInitiator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override @SuppressWarnings( {"unchecked"}) public MultiTenantConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final MultiTenancyStrategy strategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configurationValues ); if ( !strategy.requiresMultiTenantConnectionProvider() ) { // nothing to do, but given the separate hierarchies have to handle this here. return null; } final Object configValue = configurationValues.get( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ); if ( configValue == null ) { // if they also specified the data source *name*, then lets assume they want // DataSourceBasedMultiTenantConnectionProviderImpl final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE ); if ( dataSourceConfigValue != null && String.class.isInstance( dataSourceConfigValue ) ) { return new DataSourceBasedMultiTenantConnectionProviderImpl(); } return null; } if ( MultiTenantConnectionProvider.class.isInstance( configValue ) ) { return (MultiTenantConnectionProvider) configValue; } else { final Class<MultiTenantConnectionProvider> implClass; if ( Class.class.isInstance( configValue ) ) { implClass = (Class) configValue; } else { final String className = configValue.toString(); final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class ); try { implClass = classLoaderService.classForName( className ); } catch (ClassLoadingException cle) { log.warn( "Unable to locate specified class [" + className + "]", cle ); throw new ServiceException( "Unable to locate specified multi-tenant connection provider [" + className + "]" ); } } try { return implClass.newInstance(); } catch (Exception e) { log.warn( "Unable to instantiate specified class [" + implClass.getName() + "]", e ); throw new ServiceException( "Unable to instantiate specified multi-tenant connection provider [" + implClass.getName() + "]" ); } } }