HHH-13029 Avoid static singletons to hold on Strategy Registration Implementations
This commit is contained in:
parent
e3ae85f8c1
commit
fcd3b56fdd
|
@ -6,36 +6,32 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.agroal.internal;
|
package org.hibernate.agroal.internal;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
||||||
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
||||||
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the {@link AgroalConnectionProvider} to the
|
* Provides the {@link AgroalConnectionProvider} to the
|
||||||
* {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service.
|
* {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service.
|
||||||
*
|
*
|
||||||
* @author Luis Barreiro
|
* @author Luis Barreiro
|
||||||
*/
|
*/
|
||||||
public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
||||||
|
|
||||||
private static final List<StrategyRegistration> REGISTRATIONS = Collections.singletonList(
|
|
||||||
new SimpleStrategyRegistrationImpl<>(
|
|
||||||
ConnectionProvider.class,
|
|
||||||
AgroalConnectionProvider.class,
|
|
||||||
AgroalConnectionProvider.class.getSimpleName(),
|
|
||||||
"agroal",
|
|
||||||
"Agroal",
|
|
||||||
// for consistency's sake
|
|
||||||
"org.hibernate.connection.AgroalConnectionProvider"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
||||||
return REGISTRATIONS;
|
final SimpleStrategyRegistrationImpl<ConnectionProvider> strategyRegistration = new SimpleStrategyRegistrationImpl<>(
|
||||||
|
ConnectionProvider.class,
|
||||||
|
AgroalConnectionProvider.class,
|
||||||
|
AgroalConnectionProvider.class.getSimpleName(),
|
||||||
|
"agroal",
|
||||||
|
"Agroal",
|
||||||
|
// for consistency's sake
|
||||||
|
"org.hibernate.connection.AgroalConnectionProvider"
|
||||||
|
);
|
||||||
|
return Collections.singleton( strategyRegistration );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package org.hibernate.c3p0.internal;
|
package org.hibernate.c3p0.internal;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
||||||
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
||||||
|
@ -20,23 +19,21 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
*
|
*
|
||||||
* @author Brett Meyer
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
||||||
private static final List<StrategyRegistration> REGISTRATIONS = Collections.singletonList(
|
|
||||||
(StrategyRegistration) new SimpleStrategyRegistrationImpl<ConnectionProvider>(
|
|
||||||
ConnectionProvider.class,
|
|
||||||
C3P0ConnectionProvider.class,
|
|
||||||
"c3p0",
|
|
||||||
C3P0ConnectionProvider.class.getSimpleName(),
|
|
||||||
// legacy
|
|
||||||
"org.hibernate.connection.C3P0ConnectionProvider",
|
|
||||||
// legacy
|
|
||||||
"org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
||||||
return REGISTRATIONS;
|
final SimpleStrategyRegistrationImpl<ConnectionProvider> 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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,12 @@ import org.hibernate.cache.spi.RegionFactory;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
||||||
final List<StrategyRegistration> strategyRegistrations = new ArrayList<StrategyRegistration>();
|
final List<StrategyRegistration> strategyRegistrations = new ArrayList<StrategyRegistration>( 2 );
|
||||||
|
|
||||||
strategyRegistrations.add(
|
strategyRegistrations.add(
|
||||||
new SimpleStrategyRegistrationImpl(
|
new SimpleStrategyRegistrationImpl(
|
||||||
|
|
|
@ -20,22 +20,20 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
*
|
*
|
||||||
* @author Brett Meyer
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
||||||
private static final List<StrategyRegistration> REGISTRATIONS = Collections.singletonList(
|
|
||||||
(StrategyRegistration) new SimpleStrategyRegistrationImpl<ConnectionProvider>(
|
|
||||||
ConnectionProvider.class,
|
|
||||||
HikariCPConnectionProvider.class,
|
|
||||||
"hikari",
|
|
||||||
"hikaricp",
|
|
||||||
HikariCPConnectionProvider.class.getSimpleName(),
|
|
||||||
// for consistency's sake
|
|
||||||
"org.hibernate.connection.HikariCPConnectionProvider"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
||||||
return REGISTRATIONS;
|
final SimpleStrategyRegistrationImpl<ConnectionProvider> strategyRegistration = new SimpleStrategyRegistrationImpl<>(
|
||||||
|
ConnectionProvider.class,
|
||||||
|
HikariCPConnectionProvider.class,
|
||||||
|
"hikari",
|
||||||
|
"hikaricp",
|
||||||
|
HikariCPConnectionProvider.class.getSimpleName(),
|
||||||
|
// for consistency's sake
|
||||||
|
"org.hibernate.connection.HikariCPConnectionProvider"
|
||||||
|
);
|
||||||
|
return Collections.singleton( strategyRegistration );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cache.jcache.internal;
|
package org.hibernate.cache.jcache.internal;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
||||||
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
||||||
|
@ -22,24 +21,21 @@ import org.hibernate.cache.spi.RegionFactory;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
||||||
final List<StrategyRegistration> strategyRegistrations = new ArrayList<StrategyRegistration>();
|
final SimpleStrategyRegistrationImpl simpleStrategyRegistration = new SimpleStrategyRegistrationImpl(
|
||||||
|
RegionFactory.class,
|
||||||
strategyRegistrations.add(
|
JCacheRegionFactory.class,
|
||||||
new SimpleStrategyRegistrationImpl(
|
ConfigSettings.SIMPLE_FACTORY_NAME,
|
||||||
RegionFactory.class,
|
JCacheRegionFactory.class.getName(),
|
||||||
JCacheRegionFactory.class,
|
JCacheRegionFactory.class.getSimpleName(),
|
||||||
ConfigSettings.SIMPLE_FACTORY_NAME,
|
// legacy impl class name
|
||||||
JCacheRegionFactory.class.getName(),
|
"org.hibernate.cache.jcache.JCacheRegionFactory"
|
||||||
JCacheRegionFactory.class.getSimpleName(),
|
|
||||||
// legacy impl class name
|
|
||||||
"org.hibernate.cache.jcache.JCacheRegionFactory"
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return strategyRegistrations;
|
return Collections.singleton( simpleStrategyRegistration );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class TestStrategyRegistrationProvider implements StrategyRegistrationPro
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
||||||
return Collections.singletonList(
|
return Collections.singletonList(
|
||||||
(StrategyRegistration) new SimpleStrategyRegistrationImpl(
|
new SimpleStrategyRegistrationImpl(
|
||||||
Calendar.class,
|
Calendar.class,
|
||||||
GregorianCalendar.class,
|
GregorianCalendar.class,
|
||||||
GREGORIAN
|
GREGORIAN
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package org.hibernate.proxool.internal;
|
package org.hibernate.proxool.internal;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
||||||
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
||||||
|
@ -20,23 +19,21 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
*
|
*
|
||||||
* @author Brett Meyer
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
||||||
private static final List<StrategyRegistration> REGISTRATIONS = Collections.singletonList(
|
|
||||||
(StrategyRegistration) new SimpleStrategyRegistrationImpl<ConnectionProvider>(
|
|
||||||
ConnectionProvider.class,
|
|
||||||
ProxoolConnectionProvider.class,
|
|
||||||
"proxool",
|
|
||||||
ProxoolConnectionProvider.class.getSimpleName(),
|
|
||||||
// legacy
|
|
||||||
"org.hibernate.connection.ProxoolConnectionProvider",
|
|
||||||
// legacy
|
|
||||||
"org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
||||||
return REGISTRATIONS;
|
return Collections.singletonList(
|
||||||
|
new SimpleStrategyRegistrationImpl<ConnectionProvider>(
|
||||||
|
ConnectionProvider.class,
|
||||||
|
ProxoolConnectionProvider.class,
|
||||||
|
"proxool",
|
||||||
|
ProxoolConnectionProvider.class.getSimpleName(),
|
||||||
|
// legacy
|
||||||
|
"org.hibernate.connection.ProxoolConnectionProvider",
|
||||||
|
// legacy
|
||||||
|
"org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider"
|
||||||
|
) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,38 +7,35 @@
|
||||||
|
|
||||||
package org.hibernate.vibur.internal;
|
package org.hibernate.vibur.internal;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
||||||
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
||||||
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the {@link ViburDBCPConnectionProvider} to the
|
* Provides the {@link ViburDBCPConnectionProvider} to the
|
||||||
* {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service.
|
* {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service.
|
||||||
*
|
*
|
||||||
* @author Simeon Malchev
|
* @author Simeon Malchev
|
||||||
*/
|
*/
|
||||||
public class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
public final class StrategyRegistrationProviderImpl implements StrategyRegistrationProvider {
|
||||||
private static final List<StrategyRegistration> 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"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
public Iterable<StrategyRegistration> 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"
|
||||||
|
) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue