Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
public class UserSuppliedConnectionProviderImpl implements ConnectionProvider {
@Override
public boolean isUnwrappableAs(Class<?> unwrapType) {
return ConnectionProvider.class.equals( unwrapType ) ||
UserSuppliedConnectionProviderImpl.class.isAssignableFrom( unwrapType );
return unwrapType.isAssignableFrom( UserSuppliedConnectionProviderImpl.class );
}

@Override
@SuppressWarnings( {"unchecked"})
public <T> T unwrap(Class<T> unwrapType) {
if ( ConnectionProvider.class.equals( unwrapType ) ||
UserSuppliedConnectionProviderImpl.class.isAssignableFrom( unwrapType ) ) {
if ( unwrapType.isAssignableFrom( UserSuppliedConnectionProviderImpl.class ) ) {
return (T) this;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*
* @author Steve Ebersole
*/
public abstract class AbstractDataSourceBasedMultiTenantConnectionProviderImpl<T> implements MultiTenantConnectionProvider<T> {
public abstract class AbstractDataSourceBasedMultiTenantConnectionProviderImpl<T>
implements MultiTenantConnectionProvider<T> {
protected abstract DataSource selectAnyDataSource();
protected abstract DataSource selectDataSource(T tenantIdentifier);

Expand Down Expand Up @@ -46,18 +47,17 @@ public boolean supportsAggressiveRelease() {

@Override
public boolean isUnwrappableAs(Class<?> unwrapType) {
return
DataSource.class.isAssignableFrom( unwrapType ) ||
MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType );
return unwrapType.isInstance( this )
|| unwrapType.isAssignableFrom( DataSource.class );
}

@Override
@SuppressWarnings( {"unchecked"})
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> unwrapType) {
if ( MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType ) ) {
if ( unwrapType.isInstance( this ) ) {
return (T) this;
}
else if ( DataSource.class.isAssignableFrom( unwrapType ) ) {
else if ( unwrapType.isAssignableFrom( DataSource.class ) ) {
return (T) selectAnyDataSource();
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,17 @@ public boolean supportsAggressiveRelease() {

@Override
public boolean isUnwrappableAs(Class<?> unwrapType) {
return
ConnectionProvider.class.isAssignableFrom( unwrapType ) ||
MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType );
return unwrapType.isInstance( this )
|| unwrapType.isAssignableFrom( ConnectionProvider.class );
}

@Override
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> unwrapType) {
if ( MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType ) ) {
if ( unwrapType.isInstance( this ) ) {
return (T) this;
}
else if ( ConnectionProvider.class.isAssignableFrom( unwrapType ) ) {
else if ( unwrapType.isAssignableFrom( ConnectionProvider.class ) ) {
return (T) getAnyConnectionProvider();
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private Map<T, DataSource> dataSourceMap() {

@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
final ConfigurationService configurationService = serviceRegistry.requireService( ConfigurationService.class );
final var configurationService = serviceRegistry.requireService( ConfigurationService.class );
final Object dataSourceConfigValue = configurationService.getSettings().get( DATASOURCE );
if ( !(dataSourceConfigValue instanceof String configuredJndiName) ) {
throw new HibernateException( "illegal value for configuration setting '" + DATASOURCE + "'" );
Expand Down
Loading