diff --git a/hibernate-agroal/src/main/java/org/hibernate/agroal/internal/StrategyRegistrationProviderImpl.java b/hibernate-agroal/src/main/java/org/hibernate/agroal/internal/StrategyRegistrationProviderImpl.java index bfb5311413..b542cb4f0f 100644 --- a/hibernate-agroal/src/main/java/org/hibernate/agroal/internal/StrategyRegistrationProviderImpl.java +++ b/hibernate-agroal/src/main/java/org/hibernate/agroal/internal/StrategyRegistrationProviderImpl.java @@ -6,36 +6,32 @@ */ package org.hibernate.agroal.internal; +import java.util.Collections; + import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl; import org.hibernate.boot.registry.selector.StrategyRegistration; import org.hibernate.boot.registry.selector.StrategyRegistrationProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; -import java.util.Collections; -import java.util.List; - /** * Provides the {@link AgroalConnectionProvider} to the * {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service. * * @author Luis Barreiro */ -public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { - - private static final List REGISTRATIONS = Collections.singletonList( - new SimpleStrategyRegistrationImpl<>( - ConnectionProvider.class, - AgroalConnectionProvider.class, - AgroalConnectionProvider.class.getSimpleName(), - "agroal", - "Agroal", - // for consistency's sake - "org.hibernate.connection.AgroalConnectionProvider" - ) - ); +public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { @Override public Iterable getStrategyRegistrations() { - return REGISTRATIONS; + final SimpleStrategyRegistrationImpl strategyRegistration = new SimpleStrategyRegistrationImpl<>( + ConnectionProvider.class, + AgroalConnectionProvider.class, + AgroalConnectionProvider.class.getSimpleName(), + "agroal", + "Agroal", + // for consistency's sake + "org.hibernate.connection.AgroalConnectionProvider" + ); + return Collections.singleton( strategyRegistration ); } } diff --git a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/StrategyRegistrationProviderImpl.java b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/StrategyRegistrationProviderImpl.java index 3a2ca0f48e..571fd4dbad 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/StrategyRegistrationProviderImpl.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/StrategyRegistrationProviderImpl.java @@ -7,7 +7,6 @@ package org.hibernate.c3p0.internal; import java.util.Collections; -import java.util.List; import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl; import org.hibernate.boot.registry.selector.StrategyRegistration; @@ -20,23 +19,21 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; * * @author Brett Meyer */ -public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { - private static final List REGISTRATIONS = Collections.singletonList( - (StrategyRegistration) new SimpleStrategyRegistrationImpl( - ConnectionProvider.class, - C3P0ConnectionProvider.class, - "c3p0", - C3P0ConnectionProvider.class.getSimpleName(), - // legacy - "org.hibernate.connection.C3P0ConnectionProvider", - // legacy - "org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" - ) - ); - +public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { + @Override @SuppressWarnings("unchecked") public Iterable getStrategyRegistrations() { - return REGISTRATIONS; + final SimpleStrategyRegistrationImpl c3p0 = new SimpleStrategyRegistrationImpl<>( + ConnectionProvider.class, + C3P0ConnectionProvider.class, + "c3p0", + C3P0ConnectionProvider.class.getSimpleName(), + // legacy + "org.hibernate.connection.C3P0ConnectionProvider", + // legacy + "org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" + ); + return Collections.singleton( c3p0 ); } } diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/StrategyRegistrationProviderImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/StrategyRegistrationProviderImpl.java index f9e20b9f40..b0aa446491 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/StrategyRegistrationProviderImpl.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/StrategyRegistrationProviderImpl.java @@ -20,11 +20,12 @@ import org.hibernate.cache.spi.RegionFactory; * * @author Steve Ebersole */ -public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { +public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { + @Override @SuppressWarnings("unchecked") public Iterable getStrategyRegistrations() { - final List strategyRegistrations = new ArrayList(); + final List strategyRegistrations = new ArrayList( 2 ); strategyRegistrations.add( new SimpleStrategyRegistrationImpl( diff --git a/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/StrategyRegistrationProviderImpl.java b/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/StrategyRegistrationProviderImpl.java index cba5a0eaa7..06d2664140 100644 --- a/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/StrategyRegistrationProviderImpl.java +++ b/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/StrategyRegistrationProviderImpl.java @@ -20,22 +20,20 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; * * @author Brett Meyer */ -public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { - private static final List REGISTRATIONS = Collections.singletonList( - (StrategyRegistration) new SimpleStrategyRegistrationImpl( - ConnectionProvider.class, - HikariCPConnectionProvider.class, - "hikari", - "hikaricp", - HikariCPConnectionProvider.class.getSimpleName(), - // for consistency's sake - "org.hibernate.connection.HikariCPConnectionProvider" - ) - ); +public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { @Override @SuppressWarnings("unchecked") public Iterable getStrategyRegistrations() { - return REGISTRATIONS; + final SimpleStrategyRegistrationImpl strategyRegistration = new SimpleStrategyRegistrationImpl<>( + ConnectionProvider.class, + HikariCPConnectionProvider.class, + "hikari", + "hikaricp", + HikariCPConnectionProvider.class.getSimpleName(), + // for consistency's sake + "org.hibernate.connection.HikariCPConnectionProvider" + ); + return Collections.singleton( strategyRegistration ); } } diff --git a/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/internal/StrategyRegistrationProviderImpl.java b/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/internal/StrategyRegistrationProviderImpl.java index 1b6c783451..39c87d2673 100644 --- a/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/internal/StrategyRegistrationProviderImpl.java +++ b/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/internal/StrategyRegistrationProviderImpl.java @@ -6,8 +6,7 @@ */ package org.hibernate.cache.jcache.internal; -import java.util.ArrayList; -import java.util.List; +import java.util.Collections; import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl; import org.hibernate.boot.registry.selector.StrategyRegistration; @@ -22,24 +21,21 @@ import org.hibernate.cache.spi.RegionFactory; * * @author Steve Ebersole */ -public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { +public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { + @Override @SuppressWarnings("unchecked") public Iterable getStrategyRegistrations() { - final List strategyRegistrations = new ArrayList(); - - strategyRegistrations.add( - new SimpleStrategyRegistrationImpl( - RegionFactory.class, - JCacheRegionFactory.class, - ConfigSettings.SIMPLE_FACTORY_NAME, - JCacheRegionFactory.class.getName(), - JCacheRegionFactory.class.getSimpleName(), - // legacy impl class name - "org.hibernate.cache.jcache.JCacheRegionFactory" - ) + final SimpleStrategyRegistrationImpl simpleStrategyRegistration = new SimpleStrategyRegistrationImpl( + RegionFactory.class, + JCacheRegionFactory.class, + ConfigSettings.SIMPLE_FACTORY_NAME, + JCacheRegionFactory.class.getName(), + JCacheRegionFactory.class.getSimpleName(), + // legacy impl class name + "org.hibernate.cache.jcache.JCacheRegionFactory" ); - return strategyRegistrations; + return Collections.singleton( simpleStrategyRegistration ); } } diff --git a/hibernate-osgi/src/test/java/org/hibernate/osgi/test/client/TestStrategyRegistrationProvider.java b/hibernate-osgi/src/test/java/org/hibernate/osgi/test/client/TestStrategyRegistrationProvider.java index 5382e46da7..d081f41700 100644 --- a/hibernate-osgi/src/test/java/org/hibernate/osgi/test/client/TestStrategyRegistrationProvider.java +++ b/hibernate-osgi/src/test/java/org/hibernate/osgi/test/client/TestStrategyRegistrationProvider.java @@ -24,7 +24,7 @@ public class TestStrategyRegistrationProvider implements StrategyRegistrationPro @SuppressWarnings("unchecked") public Iterable getStrategyRegistrations() { return Collections.singletonList( - (StrategyRegistration) new SimpleStrategyRegistrationImpl( + new SimpleStrategyRegistrationImpl( Calendar.class, GregorianCalendar.class, GREGORIAN diff --git a/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/StrategyRegistrationProviderImpl.java b/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/StrategyRegistrationProviderImpl.java index 2ac6169c50..3b9e2c44fd 100644 --- a/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/StrategyRegistrationProviderImpl.java +++ b/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/StrategyRegistrationProviderImpl.java @@ -7,7 +7,6 @@ package org.hibernate.proxool.internal; import java.util.Collections; -import java.util.List; import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl; import org.hibernate.boot.registry.selector.StrategyRegistration; @@ -20,23 +19,21 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; * * @author Brett Meyer */ -public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { - private static final List REGISTRATIONS = Collections.singletonList( - (StrategyRegistration) new SimpleStrategyRegistrationImpl( - ConnectionProvider.class, - ProxoolConnectionProvider.class, - "proxool", - ProxoolConnectionProvider.class.getSimpleName(), - // legacy - "org.hibernate.connection.ProxoolConnectionProvider", - // legacy - "org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider" - ) - ); +public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { @Override @SuppressWarnings("unchecked") public Iterable getStrategyRegistrations() { - return REGISTRATIONS; + return Collections.singletonList( + new SimpleStrategyRegistrationImpl( + ConnectionProvider.class, + ProxoolConnectionProvider.class, + "proxool", + ProxoolConnectionProvider.class.getSimpleName(), + // legacy + "org.hibernate.connection.ProxoolConnectionProvider", + // legacy + "org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider" + ) ); } } diff --git a/hibernate-vibur/src/main/java/org/hibernate/vibur/internal/StrategyRegistrationProviderImpl.java b/hibernate-vibur/src/main/java/org/hibernate/vibur/internal/StrategyRegistrationProviderImpl.java index 5a4c1d73d1..afe4b31e97 100644 --- a/hibernate-vibur/src/main/java/org/hibernate/vibur/internal/StrategyRegistrationProviderImpl.java +++ b/hibernate-vibur/src/main/java/org/hibernate/vibur/internal/StrategyRegistrationProviderImpl.java @@ -7,38 +7,35 @@ package org.hibernate.vibur.internal; +import java.util.Collections; + import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl; import org.hibernate.boot.registry.selector.StrategyRegistration; import org.hibernate.boot.registry.selector.StrategyRegistrationProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; -import java.util.Collections; -import java.util.List; - /** * Provides the {@link ViburDBCPConnectionProvider} to the * {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service. * * @author Simeon Malchev */ -public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { - private static final List REGISTRATIONS = Collections.singletonList( - (StrategyRegistration) new SimpleStrategyRegistrationImpl<>( - ConnectionProvider.class, - ViburDBCPConnectionProvider.class, - "vibur", - "viburdbcp", - ViburDBCPConnectionProvider.class.getSimpleName(), - // for backward compatibility with pre-existing Vibur project Hibernate integration artifacts - "org.vibur.dbcp.integration.ViburDBCPConnectionProvider", - // for consistency's sake - "org.hibernate.connection.ViburDBCPConnectionProvider" - ) - ); +public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider { @Override @SuppressWarnings("unchecked") public Iterable getStrategyRegistrations() { - return REGISTRATIONS; + return Collections.singletonList( + new SimpleStrategyRegistrationImpl<>( + ConnectionProvider.class, + ViburDBCPConnectionProvider.class, + "vibur", + "viburdbcp", + ViburDBCPConnectionProvider.class.getSimpleName(), + // for backward compatibility with pre-existing Vibur project Hibernate integration artifacts + "org.vibur.dbcp.integration.ViburDBCPConnectionProvider", + // for consistency's sake + "org.hibernate.connection.ViburDBCPConnectionProvider" + ) ); } }