squash lots of warnings in services

change the raw Map representation of config properties to Map<String,Object>
This commit is contained in:
Gavin King 2022-01-25 14:56:42 +01:00
parent 1f40ed164c
commit e51c210d78
201 changed files with 640 additions and 667 deletions

View File

@ -27,6 +27,7 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.Stoppable; import org.hibernate.service.spi.Stoppable;
import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool; import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool;
@ -88,7 +89,7 @@ public abstract class AbstractMultiTenancyTest extends BaseUnitTestCase {
DriverManagerConnectionProviderImpl connectionProvider = DriverManagerConnectionProviderImpl connectionProvider =
new DriverManagerConnectionProviderImpl(); new DriverManagerConnectionProviderImpl();
connectionProvider.configure(properties); connectionProvider.configure( PropertiesHelper.map(properties) );
connectionProviderMap.put(tenantIdentifier, connectionProvider); connectionProviderMap.put(tenantIdentifier, connectionProvider);
} }
//end::multitenacy-hibernate-MultiTenantConnectionProvider-example[] //end::multitenacy-hibernate-MultiTenantConnectionProvider-example[]

View File

@ -34,6 +34,7 @@ import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.Stoppable; import org.hibernate.service.spi.Stoppable;
import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool; import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool;
@ -106,7 +107,7 @@ public class DatabaseTimeZoneMultiTenancyTest extends BaseUnitTestCase {
DriverManagerConnectionProviderImpl connectionProvider = DriverManagerConnectionProviderImpl connectionProvider =
new DriverManagerConnectionProviderImpl(); new DriverManagerConnectionProviderImpl();
connectionProvider.configure(properties); connectionProvider.configure( PropertiesHelper.map(properties) );
connectionProviderMap.put(tenantIdentifier, connectionProvider); connectionProviderMap.put(tenantIdentifier, connectionProvider);

View File

@ -58,7 +58,7 @@ public class AgroalConnectionProvider implements ConnectionProvider, Configurabl
// --- Configurable // --- Configurable
private static void resolveIsolationSetting(Map<String, String> properties, AgroalConnectionFactoryConfigurationSupplier cf) { private static void resolveIsolationSetting(Map<String, Object> properties, AgroalConnectionFactoryConfigurationSupplier cf) {
Integer isolation = ConnectionProviderInitiator.extractIsolation( properties ); Integer isolation = ConnectionProviderInitiator.extractIsolation( properties );
if ( isolation != null ) { if ( isolation != null ) {
// Agroal resolves transaction isolation from the 'nice' name // Agroal resolves transaction isolation from the 'nice' name
@ -67,19 +67,19 @@ public class AgroalConnectionProvider implements ConnectionProvider, Configurabl
} }
} }
private static <T> void copyProperty(Map<String, String> properties, String key, Consumer<T> consumer, Function<String, T> converter) { private static <T> void copyProperty(Map<String, Object> properties, String key, Consumer<T> consumer, Function<String, T> converter) {
String value = properties.get( key ); Object value = properties.get( key );
if ( value != null ) { if ( value instanceof String ) {
consumer.accept( converter.apply( value ) ); consumer.accept( converter.apply( (String) value ) );
} }
} }
@Override @Override
@SuppressWarnings( "unchecked" ) public void configure(Map<String, Object> props) throws HibernateException {
public void configure(Map props) throws HibernateException {
LOGGER.debug( "Configuring Agroal" ); LOGGER.debug( "Configuring Agroal" );
try { try {
AgroalPropertiesReader agroalProperties = new AgroalPropertiesReader( CONFIG_PREFIX ).readProperties( props ); AgroalPropertiesReader agroalProperties = new AgroalPropertiesReader( CONFIG_PREFIX )
.readProperties( (Map) props ); //TODO: this is a garbage cast
agroalProperties.modify().connectionPoolConfiguration( cp -> cp.connectionFactoryConfiguration( cf -> { agroalProperties.modify().connectionPoolConfiguration( cp -> cp.connectionFactoryConfiguration( cf -> {
copyProperty( props, AvailableSettings.DRIVER, cf::connectionProviderClassName, Function.identity() ); copyProperty( props, AvailableSettings.DRIVER, cf::connectionProviderClassName, Function.identity() );
copyProperty( props, AvailableSettings.URL, cf::jdbcUrl, Function.identity() ); copyProperty( props, AvailableSettings.URL, cf::jdbcUrl, Function.identity() );
@ -119,15 +119,17 @@ public class AgroalConnectionProvider implements ConnectionProvider, Configurabl
} }
@Override @Override
@SuppressWarnings( "rawtypes" ) public boolean isUnwrappableAs(Class<?> unwrapType) {
public boolean isUnwrappableAs(Class unwrapType) { return ConnectionProvider.class.equals( unwrapType )
return ConnectionProvider.class.equals( unwrapType ) || AgroalConnectionProvider.class.isAssignableFrom( unwrapType ) || DataSource.class.isAssignableFrom( unwrapType ); || AgroalConnectionProvider.class.isAssignableFrom( unwrapType )
|| DataSource.class.isAssignableFrom( unwrapType );
} }
@Override @Override
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
public <T> T unwrap(Class<T> unwrapType) { public <T> T unwrap(Class<T> unwrapType) {
if ( ConnectionProvider.class.equals( unwrapType ) || AgroalConnectionProvider.class.isAssignableFrom( unwrapType ) ) { if ( ConnectionProvider.class.equals( unwrapType )
|| AgroalConnectionProvider.class.isAssignableFrom( unwrapType ) ) {
return (T) this; return (T) this;
} }
if ( DataSource.class.isAssignableFrom( unwrapType ) ) { if ( DataSource.class.isAssignableFrom( unwrapType ) ) {

View File

@ -21,6 +21,7 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator; import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.UnknownUnwrapTypeException; import org.hibernate.service.UnknownUnwrapTypeException;
import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.Configurable;
@ -67,11 +68,10 @@ public class C3P0ConnectionProvider
private ServiceRegistryImplementor serviceRegistry; private ServiceRegistryImplementor serviceRegistry;
@Override @Override
@SuppressWarnings("UnnecessaryUnboxing")
public Connection getConnection() throws SQLException { public Connection getConnection() throws SQLException {
final Connection c = ds.getConnection(); final Connection c = ds.getConnection();
if ( isolation != null && !isolation.equals( c.getTransactionIsolation() ) ) { if ( isolation != null && isolation != c.getTransactionIsolation() ) {
c.setTransactionIsolation( isolation.intValue() ); c.setTransactionIsolation( isolation );
} }
if ( c.getAutoCommit() != autocommit ) { if ( c.getAutoCommit() != autocommit ) {
c.setAutoCommit( autocommit ); c.setAutoCommit( autocommit );
@ -85,7 +85,7 @@ public class C3P0ConnectionProvider
} }
@Override @Override
public boolean isUnwrappableAs(Class unwrapType) { public boolean isUnwrappableAs(Class<?> unwrapType) {
return ConnectionProvider.class.equals( unwrapType ) || return ConnectionProvider.class.equals( unwrapType ) ||
C3P0ConnectionProvider.class.isAssignableFrom( unwrapType ) || C3P0ConnectionProvider.class.isAssignableFrom( unwrapType ) ||
DataSource.class.isAssignableFrom( unwrapType ); DataSource.class.isAssignableFrom( unwrapType );
@ -107,8 +107,7 @@ public class C3P0ConnectionProvider
} }
@Override @Override
@SuppressWarnings({"unchecked"}) public void configure(Map<String, Object> props) {
public void configure(Map props) {
final String jdbcDriverClass = (String) props.get( Environment.DRIVER ); final String jdbcDriverClass = (String) props.get( Environment.DRIVER );
final String jdbcUrl = (String) props.get( Environment.URL ); final String jdbcUrl = (String) props.get( Environment.URL );
final Properties connectionProps = ConnectionProviderInitiator.getConnectionProperties( props ); final Properties connectionProps = ConnectionProviderInitiator.getConnectionProperties( props );
@ -145,11 +144,7 @@ public class C3P0ConnectionProvider
// turn hibernate.c3p0.* into c3p0.*, so c3p0 // turn hibernate.c3p0.* into c3p0.*, so c3p0
// gets a chance to see all hibernate.c3p0.* // gets a chance to see all hibernate.c3p0.*
for ( Object o : props.keySet() ) { for ( String key : props.keySet() ) {
if ( !String.class.isInstance( o ) ) {
continue;
}
final String key = (String) o;
if ( key.startsWith( "hibernate.c3p0." ) ) { if ( key.startsWith( "hibernate.c3p0." ) ) {
final String newKey = key.substring( 15 ); final String newKey = key.substring( 15 );
if ( props.containsKey( newKey ) ) { if ( props.containsKey( newKey ) ) {
@ -185,9 +180,9 @@ public class C3P0ConnectionProvider
final DataSource unpooled = DataSources.unpooledDataSource( jdbcUrl, connectionProps ); final DataSource unpooled = DataSources.unpooledDataSource( jdbcUrl, connectionProps );
final Map allProps = new HashMap(); final Map<String,Object> allProps = new HashMap<>();
allProps.putAll( props ); allProps.putAll( props );
allProps.putAll( c3props ); allProps.putAll( PropertiesHelper.map(c3props) );
ds = DataSources.pooledDataSource( unpooled, allProps ); ds = DataSources.pooledDataSource( unpooled, allProps );
} }
@ -208,7 +203,7 @@ public class C3P0ConnectionProvider
private void setOverwriteProperty( private void setOverwriteProperty(
String hibernateStyleKey, String hibernateStyleKey,
String c3p0StyleKey, String c3p0StyleKey,
Map hibp, Map<String,Object> hibp,
Properties c3p, Properties c3p,
Integer value) { Integer value) {
if ( value != null ) { if ( value != null ) {

View File

@ -7,7 +7,8 @@
package org.hibernate.test.c3p0; package org.hibernate.test.c3p0;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.util.Properties; import java.util.HashMap;
import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import javax.management.ObjectName; import javax.management.ObjectName;
@ -94,8 +95,8 @@ public class C3P0ConnectionProviderTest extends BaseCoreFunctionalTestCase {
public void testIsolationPropertyCouldBeEmpty() { public void testIsolationPropertyCouldBeEmpty() {
C3P0ConnectionProvider provider = new C3P0ConnectionProvider(); C3P0ConnectionProvider provider = new C3P0ConnectionProvider();
try { try {
Properties configuration = new Properties(); Map<String,Object> configuration = new HashMap<>();
configuration.setProperty( Environment.ISOLATION, "" ); configuration.put( Environment.ISOLATION, "" );
provider.configure( configuration ); provider.configure( configuration );
} }
finally { finally {

View File

@ -46,7 +46,7 @@ public class C3P0DefaultIsolationLevelTest extends
} }
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
connectionProvider = new C3P0ProxyConnectionProvider(); connectionProvider = new C3P0ProxyConnectionProvider();
settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider ); settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider );
settings.put( AvailableSettings.ISOLATION, "READ_COMMITTED" ); settings.put( AvailableSettings.ISOLATION, "READ_COMMITTED" );

View File

@ -19,7 +19,6 @@ import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -47,7 +46,7 @@ public class C3P0DifferentIsolationLevelTest extends
} }
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
connectionProvider = new C3P0ProxyConnectionProvider(); connectionProvider = new C3P0ProxyConnectionProvider();
settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider ); settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider );
settings.put( AvailableSettings.ISOLATION, "REPEATABLE_READ" ); settings.put( AvailableSettings.ISOLATION, "REPEATABLE_READ" );

View File

@ -28,7 +28,7 @@ public class C3P0ProxyConnectionProvider extends C3P0ConnectionProvider {
} }
@Override @Override
public void configure(Map props) { public void configure(Map<String, Object> props) {
super.configure( props ); super.configure( props );
DataSource ds = unwrap( DataSource.class ); DataSource ds = unwrap( DataSource.class );
DataSource dataSource = spy( ds ); DataSource dataSource = spy( ds );
@ -45,7 +45,7 @@ public class C3P0ProxyConnectionProvider extends C3P0ConnectionProvider {
throw new IllegalStateException( e ); throw new IllegalStateException( e );
} }
ReflectionUtil.setField( C3P0ConnectionProvider.class.cast( this ), "ds", dataSource ); ReflectionUtil.setField( this, "ds", dataSource );
} }
@Override @Override

View File

@ -6,7 +6,7 @@
*/ */
package org.hibernate.community.dialect; package org.hibernate.community.dialect;
import java.util.Properties; import java.util.HashMap;
import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
@ -14,8 +14,6 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl; import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
import org.hibernate.orm.test.dialect.resolver.TestingDialectResolutionInfo; import org.hibernate.orm.test.dialect.resolver.TestingDialectResolutionInfo;
import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.ServiceRegistryImplementor;
@ -80,13 +78,8 @@ public class CommunityDialectFactoryTest extends BaseUnitTestCase {
DialectResolver resolver) { DialectResolver resolver) {
dialectFactory.setDialectResolver( resolver ); dialectFactory.setDialectResolver( resolver );
Dialect resolved = dialectFactory.buildDialect( Dialect resolved = dialectFactory.buildDialect(
new Properties(), new HashMap<>(),
new DialectResolutionInfoSource() { () -> TestingDialectResolutionInfo.forDatabaseInfo( databaseName, driverName, majorVersion, minorVersion )
@Override
public DialectResolutionInfo getDialectResolutionInfo() {
return TestingDialectResolutionInfo.forDatabaseInfo( databaseName, driverName, majorVersion, minorVersion );
}
}
); );
assertEquals( expected, resolved.getClass() ); assertEquals( expected, resolved.getClass() );
} }

View File

@ -17,7 +17,7 @@ import org.hibernate.boot.cfgxml.spi.LoadedConfig;
public class CfgXmlAccessServiceImpl implements CfgXmlAccessService { public class CfgXmlAccessServiceImpl implements CfgXmlAccessService {
private final LoadedConfig aggregatedCfgXml; private final LoadedConfig aggregatedCfgXml;
public CfgXmlAccessServiceImpl(Map configurationValues) { public CfgXmlAccessServiceImpl(Map<?,?> configurationValues) {
aggregatedCfgXml = (LoadedConfig) configurationValues.get( LOADED_CONFIG_KEY ); aggregatedCfgXml = (LoadedConfig) configurationValues.get( LOADED_CONFIG_KEY );
} }

View File

@ -22,7 +22,7 @@ public class CfgXmlAccessServiceInitiator implements StandardServiceInitiator<Cf
public static final CfgXmlAccessServiceInitiator INSTANCE = new CfgXmlAccessServiceInitiator(); public static final CfgXmlAccessServiceInitiator INSTANCE = new CfgXmlAccessServiceInitiator();
@Override @Override
public CfgXmlAccessService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public CfgXmlAccessService initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new CfgXmlAccessServiceImpl( configurationValues ); return new CfgXmlAccessServiceImpl( configurationValues );
} }

View File

@ -38,11 +38,11 @@ public class LoadedConfig {
private String sessionFactoryName; private String sessionFactoryName;
private final Map configurationValues = new ConcurrentHashMap( 16, 0.75f, 1 ); private final Map<String,Object> configurationValues = new ConcurrentHashMap<>( 16, 0.75f, 1 );
private List<CacheRegionDefinition> cacheRegionDefinitions; private List<CacheRegionDefinition> cacheRegionDefinitions;
private List<MappingReference> mappingReferences; private List<MappingReference> mappingReferences;
private Map<EventType,Set<String>> eventListenerMap; private Map<EventType<?>,Set<String>> eventListenerMap;
public LoadedConfig(String sessionFactoryName) { public LoadedConfig(String sessionFactoryName) {
this.sessionFactoryName = sessionFactoryName; this.sessionFactoryName = sessionFactoryName;
@ -52,7 +52,7 @@ public class LoadedConfig {
return sessionFactoryName; return sessionFactoryName;
} }
public Map getConfigurationValues() { public Map<String,Object> getConfigurationValues() {
return configurationValues; return configurationValues;
} }
@ -64,7 +64,7 @@ public class LoadedConfig {
return mappingReferences == null ? Collections.emptyList() : mappingReferences; return mappingReferences == null ? Collections.emptyList() : mappingReferences;
} }
public Map<EventType, Set<String>> getEventListenerMap() { public Map<EventType<?>, Set<String>> getEventListenerMap() {
return eventListenerMap == null ? Collections.emptyMap() : eventListenerMap; return eventListenerMap == null ? Collections.emptyMap() : eventListenerMap;
} }
@ -93,7 +93,7 @@ public class LoadedConfig {
if ( !jaxbCfg.getSessionFactory().getListener().isEmpty() ) { if ( !jaxbCfg.getSessionFactory().getListener().isEmpty() ) {
for ( JaxbCfgEventListenerType listener : jaxbCfg.getSessionFactory().getListener() ) { for ( JaxbCfgEventListenerType listener : jaxbCfg.getSessionFactory().getListener() ) {
final EventType eventType = EventType.resolveEventTypeByName( listener.getType().value() ); final EventType<?> eventType = EventType.resolveEventTypeByName( listener.getType().value() );
cfg.addEventListener( eventType, listener.getClazz() ); cfg.addEventListener( eventType, listener.getClazz() );
} }
} }
@ -105,7 +105,7 @@ public class LoadedConfig {
} }
final String eventTypeName = listenerGroup.getType().value(); final String eventTypeName = listenerGroup.getType().value();
final EventType eventType = EventType.resolveEventTypeByName( eventTypeName ); final EventType<?> eventType = EventType.resolveEventTypeByName( eventTypeName );
for ( JaxbCfgEventListenerType listener : listenerGroup.getListener() ) { for ( JaxbCfgEventListenerType listener : listenerGroup.getListener() ) {
if ( listener.getType() != null ) { if ( listener.getType() != null ) {
@ -127,7 +127,6 @@ public class LoadedConfig {
return value.trim(); return value.trim();
} }
@SuppressWarnings("unchecked")
private void addConfigurationValue(String propertyName, String value) { private void addConfigurationValue(String propertyName, String value) {
value = trim( value ); value = trim( value );
configurationValues.put( propertyName, value ); configurationValues.put( propertyName, value );
@ -146,7 +145,7 @@ public class LoadedConfig {
} }
private static CacheRegionDefinition parseCacheRegionDefinition(Object cacheDeclaration) { private static CacheRegionDefinition parseCacheRegionDefinition(Object cacheDeclaration) {
if ( JaxbCfgEntityCacheType.class.isInstance( cacheDeclaration ) ) { if ( cacheDeclaration instanceof JaxbCfgEntityCacheType ) {
final JaxbCfgEntityCacheType jaxbClassCache = (JaxbCfgEntityCacheType) cacheDeclaration; final JaxbCfgEntityCacheType jaxbClassCache = (JaxbCfgEntityCacheType) cacheDeclaration;
return new CacheRegionDefinition( return new CacheRegionDefinition(
CacheRegionDefinition.CacheRegionType.ENTITY, CacheRegionDefinition.CacheRegionType.ENTITY,
@ -175,7 +174,7 @@ public class LoadedConfig {
cacheRegionDefinitions.add( cacheRegionDefinition ); cacheRegionDefinitions.add( cacheRegionDefinition );
} }
public void addEventListener(EventType eventType, String listenerClass) { public void addEventListener(EventType<?> eventType, String listenerClass) {
if ( eventListenerMap == null ) { if ( eventListenerMap == null ) {
eventListenerMap = new HashMap<>(); eventListenerMap = new HashMap<>();
} }
@ -216,8 +215,7 @@ public class LoadedConfig {
addEventListeners( incoming.getEventListenerMap() ); addEventListeners( incoming.getEventListenerMap() );
} }
@SuppressWarnings("unchecked") protected void addConfigurationValues(Map<String,Object> configurationValues) {
protected void addConfigurationValues(Map configurationValues) {
if ( configurationValues == null ) { if ( configurationValues == null ) {
return; return;
} }
@ -247,7 +245,7 @@ public class LoadedConfig {
this.cacheRegionDefinitions.addAll( cacheRegionDefinitions ); this.cacheRegionDefinitions.addAll( cacheRegionDefinitions );
} }
private void addEventListeners(Map<EventType, Set<String>> eventListenerMap) { private void addEventListeners(Map<EventType<?>, Set<String>> eventListenerMap) {
if ( eventListenerMap == null ) { if ( eventListenerMap == null ) {
return; return;
} }
@ -256,7 +254,7 @@ public class LoadedConfig {
this.eventListenerMap = new HashMap<>(); this.eventListenerMap = new HashMap<>();
} }
for ( Map.Entry<EventType, Set<String>> incomingEntry : eventListenerMap.entrySet() ) { for ( Map.Entry<EventType<?>, Set<String>> incomingEntry : eventListenerMap.entrySet() ) {
Set<String> listenerClasses = this.eventListenerMap.get( incomingEntry.getKey() ); Set<String> listenerClasses = this.eventListenerMap.get( incomingEntry.getKey() );
if ( listenerClasses == null ) { if ( listenerClasses == null ) {
listenerClasses = new HashSet<>(); listenerClasses = new HashSet<>();

View File

@ -20,7 +20,7 @@ public final class DefaultSessionFactoryBuilderInitiator implements StandardServ
} }
@Override @Override
public SessionFactoryBuilderService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public SessionFactoryBuilderService initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return DefaultSessionFactoryBuilderService.INSTANCE; return DefaultSessionFactoryBuilderService.INSTANCE;
} }

View File

@ -17,7 +17,6 @@ import java.util.TimeZone;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.CustomEntityDirtinessStrategy; import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.EmptyInterceptor; import org.hibernate.EmptyInterceptor;
import org.hibernate.EntityNameResolver; import org.hibernate.EntityNameResolver;
@ -50,6 +49,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.id.uuid.LocalObjectUuidHelper; import org.hibernate.id.uuid.LocalObjectUuidHelper;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.NullnessHelper; import org.hibernate.internal.util.NullnessHelper;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jpa.spi.JpaCompliance; import org.hibernate.jpa.spi.JpaCompliance;
@ -268,8 +268,8 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class ); ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
final Map<Object,Object> configurationSettings = new HashMap<>(); final Map<String,Object> configurationSettings = new HashMap<>();
configurationSettings.putAll( jdbcServices.getJdbcEnvironment().getDialect().getDefaultProperties() ); configurationSettings.putAll( PropertiesHelper.map( jdbcServices.getJdbcEnvironment().getDialect().getDefaultProperties() ) );
configurationSettings.putAll( cfgService.getSettings() ); configurationSettings.putAll( cfgService.getSettings() );
if ( cfgService == null ) { if ( cfgService == null ) {
cfgService = new ConfigurationServiceImpl( configurationSettings ); cfgService = new ConfigurationServiceImpl( configurationSettings );
@ -702,7 +702,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
} }
private static Interceptor determineInterceptor( private static Interceptor determineInterceptor(
Map<Object,Object> configurationSettings, Map<String,Object> configurationSettings,
StrategySelector strategySelector) { StrategySelector strategySelector) {
Object setting = configurationSettings.get( INTERCEPTOR ); Object setting = configurationSettings.get( INTERCEPTOR );
if ( setting == null ) { if ( setting == null ) {
@ -724,7 +724,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static Supplier<? extends Interceptor> determineStatelessInterceptor( private static Supplier<? extends Interceptor> determineStatelessInterceptor(
Map<Object,Object> configurationSettings, Map<String,Object> configurationSettings,
StrategySelector strategySelector) { StrategySelector strategySelector) {
Object setting = configurationSettings.get( SESSION_SCOPED_INTERCEPTOR ); Object setting = configurationSettings.get( SESSION_SCOPED_INTERCEPTOR );
@ -761,7 +761,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
} }
private PhysicalConnectionHandlingMode interpretConnectionHandlingMode( private PhysicalConnectionHandlingMode interpretConnectionHandlingMode(
Map<Object,Object> configurationSettings, Map<String,Object> configurationSettings,
StandardServiceRegistry serviceRegistry) { StandardServiceRegistry serviceRegistry) {
final PhysicalConnectionHandlingMode specifiedHandlingMode = PhysicalConnectionHandlingMode.interpret( final PhysicalConnectionHandlingMode specifiedHandlingMode = PhysicalConnectionHandlingMode.interpret(
configurationSettings.get( CONNECTION_HANDLING ) configurationSettings.get( CONNECTION_HANDLING )

View File

@ -54,7 +54,6 @@ public class TypeBeanInstanceProducer implements BeanInstanceProducer, TypeBoots
} }
@Override @Override
@SuppressWarnings("unchecked")
public Map<String, Object> getConfigurationSettings() { public Map<String, Object> getConfigurationSettings() {
return typeConfiguration.getServiceRegistry().getService( ConfigurationService.class ).getSettings(); return typeConfiguration.getServiceRegistry().getService( ConfigurationService.class ).getSettings();
} }

View File

@ -28,5 +28,5 @@ public interface StandardServiceInitiator<R extends Service> extends ServiceInit
* *
* @return The initiated service. * @return The initiated service.
*/ */
R initiateService(Map configurationValues, ServiceRegistryImplementor registry); R initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry);
} }

View File

@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import org.hibernate.boot.cfgxml.internal.ConfigLoader; import org.hibernate.boot.cfgxml.internal.ConfigLoader;
import org.hibernate.boot.cfgxml.spi.LoadedConfig; import org.hibernate.boot.cfgxml.spi.LoadedConfig;
@ -20,6 +21,7 @@ import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.integrator.spi.Integrator; import org.hibernate.integrator.spi.Integrator;
import org.hibernate.integrator.spi.IntegratorService; import org.hibernate.integrator.spi.IntegratorService;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.Service; import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
@ -47,13 +49,13 @@ public class StandardServiceRegistryBuilder {
public static StandardServiceRegistryBuilder forJpa(BootstrapServiceRegistry bootstrapServiceRegistry) { public static StandardServiceRegistryBuilder forJpa(BootstrapServiceRegistry bootstrapServiceRegistry) {
final LoadedConfig loadedConfig = new LoadedConfig( null ) { final LoadedConfig loadedConfig = new LoadedConfig( null ) {
@Override @Override
protected void addConfigurationValues(Map configurationValues) { protected void addConfigurationValues(Map<String,Object> configurationValues) {
// here, do nothing // here, do nothing
} }
}; };
return new StandardServiceRegistryBuilder( return new StandardServiceRegistryBuilder(
bootstrapServiceRegistry, bootstrapServiceRegistry,
new HashMap(), new HashMap<>(),
loadedConfig loadedConfig
) { ) {
@Override @Override
@ -66,13 +68,13 @@ public class StandardServiceRegistryBuilder {
} }
/** /**
* The default resource name for a hibernate configuration xml file. * The default resource name for a Hibernate configuration xml file.
*/ */
public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml"; public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml";
private final Map settings; private final Map<String,Object> settings;
private final List<StandardServiceInitiator> initiators; private final List<StandardServiceInitiator<?>> initiators;
private final List<ProvidedService> providedServices = new ArrayList<>(); private final List<ProvidedService<?>> providedServices = new ArrayList<>();
private boolean autoCloseRegistry = true; private boolean autoCloseRegistry = true;
@ -97,14 +99,14 @@ public class StandardServiceRegistryBuilder {
} }
/** /**
* Intended for use exclusively from JPA boot-strapping, or extensions of * Intended for use exclusively from JPA bootstrapping, or extensions of
* this class. Consider this an SPI. * this class. Consider this an SPI.
* *
* @see #forJpa * @see #forJpa
*/ */
protected StandardServiceRegistryBuilder( protected StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry, BootstrapServiceRegistry bootstrapServiceRegistry,
Map settings, Map<String,Object> settings,
LoadedConfig loadedConfig) { LoadedConfig loadedConfig) {
this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
@ -114,7 +116,7 @@ public class StandardServiceRegistryBuilder {
} }
/** /**
* Intended for use exclusively from Quarkus boot-strapping, or extensions of * Intended for use exclusively from Quarkus bootstrapping, or extensions of
* this class which need to override the standard ServiceInitiator list. * this class which need to override the standard ServiceInitiator list.
* Consider this an SPI. * Consider this an SPI.
* @deprecated Quarkus will switch to use {@link #StandardServiceRegistryBuilder(BootstrapServiceRegistry, Map, ConfigLoader, LoadedConfig, List)} * @deprecated Quarkus will switch to use {@link #StandardServiceRegistryBuilder(BootstrapServiceRegistry, Map, ConfigLoader, LoadedConfig, List)}
@ -122,9 +124,9 @@ public class StandardServiceRegistryBuilder {
@Deprecated @Deprecated
protected StandardServiceRegistryBuilder( protected StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry, BootstrapServiceRegistry bootstrapServiceRegistry,
Map settings, Map <String,Object> settings,
LoadedConfig loadedConfig, LoadedConfig loadedConfig,
List<StandardServiceInitiator> initiators) { List<StandardServiceInitiator<?>> initiators) {
this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
this.settings = settings; this.settings = settings;
@ -133,16 +135,16 @@ public class StandardServiceRegistryBuilder {
} }
/** /**
* Intended for use exclusively from Quarkus boot-strapping, or extensions of * Intended for use exclusively from Quarkus bootstrapping, or extensions of
* this class which need to override the standard ServiceInitiator list. * this class which need to override the standard ServiceInitiator list.
* Consider this an SPI. * Consider this an SPI.
*/ */
protected StandardServiceRegistryBuilder( protected StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry, BootstrapServiceRegistry bootstrapServiceRegistry,
Map settings, Map<String,Object> settings,
ConfigLoader loader, ConfigLoader loader,
LoadedConfig loadedConfig, LoadedConfig loadedConfig,
List<StandardServiceInitiator> initiators) { List<StandardServiceInitiator<?>> initiators) {
this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = loader; this.configLoader = loader;
this.settings = settings; this.settings = settings;
@ -158,7 +160,7 @@ public class StandardServiceRegistryBuilder {
public StandardServiceRegistryBuilder( public StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry, BootstrapServiceRegistry bootstrapServiceRegistry,
LoadedConfig loadedConfigBaseline) { LoadedConfig loadedConfigBaseline) {
this.settings = Environment.getProperties(); this.settings = PropertiesHelper.map( Environment.getProperties() );
this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
this.aggregatedCfgXml = loadedConfigBaseline; this.aggregatedCfgXml = loadedConfigBaseline;
@ -181,13 +183,12 @@ public class StandardServiceRegistryBuilder {
* *
* @return List of standard initiators * @return List of standard initiators
*/ */
private static List<StandardServiceInitiator> standardInitiatorList() { private static List<StandardServiceInitiator<?>> standardInitiatorList() {
final List<StandardServiceInitiator> initiators = new ArrayList<>( StandardServiceInitiators.LIST.size() ); final List<StandardServiceInitiator<?>> initiators = new ArrayList<>( StandardServiceInitiators.LIST.size() );
initiators.addAll( StandardServiceInitiators.LIST ); initiators.addAll( StandardServiceInitiators.LIST );
return initiators; return initiators;
} }
@SuppressWarnings("unused")
public BootstrapServiceRegistry getBootstrapServiceRegistry() { public BootstrapServiceRegistry getBootstrapServiceRegistry() {
return bootstrapServiceRegistry; return bootstrapServiceRegistry;
} }
@ -205,9 +206,8 @@ public class StandardServiceRegistryBuilder {
* @see #configure() * @see #configure()
* @see #configure(String) * @see #configure(String)
*/ */
@SuppressWarnings({"unchecked"})
public StandardServiceRegistryBuilder loadProperties(String resourceName) { public StandardServiceRegistryBuilder loadProperties(String resourceName) {
settings.putAll( configLoader.loadProperties( resourceName ) ); settings.putAll( PropertiesHelper.map( configLoader.loadProperties( resourceName ) ) );
return this; return this;
} }
@ -224,9 +224,8 @@ public class StandardServiceRegistryBuilder {
* @see #configure() * @see #configure()
* @see #configure(String) * @see #configure(String)
*/ */
@SuppressWarnings({"unchecked"})
public StandardServiceRegistryBuilder loadProperties(File file) { public StandardServiceRegistryBuilder loadProperties(File file) {
settings.putAll( configLoader.loadProperties( file ) ); settings.putAll( PropertiesHelper.map( configLoader.loadProperties( file ) ) );
return this; return this;
} }
@ -262,7 +261,6 @@ public class StandardServiceRegistryBuilder {
return configure( configLoader.loadConfigXmlUrl( url ) ); return configure( configLoader.loadConfigXmlUrl( url ) );
} }
@SuppressWarnings({"unchecked"})
public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig) { public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig) {
aggregatedCfgXml.merge( loadedConfig ); aggregatedCfgXml.merge( loadedConfig );
settings.putAll( loadedConfig.getConfigurationValues() ); settings.putAll( loadedConfig.getConfigurationValues() );
@ -278,25 +276,38 @@ public class StandardServiceRegistryBuilder {
* *
* @return this, for method chaining * @return this, for method chaining
*/ */
@SuppressWarnings({"unchecked", "UnusedDeclaration"})
public StandardServiceRegistryBuilder applySetting(String settingName, Object value) { public StandardServiceRegistryBuilder applySetting(String settingName, Object value) {
settings.put( settingName, value ); settings.put( settingName, value );
return this; return this;
} }
/** /**
* Apply a groups of setting values. * Apply a group of settings.
* *
* @param settings The incoming settings to apply * @param settings The incoming settings to apply
* *
* @return this, for method chaining * @return this, for method chaining
*/ */
@SuppressWarnings({"unchecked", "UnusedDeclaration"}) public StandardServiceRegistryBuilder applySettings(Map<String,Object> settings) {
public StandardServiceRegistryBuilder applySettings(Map settings) {
this.settings.putAll( settings ); this.settings.putAll( settings );
return this; return this;
} }
/**
* Apply a group of settings.
*
* @param settings The incoming settings to apply
*
* @return this, for method chaining
*/
public StandardServiceRegistryBuilder applySettings(Properties settings) {
this.settings.putAll( PropertiesHelper.map(settings) );
return this;
}
/**
* Discard all the settings applied so far.
*/
public void clearSettings() { public void clearSettings() {
settings.clear(); settings.clear();
} }
@ -308,8 +319,7 @@ public class StandardServiceRegistryBuilder {
* *
* @return this, for method chaining * @return this, for method chaining
*/ */
@SuppressWarnings({"UnusedDeclaration"}) public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator<?> initiator) {
public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
initiators.add( initiator ); initiators.add( initiator );
return this; return this;
} }
@ -322,9 +332,8 @@ public class StandardServiceRegistryBuilder {
* *
* @return this, for method chaining * @return this, for method chaining
*/ */
@SuppressWarnings({"unchecked"}) public <T extends Service> StandardServiceRegistryBuilder addService(final Class<T> serviceRole, final T service) {
public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) { providedServices.add( new ProvidedService<>( serviceRole, service ) );
providedServices.add( new ProvidedService( serviceRole, service ) );
return this; return this;
} }
@ -362,12 +371,11 @@ public class StandardServiceRegistryBuilder {
* *
* @return The StandardServiceRegistry. * @return The StandardServiceRegistry.
*/ */
@SuppressWarnings("unchecked")
public StandardServiceRegistry build() { public StandardServiceRegistry build() {
applyServiceContributingIntegrators(); applyServiceContributingIntegrators();
applyServiceContributors(); applyServiceContributors();
final Map settingsCopy = new HashMap( settings ); final Map<String,Object> settingsCopy = new HashMap<>( settings );
settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml ); settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml );
ConfigurationHelper.resolvePlaceHolders( settingsCopy ); ConfigurationHelper.resolvePlaceHolders( settingsCopy );
@ -384,9 +392,9 @@ public class StandardServiceRegistryBuilder {
private void applyServiceContributingIntegrators() { private void applyServiceContributingIntegrators() {
for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class ) for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class )
.getIntegrators() ) { .getIntegrators() ) {
if ( org.hibernate.integrator.spi.ServiceContributingIntegrator.class.isInstance( integrator ) ) { if ( integrator instanceof org.hibernate.integrator.spi.ServiceContributingIntegrator ) {
org.hibernate.integrator.spi.ServiceContributingIntegrator.class.cast( integrator ).prepareServices( ( (org.hibernate.integrator.spi.ServiceContributingIntegrator) integrator )
this ); .prepareServices(this );
} }
} }
} }
@ -411,7 +419,7 @@ public class StandardServiceRegistryBuilder {
* This allows code to configure the builder and access that to configure Configuration object. * This allows code to configure the builder and access that to configure Configuration object.
*/ */
@Deprecated @Deprecated
public Map getSettings() { public Map<String,Object> getSettings() {
return settings; return settings;
} }

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.boot.registry.internal; package org.hibernate.boot.registry.internal;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -28,7 +27,7 @@ import org.hibernate.service.spi.ServiceInitiator;
public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl implements StandardServiceRegistry { public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl implements StandardServiceRegistry {
//Access to this field requires synchronization on -this- //Access to this field requires synchronization on -this-
private Map configurationValues; private Map<String,Object> configurationValues;
/** /**
* Constructs a StandardServiceRegistryImpl. Should not be instantiated directly; use * Constructs a StandardServiceRegistryImpl. Should not be instantiated directly; use
@ -41,12 +40,11 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
* *
* @see org.hibernate.boot.registry.StandardServiceRegistryBuilder * @see org.hibernate.boot.registry.StandardServiceRegistryBuilder
*/ */
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryImpl( public StandardServiceRegistryImpl(
BootstrapServiceRegistry bootstrapServiceRegistry, BootstrapServiceRegistry bootstrapServiceRegistry,
List<StandardServiceInitiator> serviceInitiators, List<StandardServiceInitiator<?>> serviceInitiators,
List<ProvidedService> providedServices, List<ProvidedService<?>> providedServices,
Map<?, ?> configurationValues) { Map<String,Object> configurationValues) {
this( true, bootstrapServiceRegistry, serviceInitiators, providedServices, configurationValues ); this( true, bootstrapServiceRegistry, serviceInitiators, providedServices, configurationValues );
} }
@ -63,13 +61,12 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
* *
* @see org.hibernate.boot.registry.StandardServiceRegistryBuilder * @see org.hibernate.boot.registry.StandardServiceRegistryBuilder
*/ */
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryImpl( public StandardServiceRegistryImpl(
boolean autoCloseRegistry, boolean autoCloseRegistry,
BootstrapServiceRegistry bootstrapServiceRegistry, BootstrapServiceRegistry bootstrapServiceRegistry,
List<StandardServiceInitiator> serviceInitiators, List<StandardServiceInitiator<?>> serviceInitiators,
List<ProvidedService> providedServices, List<ProvidedService<?>> providedServices,
Map<?, ?> configurationValues) { Map<String,Object> configurationValues) {
super( bootstrapServiceRegistry, autoCloseRegistry ); super( bootstrapServiceRegistry, autoCloseRegistry );
this.configurationValues = configurationValues; this.configurationValues = configurationValues;
@ -77,15 +74,17 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
applyServiceRegistrations( serviceInitiators, providedServices ); applyServiceRegistrations( serviceInitiators, providedServices );
} }
private void applyServiceRegistrations(List<StandardServiceInitiator> serviceInitiators, List<ProvidedService> providedServices) { private void applyServiceRegistrations(List<StandardServiceInitiator<?>> serviceInitiators, List<ProvidedService<?>> providedServices) {
try { try {
// process initiators // process initiators
for ( ServiceInitiator initiator : serviceInitiators ) { for ( ServiceInitiator<?> initiator : serviceInitiators ) {
createServiceBinding( initiator ); createServiceBinding( initiator );
} }
// then, explicitly provided service instances // then, explicitly provided service instances
//noinspection rawtypes
for ( ProvidedService providedService : providedServices ) { for ( ProvidedService providedService : providedServices ) {
//noinspection unchecked
createServiceBinding( providedService ); createServiceBinding( providedService );
} }
} }
@ -103,27 +102,11 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
@Override @Override
public synchronized <R extends Service> void configureService(ServiceBinding<R> serviceBinding) { public synchronized <R extends Service> void configureService(ServiceBinding<R> serviceBinding) {
if ( Configurable.class.isInstance( serviceBinding.getService() ) ) { if ( serviceBinding.getService() instanceof Configurable ) {
( (Configurable) serviceBinding.getService() ).configure( configurationValues ); ( (Configurable) serviceBinding.getService() ).configure( configurationValues );
} }
} }
/**
* Very advanced and tricky to handle: not designed for this. Intended for experiments only!
*/
public synchronized void resetAndReactivate(BootstrapServiceRegistry bootstrapServiceRegistry,
List<StandardServiceInitiator> serviceInitiators,
List<ProvidedService> providedServices,
Map<?, ?> configurationValues) {
if ( super.isActive() ) {
throw new IllegalStateException( "Can't reactivate an active registry!" );
}
super.resetParent( bootstrapServiceRegistry );
this.configurationValues = new HashMap( configurationValues );
super.reactivate();
applyServiceRegistrations( serviceInitiators, providedServices );
}
@Override @Override
public synchronized void destroy() { public synchronized void destroy() {
super.destroy(); super.destroy();

View File

@ -21,7 +21,7 @@ public final class BytecodeProviderInitiator implements StandardServiceInitiator
public static final StandardServiceInitiator<BytecodeProvider> INSTANCE = new BytecodeProviderInitiator(); public static final StandardServiceInitiator<BytecodeProvider> INSTANCE = new BytecodeProviderInitiator();
@Override @Override
public BytecodeProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public BytecodeProvider initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
// TODO in 6 this will no longer use Environment, which is configured via global environment variables, // TODO in 6 this will no longer use Environment, which is configured via global environment variables,
// but move to a component which can be reconfigured differently in each registry. // but move to a component which can be reconfigured differently in each registry.
return Environment.getBytecodeProvider(); return Environment.getBytecodeProvider();

View File

@ -27,7 +27,7 @@ public final class ProxyFactoryFactoryInitiator implements StandardServiceInitia
public static final StandardServiceInitiator<ProxyFactoryFactory> INSTANCE = new ProxyFactoryFactoryInitiator(); public static final StandardServiceInitiator<ProxyFactoryFactory> INSTANCE = new ProxyFactoryFactoryInitiator();
@Override @Override
public ProxyFactoryFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public ProxyFactoryFactory initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final BytecodeProvider bytecodeProvider = registry.getService( BytecodeProvider.class ); final BytecodeProvider bytecodeProvider = registry.getService( BytecodeProvider.class );
return bytecodeProvider.getProxyFactoryFactory(); return bytecodeProvider.getProxyFactoryFactory();
} }

View File

@ -40,7 +40,7 @@ public class NoCachingRegionFactory implements RegionFactory {
} }
@Override @Override
public void start(SessionFactoryOptions settings, Map configValues) throws CacheException { public void start(SessionFactoryOptions settings, Map<String,Object> configValues) throws CacheException {
} }
@Override @Override

View File

@ -43,7 +43,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFa
} }
@Override @Override
public RegionFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public RegionFactory initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final RegionFactory regionFactory = resolveRegionFactory( configurationValues, registry ); final RegionFactory regionFactory = resolveRegionFactory( configurationValues, registry );
LOG.debugf( "Cache region factory : %s", regionFactory.getClass().getName() ); LOG.debugf( "Cache region factory : %s", regionFactory.getClass().getName() );
@ -52,7 +52,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFa
} }
protected RegionFactory resolveRegionFactory(Map configurationValues, ServiceRegistryImplementor registry) { protected RegionFactory resolveRegionFactory(Map<String,Object> configurationValues, ServiceRegistryImplementor registry) {
final Properties p = new Properties(); final Properties p = new Properties();
p.putAll( configurationValues ); p.putAll( configurationValues );
@ -83,8 +83,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFa
if ( setting == null && implementors.size() != 1 ) { if ( setting == null && implementors.size() != 1 ) {
// if either is explicitly defined as TRUE we need a RegionFactory // if either is explicitly defined as TRUE we need a RegionFactory
if ( ( useSecondLevelCache != null && useSecondLevelCache == TRUE ) if ( useSecondLevelCache == TRUE || useQueryCache == TRUE ) {
|| ( useQueryCache != null && useQueryCache == TRUE ) ) {
throw new CacheException( "Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory" ); throw new CacheException( "Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory" );
} }
} }
@ -125,7 +124,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFa
return NoCachingRegionFactory.INSTANCE; return NoCachingRegionFactory.INSTANCE;
} }
protected RegionFactory getFallback(Map configurationValues, ServiceRegistryImplementor registry) { protected RegionFactory getFallback(Map<?,?> configurationValues, ServiceRegistryImplementor registry) {
return null; return null;
} }
} }

View File

@ -79,7 +79,7 @@ public abstract class AbstractRegionFactory implements RegionFactory {
} }
@Override @Override
public final void start(SessionFactoryOptions settings, Map configValues) throws CacheException { public final void start(SessionFactoryOptions settings, Map<String,Object> configValues) throws CacheException {
if ( started.compareAndSet( false, true ) ) { if ( started.compareAndSet( false, true ) ) {
synchronized (this) { synchronized (this) {
this.options = settings; this.options = settings;
@ -99,7 +99,7 @@ public abstract class AbstractRegionFactory implements RegionFactory {
} }
} }
protected abstract void prepareForUse(SessionFactoryOptions settings, Map configValues); protected abstract void prepareForUse(SessionFactoryOptions settings, Map<String,Object> configValues);
@Override @Override
public final void stop() { public final void stop() {

View File

@ -51,7 +51,7 @@ public interface RegionFactory extends Service, Stoppable {
* considered as a sign to stop {@link org.hibernate.SessionFactory} * considered as a sign to stop {@link org.hibernate.SessionFactory}
* building. * building.
*/ */
void start(SessionFactoryOptions settings, Map configValues) throws CacheException; void start(SessionFactoryOptions settings, Map<String,Object> configValues) throws CacheException;
/** /**
* By default should we perform "minimal puts" when using this second * By default should we perform "minimal puts" when using this second

View File

@ -320,7 +320,7 @@ public class Configuration {
* *
* @param type The type to register. * @param type The type to register.
*/ */
public Configuration registerTypeOverride(BasicType type) { public Configuration registerTypeOverride(BasicType<?> type) {
basicTypes.add( type ); basicTypes.add( type );
return this; return this;
} }
@ -865,7 +865,7 @@ public class Configuration {
* @return this for method chaining * @return this for method chaining
*/ */
public Configuration mergeProperties(Properties properties) { public Configuration mergeProperties(Properties properties) {
for ( Map.Entry entry : properties.entrySet() ) { for ( Map.Entry<Object,Object> entry : properties.entrySet() ) {
if ( this.properties.containsKey( entry.getKey() ) ) { if ( this.properties.containsKey( entry.getKey() ) ) {
continue; continue;
} }

View File

@ -29,7 +29,7 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe
ConfigurationServiceImpl.class.getName() ConfigurationServiceImpl.class.getName()
); );
private final Map settings; private final Map<String, Object> settings;
private ServiceRegistryImplementor serviceRegistry; private ServiceRegistryImplementor serviceRegistry;
/** /**
@ -37,13 +37,12 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe
* *
* @param settings The map of settings * @param settings The map of settings
*/ */
@SuppressWarnings( "unchecked" ) public ConfigurationServiceImpl(Map<String, Object> settings) {
public ConfigurationServiceImpl(Map settings) {
this.settings = Collections.unmodifiableMap( settings ); this.settings = Collections.unmodifiableMap( settings );
} }
@Override @Override
public Map getSettings() { public Map<String, Object> getSettings() {
return settings; return settings;
} }
@ -86,7 +85,7 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe
Class<T> target; Class<T> target;
if (candidate instanceof Class) { if (candidate instanceof Class) {
target = (Class) candidate; target = (Class<T>) candidate;
} }
else { else {
try { try {

View File

@ -24,7 +24,7 @@ public class ConfigurationServiceInitiator implements StandardServiceInitiator<C
public static final ConfigurationServiceInitiator INSTANCE = new ConfigurationServiceInitiator(); public static final ConfigurationServiceInitiator INSTANCE = new ConfigurationServiceInitiator();
@Override @Override
public ConfigurationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public ConfigurationService initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new ConfigurationServiceImpl( configurationValues ); return new ConfigurationServiceImpl( configurationValues );
} }

View File

@ -27,7 +27,7 @@ public interface ConfigurationService extends Service {
* *
* @return The immutable map of config settings. * @return The immutable map of config settings.
*/ */
Map getSettings(); Map<String,Object> getSettings();
/** /**
* Get the named setting, using the specified converter. * Get the named setting, using the specified converter.

View File

@ -38,7 +38,7 @@ public class BatchBuilderInitiator implements StandardServiceInitiator<BatchBuil
} }
@Override @Override
public BatchBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public BatchBuilder initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final Object builder = configurationValues.get( BUILDER ); final Object builder = configurationValues.get( BUILDER );
if ( builder == null ) { if ( builder == null ) {
return new BatchBuilderImpl( return new BatchBuilderImpl(
@ -46,7 +46,7 @@ public class BatchBuilderInitiator implements StandardServiceInitiator<BatchBuil
); );
} }
if ( BatchBuilder.class.isInstance( builder ) ) { if ( builder instanceof BatchBuilder ) {
return (BatchBuilder) builder; return (BatchBuilder) builder;
} }

View File

@ -9,7 +9,6 @@ package org.hibernate.engine.jdbc.batch.internal;
import java.util.Map; import java.util.Map;
import org.hibernate.boot.registry.StandardServiceInitiator; import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.batch.spi.BatchBuilder; import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
@ -36,7 +35,7 @@ public final class UnmodifiableBatchBuilderInitiator implements StandardServiceI
} }
@Override @Override
public BatchBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public BatchBuilder initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final Object builder = configurationValues.get( BatchBuilderInitiator.BUILDER ); final Object builder = configurationValues.get( BatchBuilderInitiator.BUILDER );
if ( builder == null ) { if ( builder == null ) {
return new UnmodifiableBatchBuilderImpl( return new UnmodifiableBatchBuilderImpl(

View File

@ -27,6 +27,6 @@ interface ConnectionCreatorFactory {
Boolean autocommit, Boolean autocommit,
Integer isolation, Integer isolation,
String initSql, String initSql,
Map<Object, Object> configurationValues); Map<String, Object> configurationValues);
} }

View File

@ -33,7 +33,7 @@ public class ConnectionCreatorFactoryImpl implements ConnectionCreatorFactory {
Boolean autoCommit, Boolean autoCommit,
Integer isolation, Integer isolation,
String initSql, String initSql,
Map<Object, Object> configurationValues) { Map<String, Object> configurationValues) {
if ( driver == null ) { if ( driver == null ) {
return new DriverManagerConnectionCreator( return new DriverManagerConnectionCreator(
serviceRegistry, serviceRegistry,

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.engine.jdbc.connections.internal; package org.hibernate.engine.jdbc.connections.internal;
import java.beans.BeanInfo;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.sql.Connection; import java.sql.Connection;
@ -27,7 +26,6 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.log.DeprecationLogger; import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.beans.BeanInfoHelper; import org.hibernate.internal.util.beans.BeanInfoHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.ServiceRegistryImplementor;
/** /**
@ -94,7 +92,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
@Override @Override
public ConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public ConnectionProvider initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
if ( configurationValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) { if ( configurationValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) {
// nothing to do, but given the separate hierarchies have to handle this here. // nothing to do, but given the separate hierarchies have to handle this here.
return null; return null;
@ -108,7 +106,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
return (ConnectionProvider) explicitSetting; return (ConnectionProvider) explicitSetting;
} }
else if ( explicitSetting instanceof Class ) { else if ( explicitSetting instanceof Class ) {
final Class providerClass = (Class) explicitSetting; final Class<?> providerClass = (Class<?>) explicitSetting;
LOG.instantiatingExplicitConnectionProvider( providerClass.getName() ); LOG.instantiatingExplicitConnectionProvider( providerClass.getName() );
return instantiateExplicitConnectionProvider( providerClass ); return instantiateExplicitConnectionProvider( providerClass );
} }
@ -125,7 +123,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
LOG.instantiatingExplicitConnectionProvider( providerName ); LOG.instantiatingExplicitConnectionProvider( providerName );
final Class providerClass = strategySelector.selectStrategyImplementor( final Class<?> providerClass = strategySelector.selectStrategyImplementor(
ConnectionProvider.class, ConnectionProvider.class,
providerName providerName
); );
@ -200,13 +198,12 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
final Map injectionData = (Map) configurationValues.get( INJECTION_DATA ); final Map<?,?> injectionData = (Map<?,?>) configurationValues.get( INJECTION_DATA );
if ( injectionData != null && injectionData.size() > 0 ) { if ( injectionData != null && injectionData.size() > 0 ) {
final ConnectionProvider theConnectionProvider = connectionProvider; final ConnectionProvider theConnectionProvider = connectionProvider;
new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo( new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo(
connectionProvider, connectionProvider,
new BeanInfoHelper.BeanInfoDelegate() { beanInfo -> {
public void processBeanInfo(BeanInfo beanInfo) throws Exception {
final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
for ( PropertyDescriptor descriptor : descriptors ) { for ( PropertyDescriptor descriptor : descriptors ) {
final String propertyName = descriptor.getName(); final String propertyName = descriptor.getName();
@ -219,7 +216,6 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
} }
} }
}
); );
} }
@ -235,7 +231,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
return null; return null;
} }
private ConnectionProvider instantiateExplicitConnectionProvider(Class providerClass) { private ConnectionProvider instantiateExplicitConnectionProvider(Class<?> providerClass) {
try { try {
return (ConnectionProvider) providerClass.newInstance(); return (ConnectionProvider) providerClass.newInstance();
} }
@ -244,10 +240,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
} }
private static boolean c3p0ConfigDefined(Map configValues) { private static boolean c3p0ConfigDefined(Map<String, Object> configValues) {
for ( Object key : configValues.keySet() ) { for ( String key : configValues.keySet() ) {
if ( String.class.isInstance( key ) if ( key.startsWith( AvailableSettings.C3P0_CONFIG_PREFIX ) ) {
&& ( (String) key ).startsWith( AvailableSettings.C3P0_CONFIG_PREFIX ) ) {
return true; return true;
} }
} }
@ -264,10 +259,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
} }
private static boolean proxoolConfigDefined(Map configValues) { private static boolean proxoolConfigDefined(Map<String, Object> configValues) {
for ( Object key : configValues.keySet() ) { for ( String key : configValues.keySet() ) {
if ( String.class.isInstance( key ) if ( key.startsWith( AvailableSettings.PROXOOL_CONFIG_PREFIX ) ) {
&& ( (String) key ).startsWith( AvailableSettings.PROXOOL_CONFIG_PREFIX ) ) {
return true; return true;
} }
} }
@ -284,13 +278,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
} }
private boolean hikariConfigDefined(Map configValues) { private boolean hikariConfigDefined(Map<String, Object> configValues) {
for ( Object key : configValues.keySet() ) { for ( String key : configValues.keySet() ) {
if ( !String.class.isInstance( key ) ) { if ( key.startsWith( "hibernate.hikari." ) ) {
continue;
}
if ( ( (String) key ).startsWith( "hibernate.hikari." ) ) {
return true; return true;
} }
} }
@ -307,13 +297,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
} }
private boolean viburConfigDefined(Map configValues) { private boolean viburConfigDefined(Map<String, Object> configValues) {
for ( Object key : configValues.keySet() ) { for ( String key : configValues.keySet() ) {
if ( !String.class.isInstance( key ) ) { if ( key.startsWith( "hibernate.vibur." ) ) {
continue;
}
if ( ( (String) key ).startsWith( "hibernate.vibur." ) ) {
return true; return true;
} }
} }
@ -321,13 +307,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
private boolean agroalConfigDefined(Map configValues) { private boolean agroalConfigDefined(Map<String, Object> configValues) {
for ( Object key : configValues.keySet() ) { for ( String key : configValues.keySet() ) {
if ( !String.class.isInstance( key ) ) { if ( key.startsWith( "hibernate.agroal." ) ) {
continue;
}
if ( ( (String) key ).startsWith( "hibernate.agroal." ) ) {
return true; return true;
} }
} }
@ -355,19 +337,20 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
} }
/** /**
* Build the connection properties capable of being passed to the {@link java.sql.DriverManager#getConnection} * Build the connection properties capable of being passed to
* forms taking {@link Properties} argument. We seek out all keys in the passed map which start with * {@link java.sql.DriverManager#getConnection(String, Properties)} forms taking {@link Properties} argument.
* {@code hibernate.connection.}, using them to create a new {@link Properties} instance. The keys in this * We seek out all keys in the passed map which start with {@code hibernate.connection.}, using them to create
* new {@link Properties} have the {@code hibernate.connection.} prefix trimmed. * a new {@link Properties} instance. The keys in this new {@link Properties} have the
* {@code hibernate.connection.} prefix trimmed.
* *
* @param properties The map from which to build the connection specific properties. * @param properties The map from which to build the connection specific properties.
* *
* @return The connection properties. * @return The connection properties.
*/ */
public static Properties getConnectionProperties(Map<?,?> properties) { public static Properties getConnectionProperties(Map<String,Object> properties) {
final Properties result = new Properties(); final Properties result = new Properties();
for ( Map.Entry entry : properties.entrySet() ) { for ( Map.Entry<?,?> entry : properties.entrySet() ) {
if ( ! ( String.class.isInstance( entry.getKey() ) ) || ! String.class.isInstance( entry.getValue() ) ) { if ( !(entry.getKey() instanceof String) || !(entry.getValue() instanceof String) ) {
continue; continue;
} }
final String key = (String) entry.getKey(); final String key = (String) entry.getKey();
@ -444,7 +427,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
AvailableSettings.ENABLE_SYNONYMS, "includeSynonyms" AvailableSettings.ENABLE_SYNONYMS, "includeSynonyms"
); );
public static Integer extractIsolation(Map settings) { public static Integer extractIsolation(Map<String,?> settings) {
return interpretIsolation( settings.get( AvailableSettings.ISOLATION ) ); return interpretIsolation( settings.get( AvailableSettings.ISOLATION ) );
} }
@ -453,7 +436,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
return null; return null;
} }
if ( Number.class.isInstance( setting ) ) { if ( setting instanceof Number ) {
return ( (Number) setting ).intValue(); return ( (Number) setting ).intValue();
} }

View File

@ -56,7 +56,7 @@ public class DatasourceConnectionProviderImpl implements ConnectionProvider, Con
} }
@Override @Override
public boolean isUnwrappableAs(Class unwrapType) { public boolean isUnwrappableAs(Class<?> unwrapType) {
return ConnectionProvider.class.equals( unwrapType ) || return ConnectionProvider.class.equals( unwrapType ) ||
DatasourceConnectionProviderImpl.class.isAssignableFrom( unwrapType ) || DatasourceConnectionProviderImpl.class.isAssignableFrom( unwrapType ) ||
DataSource.class.isAssignableFrom( unwrapType ); DataSource.class.isAssignableFrom( unwrapType );
@ -78,10 +78,10 @@ public class DatasourceConnectionProviderImpl implements ConnectionProvider, Con
} }
@Override @Override
public void configure(Map configValues) { public void configure(Map<String, Object> configValues) {
if ( this.dataSource == null ) { if ( this.dataSource == null ) {
final Object dataSource = configValues.get( Environment.DATASOURCE ); final Object dataSource = configValues.get( Environment.DATASOURCE );
if ( DataSource.class.isInstance( dataSource ) ) { if ( dataSource instanceof DataSource ) {
this.dataSource = (DataSource) dataSource; this.dataSource = (DataSource) dataSource;
} }
else { else {

View File

@ -73,15 +73,14 @@ public class DriverManagerConnectionProviderImpl
} }
@Override @Override
public void configure(Map configurationValues) { public void configure(Map<String, Object> configurationValues) {
CONNECTIONS_MESSAGE_LOGGER.usingHibernateBuiltInConnectionPool(); CONNECTIONS_MESSAGE_LOGGER.usingHibernateBuiltInConnectionPool();
PooledConnections pool = buildPool( configurationValues, serviceRegistry ); PooledConnections pool = buildPool( configurationValues, serviceRegistry );
final long validationInterval = ConfigurationHelper.getLong( VALIDATION_INTERVAL, configurationValues, 30 ); final long validationInterval = ConfigurationHelper.getLong( VALIDATION_INTERVAL, configurationValues, 30 );
PoolState newstate = new PoolState( pool, validationInterval ); this.state = new PoolState( pool, validationInterval );
this.state = newstate;
} }
private PooledConnections buildPool(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { private PooledConnections buildPool(Map<String,Object> configurationValues, ServiceRegistryImplementor serviceRegistry) {
final boolean autoCommit = ConfigurationHelper.getBoolean( final boolean autoCommit = ConfigurationHelper.getBoolean(
AvailableSettings.AUTOCOMMIT, AvailableSettings.AUTOCOMMIT,
configurationValues, configurationValues,
@ -103,7 +102,7 @@ public class DriverManagerConnectionProviderImpl
return pooledConnectionBuilder.build(); return pooledConnectionBuilder.build();
} }
private static ConnectionCreator buildCreator(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { private static ConnectionCreator buildCreator(Map<String,Object> configurationValues, ServiceRegistryImplementor serviceRegistry) {
final String url = (String) configurationValues.get( AvailableSettings.URL ); final String url = (String) configurationValues.get( AvailableSettings.URL );
String driverClassName = (String) configurationValues.get( AvailableSettings.DRIVER ); String driverClassName = (String) configurationValues.get( AvailableSettings.DRIVER );
@ -276,7 +275,7 @@ public class DriverManagerConnectionProviderImpl
} }
@Override @Override
public boolean isUnwrappableAs(Class unwrapType) { public boolean isUnwrappableAs(Class<?> unwrapType) {
return ConnectionProvider.class.equals( unwrapType ) || return ConnectionProvider.class.equals( unwrapType ) ||
DriverManagerConnectionProviderImpl.class.isAssignableFrom( unwrapType ); DriverManagerConnectionProviderImpl.class.isAssignableFrom( unwrapType );
} }
@ -516,7 +515,7 @@ public class DriverManagerConnectionProviderImpl
public static class Builder { public static class Builder {
private final ConnectionCreator connectionCreator; private final ConnectionCreator connectionCreator;
private ConnectionValidator connectionValidator; private ConnectionValidator connectionValidator;
private boolean autoCommit; private final boolean autoCommit;
private int initialSize = 1; private int initialSize = 1;
private int minSize = 1; private int minSize = 1;
private int maxSize = 20; private int maxSize = 20;

View File

@ -38,8 +38,7 @@ public class MultiTenantConnectionProviderInitiator implements StandardServiceIn
} }
@Override @Override
@SuppressWarnings( {"unchecked"}) public MultiTenantConnectionProvider initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
public MultiTenantConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
if ( !configurationValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) { if ( !configurationValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) {
// nothing to do, but given the separate hierarchies have to handle this here. // nothing to do, but given the separate hierarchies have to handle this here.
return null; return null;
@ -50,20 +49,22 @@ public class MultiTenantConnectionProviderInitiator implements StandardServiceIn
// if they also specified the data source *name*, then lets assume they want // if they also specified the data source *name*, then lets assume they want
// DataSourceBasedMultiTenantConnectionProviderImpl // DataSourceBasedMultiTenantConnectionProviderImpl
final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE ); final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE );
if ( String.class.isInstance( dataSourceConfigValue ) ) { if ( dataSourceConfigValue instanceof String ) {
return new DataSourceBasedMultiTenantConnectionProviderImpl(); return new DataSourceBasedMultiTenantConnectionProviderImpl();
} }
return null; return null;
} }
if ( MultiTenantConnectionProvider.class.isInstance( configValue ) ) { if ( configValue instanceof MultiTenantConnectionProvider ) {
return (MultiTenantConnectionProvider) configValue; return (MultiTenantConnectionProvider) configValue;
} }
else { else {
final Class<MultiTenantConnectionProvider> implClass; final Class<MultiTenantConnectionProvider> implClass;
if ( Class.class.isInstance( configValue ) ) { if ( configValue instanceof Class ) {
implClass = (Class) configValue; @SuppressWarnings("unchecked")
Class<MultiTenantConnectionProvider> clazz = (Class<MultiTenantConnectionProvider>) configValue;
implClass = clazz;
} }
else { else {
final String className = configValue.toString(); final String className = configValue.toString();

View File

@ -22,7 +22,7 @@ import org.hibernate.service.UnknownUnwrapTypeException;
*/ */
public class UserSuppliedConnectionProviderImpl implements ConnectionProvider { public class UserSuppliedConnectionProviderImpl implements ConnectionProvider {
@Override @Override
public boolean isUnwrappableAs(Class unwrapType) { public boolean isUnwrappableAs(Class<?> unwrapType) {
return ConnectionProvider.class.equals( unwrapType ) || return ConnectionProvider.class.equals( unwrapType ) ||
UserSuppliedConnectionProviderImpl.class.isAssignableFrom( unwrapType ); UserSuppliedConnectionProviderImpl.class.isAssignableFrom( unwrapType );
} }

View File

@ -46,7 +46,7 @@ public abstract class AbstractDataSourceBasedMultiTenantConnectionProviderImpl i
} }
@Override @Override
public boolean isUnwrappableAs(Class unwrapType) { public boolean isUnwrappableAs(Class<?> unwrapType) {
return return
DataSource.class.isAssignableFrom( unwrapType ) || DataSource.class.isAssignableFrom( unwrapType ) ||
MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType ); MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType );

View File

@ -47,7 +47,7 @@ public abstract class AbstractMultiTenantConnectionProvider implements MultiTena
} }
@Override @Override
public boolean isUnwrappableAs(Class unwrapType) { public boolean isUnwrappableAs(Class<?> unwrapType) {
return return
ConnectionProvider.class.isAssignableFrom( unwrapType ) || ConnectionProvider.class.isAssignableFrom( unwrapType ) ||
MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType ); MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType );

View File

@ -24,7 +24,7 @@ public class RefCursorSupportInitiator implements StandardServiceInitiator<RefCu
public static final RefCursorSupportInitiator INSTANCE = new RefCursorSupportInitiator(); public static final RefCursorSupportInitiator INSTANCE = new RefCursorSupportInitiator();
@Override @Override
public RefCursorSupport initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public RefCursorSupport initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new StandardRefCursorSupport(); return new StandardRefCursorSupport();
} }

View File

@ -53,7 +53,7 @@ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareS
} }
@Override @Override
public Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException { public Dialect buildDialect(Map<String,Object> configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException {
final Object dialectReference = configValues.get( AvailableSettings.DIALECT ); final Object dialectReference = configValues.get( AvailableSettings.DIALECT );
Dialect dialect = !isEmpty( dialectReference ) ? Dialect dialect = !isEmpty( dialectReference ) ?
constructDialect( dialectReference, resolutionInfoSource ) : constructDialect( dialectReference, resolutionInfoSource ) :

View File

@ -29,7 +29,7 @@ public class DialectFactoryInitiator implements StandardServiceInitiator<Dialect
} }
@Override @Override
public DialectFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public DialectFactory initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new DialectFactoryImpl(); return new DialectFactoryImpl();
} }
} }

View File

@ -36,7 +36,7 @@ public class DialectResolverInitiator implements StandardServiceInitiator<Dialec
} }
@Override @Override
public DialectResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public DialectResolver initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final DialectResolverSet resolverSet = new DialectResolverSet(); final DialectResolverSet resolverSet = new DialectResolverSet();
applyCustomerResolvers( resolverSet, registry, configurationValues ); applyCustomerResolvers( resolverSet, registry, configurationValues );

View File

@ -35,5 +35,5 @@ public interface DialectFactory extends Service {
* *
* @throws HibernateException No dialect specified and no resolver could make the determination. * @throws HibernateException No dialect specified and no resolver could make the determination.
*/ */
Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException; Dialect buildDialect(Map<String,Object> configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException;
} }

View File

@ -47,7 +47,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
} }
@Override @Override
public JdbcEnvironment initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public JdbcEnvironment initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final DialectFactory dialectFactory = registry.getService( DialectFactory.class ); final DialectFactory dialectFactory = registry.getService( DialectFactory.class );
// 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value. // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
@ -244,7 +244,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
return new JdbcEnvironmentImpl( registry, dialectFactory.buildDialect( configurationValues, null ) ); return new JdbcEnvironmentImpl( registry, dialectFactory.buildDialect( configurationValues, null ) );
} }
private JdbcConnectionAccess buildJdbcConnectionAccess(Map configValues, ServiceRegistryImplementor registry) { private JdbcConnectionAccess buildJdbcConnectionAccess(Map<?,?> configValues, ServiceRegistryImplementor registry) {
if ( !configValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) { if ( !configValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) {
ConnectionProvider connectionProvider = registry.getService( ConnectionProvider.class ); ConnectionProvider connectionProvider = registry.getService( ConnectionProvider.class );
return new ConnectionProviderJdbcConnectionAccess( connectionProvider ); return new ConnectionProviderJdbcConnectionAccess( connectionProvider );

View File

@ -8,7 +8,6 @@ package org.hibernate.engine.jdbc.internal;
import java.util.Map; import java.util.Map;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.LobCreationContext; import org.hibernate.engine.jdbc.LobCreationContext;
@ -45,7 +44,7 @@ public class JdbcServicesImpl implements JdbcServices, ServiceRegistryAwareServi
} }
@Override @Override
public void configure(Map configValues) { public void configure(Map<String, Object> configValues) {
this.jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class ); this.jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
assert jdbcEnvironment != null : "JdbcEnvironment was not found!"; assert jdbcEnvironment != null : "JdbcEnvironment was not found!";

View File

@ -31,7 +31,7 @@ public class JdbcServicesInitiator implements StandardServiceInitiator<JdbcServi
} }
@Override @Override
public JdbcServices initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public JdbcServices initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new JdbcServicesImpl(); return new JdbcServicesImpl();
} }
} }

View File

@ -34,14 +34,14 @@ public class SqlStatementLogger {
private final long logSlowQuery; private final long logSlowQuery;
/** /**
* Constructs a new SqlStatementLogger instance. * Constructs a new {@code SqlStatementLogger} instance.
*/ */
public SqlStatementLogger() { public SqlStatementLogger() {
this( false, false, false ); this( false, false, false );
} }
/** /**
* Constructs a new SqlStatementLogger instance. * Constructs a new {@code SqlStatementLogger} instance.
* *
* @param logToStdout Should we log to STDOUT in addition to our internal logger. * @param logToStdout Should we log to STDOUT in addition to our internal logger.
* @param format Should we format the statements in the console and log * @param format Should we format the statements in the console and log
@ -51,7 +51,7 @@ public class SqlStatementLogger {
} }
/** /**
* Constructs a new SqlStatementLogger instance. * Constructs a new {@code SqlStatementLogger} instance.
* *
* @param logToStdout Should we log to STDOUT in addition to our internal logger. * @param logToStdout Should we log to STDOUT in addition to our internal logger.
* @param format Should we format the statements in the console and log * @param format Should we format the statements in the console and log
@ -62,7 +62,7 @@ public class SqlStatementLogger {
} }
/** /**
* Constructs a new SqlStatementLogger instance. * Constructs a new {@code SqlStatementLogger} instance.
* *
* @param logToStdout Should we log to STDOUT in addition to our internal logger. * @param logToStdout Should we log to STDOUT in addition to our internal logger.
* @param format Should we format the statements in the console and log * @param format Should we format the statements in the console and log

View File

@ -10,7 +10,6 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Map; import java.util.Map;
import java.util.Set;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.naming.InvalidNameException; import javax.naming.InvalidNameException;
@ -39,14 +38,14 @@ final class JndiServiceImpl implements JndiService {
JndiServiceImpl.class.getName() JndiServiceImpl.class.getName()
); );
private final Hashtable initialContextSettings; private final Hashtable<String,Object> initialContextSettings;
/** /**
* Constructs a JndiServiceImpl * Constructs a JndiServiceImpl
* *
* @param configurationValues Map of configuration settings, some of which apply to JNDI support. * @param configurationValues Map of configuration settings, some of which apply to JNDI support.
*/ */
public JndiServiceImpl(Map configurationValues) { public JndiServiceImpl(Map<?,?> configurationValues) {
this.initialContextSettings = extractJndiProperties( configurationValues ); this.initialContextSettings = extractJndiProperties( configurationValues );
} }
@ -57,18 +56,17 @@ final class JndiServiceImpl implements JndiService {
* *
* @return The extracted JNDI specific properties. * @return The extracted JNDI specific properties.
*/ */
@SuppressWarnings({ "unchecked" }) private static Hashtable<String,Object> extractJndiProperties(Map<?,?> configurationValues) {
private static Hashtable extractJndiProperties(Map configurationValues) { final Hashtable<String,Object> jndiProperties = new Hashtable<>();
final Hashtable jndiProperties = new Hashtable();
for ( Map.Entry entry : (Set<Map.Entry>) configurationValues.entrySet() ) { for ( Map.Entry<?,?> entry : configurationValues.entrySet() ) {
if ( !String.class.isInstance( entry.getKey() ) ) { if ( !(entry.getKey() instanceof String) ) {
continue; continue;
} }
final String propertyName = (String) entry.getKey(); final String propertyName = (String) entry.getKey();
final Object propertyValue = entry.getValue(); final Object propertyValue = entry.getValue();
if ( propertyName.startsWith( Environment.JNDI_PREFIX ) ) { if ( propertyName.startsWith( Environment.JNDI_PREFIX ) ) {
// write the IntialContextFactory class and provider url to the result only if they are // write the InitialContextFactory class and provider url to the result only if they are
// non-null; this allows the environmental defaults (if any) to remain in effect // non-null; this allows the environmental defaults (if any) to remain in effect
if ( Environment.JNDI_CLASS.equals( propertyName ) ) { if ( Environment.JNDI_CLASS.equals( propertyName ) ) {
if ( propertyValue != null ) { if ( propertyValue != null ) {
@ -81,8 +79,8 @@ final class JndiServiceImpl implements JndiService {
} }
} }
else { else {
final String passThruPropertyname = propertyName.substring( Environment.JNDI_PREFIX.length() + 1 ); final String passThruPropertyName = propertyName.substring( Environment.JNDI_PREFIX.length() + 1 );
jndiProperties.put( passThruPropertyname, propertyValue ); jndiProperties.put( passThruPropertyName, propertyValue );
} }
} }
} }

View File

@ -29,7 +29,7 @@ public final class JndiServiceInitiator implements StandardServiceInitiator<Jndi
} }
@Override @Override
public JndiService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public JndiService initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new JndiServiceImpl( configurationValues ); return new JndiServiceImpl( configurationValues );
} }
} }

View File

@ -49,7 +49,7 @@ public abstract class AbstractJtaPlatform
protected abstract TransactionManager locateTransactionManager(); protected abstract TransactionManager locateTransactionManager();
protected abstract UserTransaction locateUserTransaction(); protected abstract UserTransaction locateUserTransaction();
public void configure(Map configValues) { public void configure(Map<String, Object> configValues) {
cacheTransactionManager = ConfigurationHelper.getBoolean( cacheTransactionManager = ConfigurationHelper.getBoolean(
AvailableSettings.JTA_CACHE_TM, AvailableSettings.JTA_CACHE_TM,
configValues, configValues,

View File

@ -34,8 +34,7 @@ public class JtaPlatformInitiator implements StandardServiceInitiator<JtaPlatfor
} }
@Override @Override
@SuppressWarnings( {"unchecked"}) public JtaPlatform initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM ); final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM );
JtaPlatform platform = registry.getService( StrategySelector.class ).resolveStrategy( JtaPlatform.class, setting ); JtaPlatform platform = registry.getService( StrategySelector.class ).resolveStrategy( JtaPlatform.class, setting );
@ -53,7 +52,7 @@ public class JtaPlatformInitiator implements StandardServiceInitiator<JtaPlatfor
return platform; return platform;
} }
protected JtaPlatform getFallbackProvider(Map configurationValues, ServiceRegistryImplementor registry) { protected JtaPlatform getFallbackProvider(Map<?,?> configurationValues, ServiceRegistryImplementor registry) {
return null; return null;
} }
} }

View File

@ -25,7 +25,7 @@ public class JtaPlatformResolverInitiator implements StandardServiceInitiator<Jt
private static final Logger log = Logger.getLogger( JtaPlatformResolverInitiator.class ); private static final Logger log = Logger.getLogger( JtaPlatformResolverInitiator.class );
@Override @Override
public JtaPlatformResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public JtaPlatformResolver initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM_RESOLVER ); final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM_RESOLVER );
final JtaPlatformResolver resolver = registry.getService( StrategySelector.class ) final JtaPlatformResolver resolver = registry.getService( StrategySelector.class )
.resolveStrategy( JtaPlatformResolver.class, setting ); .resolveStrategy( JtaPlatformResolver.class, setting );

View File

@ -32,7 +32,7 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( EntityCopyObserverFactoryInitiator.class ); private static final CoreMessageLogger LOG = CoreLogging.messageLogger( EntityCopyObserverFactoryInitiator.class );
@Override @Override
public EntityCopyObserverFactory initiateService(final Map configurationValues, final ServiceRegistryImplementor registry) { public EntityCopyObserverFactory initiateService(final Map<String, Object> configurationValues, final ServiceRegistryImplementor registry) {
final Object value = getConfigurationValue( configurationValues ); final Object value = getConfigurationValue( configurationValues );
if ( value.equals( EntityCopyNotAllowedObserver.SHORT_NAME ) || value.equals( EntityCopyNotAllowedObserver.class.getName() ) ) { if ( value.equals( EntityCopyNotAllowedObserver.SHORT_NAME ) || value.equals( EntityCopyNotAllowedObserver.class.getName() ) ) {
LOG.debugf( "Configured EntityCopyObserver strategy: %s", EntityCopyNotAllowedObserver.SHORT_NAME ); LOG.debugf( "Configured EntityCopyObserver strategy: %s", EntityCopyNotAllowedObserver.SHORT_NAME );
@ -51,13 +51,13 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia
//this might look excessive, but it also happens to test eagerly (at boot) that we can actually construct these //this might look excessive, but it also happens to test eagerly (at boot) that we can actually construct these
//and that they are indeed of the right type. //and that they are indeed of the right type.
EntityCopyObserver exampleInstance = registry.getService( StrategySelector.class ).resolveStrategy( EntityCopyObserver.class, value ); EntityCopyObserver exampleInstance = registry.getService( StrategySelector.class ).resolveStrategy( EntityCopyObserver.class, value );
Class observerType = exampleInstance.getClass(); Class<?> observerType = exampleInstance.getClass();
LOG.debugf( "Configured EntityCopyObserver is a custom implementation of type %s", observerType.getName() ); LOG.debugf( "Configured EntityCopyObserver is a custom implementation of type %s", observerType.getName() );
return new EntityObserversFactoryFromClass( observerType ); return new EntityObserversFactoryFromClass( observerType );
} }
} }
private Object getConfigurationValue(final Map configurationValues) { private Object getConfigurationValue(final Map<?,?> configurationValues) {
final Object o = configurationValues.get( AvailableSettings.MERGE_ENTITY_COPY_OBSERVER ); final Object o = configurationValues.get( AvailableSettings.MERGE_ENTITY_COPY_OBSERVER );
if ( o == null ) { if ( o == null ) {
return EntityCopyNotAllowedObserver.SHORT_NAME; //default return EntityCopyNotAllowedObserver.SHORT_NAME; //default
@ -77,9 +77,9 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia
private static class EntityObserversFactoryFromClass implements EntityCopyObserverFactory { private static class EntityObserversFactoryFromClass implements EntityCopyObserverFactory {
private final Class value; private final Class<?> value;
public EntityObserversFactoryFromClass(Class value) { public EntityObserversFactoryFromClass(Class<?> value) {
this.value = value; this.value = value;
} }

View File

@ -11,8 +11,9 @@ import java.util.Properties;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
/** /**
* The Configurable interface defines the contract for SQLExceptionConverter impls that * This interface defines the contract for {@link SQLExceptionConverter}
* want to be configured prior to usage given the currently defined Hibernate properties. * implementations that want to be configured prior to usage given the
* currently defined Hibernate properties.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -12,15 +12,14 @@ import java.sql.SQLException;
import org.hibernate.JDBCException; import org.hibernate.JDBCException;
/** /**
* Defines a contract for implementations that know how to convert a SQLException * Defines a contract for implementations that know how to convert a
* into Hibernate's JDBCException hierarchy. Inspired by Spring's * {@link SQLException} to Hibernate's {@link JDBCException} hierarchy.
* SQLExceptionTranslator.
* <p/> * <p/>
* Implementations <b>must</b> have a constructor which takes a * Implementations <b>must</b> have a constructor which takes a
* {@link ViolatedConstraintNameExtractor} parameter. * {@link ViolatedConstraintNameExtractor} parameter.
* <p/> * <p/>
* Implementations may implement {@link Configurable} if they need to perform * Implementations may implement {@link Configurable} if they need to
* configuration steps prior to first use. * perform configuration steps prior to first use.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@ -31,7 +30,11 @@ public interface SQLExceptionConverter extends Serializable {
* @param sqlException The SQLException to be converted. * @param sqlException The SQLException to be converted.
* @param message An optional error message. * @param message An optional error message.
* @return The resulting JDBCException. * @return The resulting JDBCException.
* @see org.hibernate.exception.ConstraintViolationException , JDBCConnectionException, SQLGrammarException, LockAcquisitionException *
* @see org.hibernate.exception.ConstraintViolationException
* @see org.hibernate.exception.JDBCConnectionException
* @see org.hibernate.exception.SQLGrammarException
* @see org.hibernate.exception.LockAcquisitionException
*/ */
JDBCException convert(SQLException sqlException, String message, String sql); JDBCException convert(SQLException sqlException, String message, String sql);
} }

View File

@ -10,7 +10,8 @@ import java.sql.SQLException;
/** /**
* Defines a contract for implementations that can extract the name of a violated * Defines a contract for implementations that can extract the name of a violated
* constraint from a SQLException that is the result of that constraint violation. * constraint from a {@link SQLException} that is the result of that constraint
* violation.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -0,0 +1,24 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.internal.util;
import java.util.Map;
import java.util.Properties;
public class PropertiesHelper {
/**
* Pretend that a {@link Properties} object is really a
* {@link Map Map&lt;String,Object&gt;}, which of course it
* should be anyway.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static Map<String, Object> map(Properties properties) {
//yup, I'm really doing this, and yep, I know it's rubbish:
return (Map) properties;
}
}

View File

@ -55,25 +55,25 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
return builder.build(); return builder.build();
} }
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties) { protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map<?,?> properties) {
return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, null, null ); return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, null, null );
} }
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map<?,?> properties,
ClassLoader providedClassLoader) { ClassLoader providedClassLoader) {
return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, providedClassLoader, null ); return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, providedClassLoader, null );
} }
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map<?,?> properties,
ClassLoaderService providedClassLoaderService) { ClassLoaderService providedClassLoaderService) {
return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, null, providedClassLoaderService ); return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, null, providedClassLoaderService );
} }
private EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, private EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map<?,?> properties,
ClassLoader providedClassLoader, ClassLoaderService providedClassLoaderService) { ClassLoader providedClassLoader, ClassLoaderService providedClassLoaderService) {
log.tracef( "Attempting to obtain correct EntityManagerFactoryBuilder for persistenceUnitName : %s", persistenceUnitName ); log.tracef( "Attempting to obtain correct EntityManagerFactoryBuilder for persistenceUnitName : %s", persistenceUnitName );
final Map integration = wrap( properties ); final Map<?,?> integration = wrap( properties );
final List<ParsedPersistenceXmlDescriptor> units; final List<ParsedPersistenceXmlDescriptor> units;
try { try {
units = PersistenceXmlParser.locatePersistenceUnits( integration ); units = PersistenceXmlParser.locatePersistenceUnits( integration );
@ -124,8 +124,7 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
return null; return null;
} }
@SuppressWarnings("unchecked") protected static Map<?,?> wrap(Map<?,?> properties) {
protected static Map wrap(Map properties) {
return properties == null ? Collections.emptyMap() : Collections.unmodifiableMap( properties ); return properties == null ? Collections.emptyMap() : Collections.unmodifiableMap( properties );
} }
@ -166,17 +165,17 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
return true; return true;
} }
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitInfo info, Map integration) { protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitInfo info, Map<?,?> integration) {
return Bootstrap.getEntityManagerFactoryBuilder( info, integration ); return Bootstrap.getEntityManagerFactoryBuilder( info, integration );
} }
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor, protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor,
Map integration, ClassLoader providedClassLoader) { Map<?,?> integration, ClassLoader providedClassLoader) {
return Bootstrap.getEntityManagerFactoryBuilder( persistenceUnitDescriptor, integration, providedClassLoader ); return Bootstrap.getEntityManagerFactoryBuilder( persistenceUnitDescriptor, integration, providedClassLoader );
} }
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor, protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor,
Map integration, ClassLoaderService providedClassLoaderService) { Map<?,?> integration, ClassLoaderService providedClassLoaderService) {
return Bootstrap.getEntityManagerFactoryBuilder( persistenceUnitDescriptor, integration, providedClassLoaderService ); return Bootstrap.getEntityManagerFactoryBuilder( persistenceUnitDescriptor, integration, providedClassLoaderService );
} }

View File

@ -59,6 +59,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.integrator.spi.Integrator; import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.EntityManagerMessageLogger; import org.hibernate.internal.EntityManagerMessageLogger;
import org.hibernate.internal.util.NullnessHelper; import org.hibernate.internal.util.NullnessHelper;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder; import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
@ -166,7 +167,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// things built in first phase, needed for second phase // things built in first phase, needed for second phase
private final Map<Object,Object> configurationValues; private final Map<String,Object> configurationValues;
private final StandardServiceRegistry standardServiceRegistry; private final StandardServiceRegistry standardServiceRegistry;
private final ManagedResources managedResources; private final ManagedResources managedResources;
private final MetadataBuilderImplementor metamodelBuilder; private final MetadataBuilderImplementor metamodelBuilder;
@ -184,20 +185,20 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
public EntityManagerFactoryBuilderImpl( public EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnit, PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings) { Map<String, Object> integrationSettings) {
this( persistenceUnit, integrationSettings, null, null, null ); this( persistenceUnit, integrationSettings, null, null, null );
} }
public EntityManagerFactoryBuilderImpl( public EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnit, PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings, Map<String, Object> integrationSettings,
ClassLoader providedClassLoader ) { ClassLoader providedClassLoader ) {
this( persistenceUnit, integrationSettings, providedClassLoader, null, null ); this( persistenceUnit, integrationSettings, providedClassLoader, null, null );
} }
public EntityManagerFactoryBuilderImpl( public EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnit, PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings, Map<String, Object> integrationSettings,
ClassLoaderService providedClassLoaderService ) { ClassLoaderService providedClassLoaderService ) {
this( persistenceUnit, integrationSettings, null, providedClassLoaderService, null ); this( persistenceUnit, integrationSettings, null, providedClassLoaderService, null );
} }
@ -208,14 +209,14 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
@Internal @Internal
public EntityManagerFactoryBuilderImpl( public EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnitDescriptor, PersistenceUnitDescriptor persistenceUnitDescriptor,
Map<?,?> integration, Map<String, Object> integration,
Consumer<MergedSettings> mergedSettingsBaseline) { Consumer<MergedSettings> mergedSettingsBaseline) {
this( persistenceUnitDescriptor, integration, null, null, mergedSettingsBaseline ); this( persistenceUnitDescriptor, integration, null, null, mergedSettingsBaseline );
} }
private EntityManagerFactoryBuilderImpl( private EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnit, PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings, Map<String,Object> integrationSettings,
ClassLoader providedClassLoader, ClassLoader providedClassLoader,
ClassLoaderService providedClassLoaderService, ClassLoaderService providedClassLoaderService,
Consumer<MergedSettings> mergedSettingsBaseline) { Consumer<MergedSettings> mergedSettingsBaseline) {
@ -514,7 +515,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
private MergedSettings mergeSettings( private MergedSettings mergeSettings(
PersistenceUnitDescriptor persistenceUnit, PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings, Map<String,Object> integrationSettings,
StandardServiceRegistryBuilder ssrBuilder, StandardServiceRegistryBuilder ssrBuilder,
Consumer<MergedSettings> mergedSettingsBaseline) { Consumer<MergedSettings> mergedSettingsBaseline) {
final MergedSettings mergedSettings = new MergedSettings(); final MergedSettings mergedSettings = new MergedSettings();
@ -541,17 +542,17 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
// 2) additional cache region declarations // 2) additional cache region declarations
// //
// we will also clean up any references with null entries // we will also clean up any references with null entries
Iterator<Map.Entry<Object,Object>> itr = mergedSettings.configurationValues.entrySet().iterator(); Iterator<Map.Entry<String,Object>> itr = mergedSettings.configurationValues.entrySet().iterator();
while ( itr.hasNext() ) { while ( itr.hasNext() ) {
final Map.Entry<Object,Object> entry = itr.next(); final Map.Entry<String,Object> entry = itr.next();
if ( entry.getValue() == null ) { if ( entry.getValue() == null ) {
// remove entries with null values // remove entries with null values
itr.remove(); itr.remove();
break; break;
} }
if ( entry.getKey() instanceof String && entry.getValue() instanceof String) { if ( entry.getValue() instanceof String) {
final String keyString = (String) entry.getKey(); final String keyString = entry.getKey();
final String valueString = (String) entry.getValue(); final String valueString = (String) entry.getValue();
if ( keyString.startsWith( CLASS_CACHE_PREFIX ) ) { if ( keyString.startsWith( CLASS_CACHE_PREFIX ) ) {
@ -584,10 +585,10 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
*/ */
private void normalizeSettings( private void normalizeSettings(
PersistenceUnitDescriptor persistenceUnit, PersistenceUnitDescriptor persistenceUnit,
Map<?, ?> integrationSettings, Map<String, Object> integrationSettings,
MergedSettings mergedSettings) { MergedSettings mergedSettings) {
// make a copy so we can remove things as we process them // make a copy so we can remove things as we process them
final HashMap<?, ?> integrationSettingsCopy = new HashMap<>( integrationSettings ); final HashMap<String, Object> integrationSettingsCopy = new HashMap<>( integrationSettings );
normalizeConnectionAccessUserAndPass( integrationSettingsCopy, mergedSettings ); normalizeConnectionAccessUserAndPass( integrationSettingsCopy, mergedSettings );
@ -630,7 +631,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
// //
// NOTE that this occurs after the specialized normalize calls above which remove // NOTE that this occurs after the specialized normalize calls above which remove
// any specially-handled settings. // any specially-handled settings.
for ( Map.Entry<?,?> entry : integrationSettingsCopy.entrySet() ) { for ( Map.Entry<String,Object> entry : integrationSettingsCopy.entrySet() ) {
if ( entry.getKey() == null ) { if ( entry.getKey() == null ) {
continue; continue;
} }
@ -1515,7 +1516,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
} }
public static class MergedSettings { public static class MergedSettings {
private final Map<Object,Object> configurationValues = new ConcurrentHashMap<>( 16, 0.75f, 1 ); private final Map<String,Object> configurationValues = new ConcurrentHashMap<>( 16, 0.75f, 1 );
private List<CacheRegionDefinition> cacheRegionDefinitions; private List<CacheRegionDefinition> cacheRegionDefinitions;
@ -1523,12 +1524,12 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
* MergedSettings is initialized with hibernate.properties * MergedSettings is initialized with hibernate.properties
*/ */
private MergedSettings() { private MergedSettings() {
configurationValues.putAll( Environment.getProperties() ); configurationValues.putAll( PropertiesHelper.map( Environment.getProperties() ) );
} }
public void processPersistenceUnitDescriptorProperties(PersistenceUnitDescriptor persistenceUnit) { public void processPersistenceUnitDescriptorProperties(PersistenceUnitDescriptor persistenceUnit) {
if ( persistenceUnit.getProperties() != null ) { if ( persistenceUnit.getProperties() != null ) {
configurationValues.putAll( persistenceUnit.getProperties() ); configurationValues.putAll( PropertiesHelper.map( persistenceUnit.getProperties() ) );
} }
configurationValues.put( PERSISTENCE_UNIT_NAME, persistenceUnit.getName() ); configurationValues.put( PERSISTENCE_UNIT_NAME, persistenceUnit.getName() );
@ -1551,7 +1552,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
configurationValues.putAll( loadedConfig.getConfigurationValues() ); configurationValues.putAll( loadedConfig.getConfigurationValues() );
} }
public Map<Object,Object> getConfigurationValues() { public Map<String,Object> getConfigurationValues() {
return configurationValues; return configurationValues;
} }

View File

@ -27,14 +27,13 @@ public class PersisterClassResolverInitiator implements StandardServiceInitiator
} }
@Override @Override
@SuppressWarnings( {"unchecked"}) public PersisterClassResolver initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
public PersisterClassResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object customImpl = configurationValues.get( IMPL_NAME ); final Object customImpl = configurationValues.get( IMPL_NAME );
if ( customImpl == null ) { if ( customImpl == null ) {
return new StandardPersisterClassResolver(); return new StandardPersisterClassResolver();
} }
if ( PersisterClassResolver.class.isInstance( customImpl ) ) { if ( customImpl instanceof PersisterClassResolver ) {
return (PersisterClassResolver) customImpl; return (PersisterClassResolver) customImpl;
} }

View File

@ -28,18 +28,18 @@ public class PersisterFactoryInitiator implements StandardServiceInitiator<Persi
} }
@Override @Override
@SuppressWarnings( {"unchecked"}) public PersisterFactory initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
public PersisterFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object customImpl = configurationValues.get( IMPL_NAME ); final Object customImpl = configurationValues.get( IMPL_NAME );
if ( customImpl == null ) { if ( customImpl == null ) {
return new PersisterFactoryImpl(); return new PersisterFactoryImpl();
} }
if ( PersisterFactory.class.isInstance( customImpl ) ) { if ( customImpl instanceof PersisterFactory ) {
return (PersisterFactory) customImpl; return (PersisterFactory) customImpl;
} }
final Class<? extends PersisterFactory> customImplClass = Class.class.isInstance( customImpl ) @SuppressWarnings("unchecked")
final Class<? extends PersisterFactory> customImplClass = customImpl instanceof Class
? ( Class<? extends PersisterFactory> ) customImpl ? ( Class<? extends PersisterFactory> ) customImpl
: locate( registry, customImpl.toString() ); : locate( registry, customImpl.toString() );
try { try {

View File

@ -27,7 +27,7 @@ public class PropertyAccessStrategyResolverInitiator implements StandardServiceI
} }
@Override @Override
public PropertyAccessStrategyResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public PropertyAccessStrategyResolver initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new PropertyAccessStrategyResolverStandardImpl( registry ); return new PropertyAccessStrategyResolverStandardImpl( registry );
} }
} }

View File

@ -240,7 +240,6 @@ public abstract class AbstractCommonQueryContract implements CommonQueryContract
return this; return this;
} }
@SuppressWarnings("deprecation")
public final boolean applyHint(String hintName, Object value) { public final boolean applyHint(String hintName, Object value) {
getSession().checkOpen( true ); getSession().checkOpen( true );
@ -632,13 +631,12 @@ public abstract class AbstractCommonQueryContract implements CommonQueryContract
setHibernateFlushMode( FlushModeTypeHelper.getFlushMode( flushModeType ) ); setHibernateFlushMode( FlushModeTypeHelper.getFlushMode( flushModeType ) );
} }
@SuppressWarnings( "rawtypes" ) public boolean applyTupleTransformer(TupleTransformer<?> transformer) {
public boolean applyTupleTransformer(TupleTransformer transformer) {
getQueryOptions().setTupleTransformer( transformer ); getQueryOptions().setTupleTransformer( transformer );
return true; return true;
} }
public boolean applyResultListTransformer(ResultListTransformer transformer) { public boolean applyResultListTransformer(ResultListTransformer<?> transformer) {
getQueryOptions().setResultListTransformer( transformer ); getQueryOptions().setResultListTransformer( transformer );
return true; return true;
} }
@ -1394,7 +1392,7 @@ public abstract class AbstractCommonQueryContract implements CommonQueryContract
} }
@Override @Override
public CommonQueryContract setProperties(Map map) { public CommonQueryContract setProperties(@SuppressWarnings("rawtypes") Map map) {
for ( String paramName : getParameterMetadata().getNamedParameterNames() ) { for ( String paramName : getParameterMetadata().getNamedParameterNames() ) {
final Object object = map.get( paramName ); final Object object = map.get( paramName );
if ( object == null ) { if ( object == null ) {

View File

@ -7,7 +7,7 @@
package org.hibernate.resource.beans.container.spi; package org.hibernate.resource.beans.container.spi;
/** /**
* Release-able extension to ContainedBean. We make the split to make it * Release-able extension to {@link ContainedBean}. We make the split to make it
* clear that generally speaking the callers to BeanContainer should not perform * clear that generally speaking the callers to BeanContainer should not perform
* the release * the release
* *

View File

@ -11,7 +11,7 @@ import jakarta.enterprise.inject.spi.BeanManager;
/** /**
* This contract and the nested LifecycleListener contract represent the changes * This contract and the nested LifecycleListener contract represent the changes
* we'd like to propose to the CDI spec. The idea being simply to allow contextual * we'd like to propose to the CDI spec. The idea being simply to allow contextual
* registration of BeanManager lifecycle callbacks * registration of {@link BeanManager} lifecycle callbacks
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -7,7 +7,7 @@
package org.hibernate.resource.beans.spi; package org.hibernate.resource.beans.spi;
/** /**
* Generalized contract for a "ManagedBean" as seen by Hibernate * Generalized contract for a (CDI or Spring) "managed bean" as seen by Hibernate
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -10,7 +10,7 @@ import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.service.Service; import org.hibernate.service.Service;
/** /**
* A registry for ManagedBean instances. Responsible for managing the lifecycle. * A registry for {@link ManagedBean} instances. Responsible for managing the lifecycle.
* <p/> * <p/>
* Access to the beans and usage of them are only valid between the time * Access to the beans and usage of them are only valid between the time
* the registry is initialized and released (however those events are recognized). * the registry is initialized and released (however those events are recognized).

View File

@ -22,7 +22,7 @@ import org.hibernate.resource.beans.internal.ManagedBeanRegistryImpl;
import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.ServiceRegistryImplementor;
/** /**
* Hibernate's standard initializer for the ManagedBeanRegistry service. * Hibernate's standard initializer for the {@link ManagedBeanRegistry} service.
* *
* Produces a {@link ManagedBeanRegistryImpl} * Produces a {@link ManagedBeanRegistryImpl}
* *
@ -41,12 +41,12 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator<Ma
@Override @Override
public ManagedBeanRegistry initiateService( public ManagedBeanRegistry initiateService(
Map configurationValues, Map<String, Object> configurationValues,
ServiceRegistryImplementor serviceRegistry) { ServiceRegistryImplementor serviceRegistry) {
return new ManagedBeanRegistryImpl( resolveBeanContainer( configurationValues, serviceRegistry ) ); return new ManagedBeanRegistryImpl( resolveBeanContainer( configurationValues, serviceRegistry ) );
} }
private BeanContainer resolveBeanContainer(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { private BeanContainer resolveBeanContainer(Map<?,?> configurationValues, ServiceRegistryImplementor serviceRegistry) {
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
final ConfigurationService cfgSvc = serviceRegistry.getService( ConfigurationService.class ); final ConfigurationService cfgSvc = serviceRegistry.getService( ConfigurationService.class );
@ -92,14 +92,14 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator<Ma
} }
// otherwise we ultimately need to resolve this to a class // otherwise we ultimately need to resolve this to a class
final Class containerClass; final Class<?> containerClass;
if ( explicitSetting instanceof Class ) { if ( explicitSetting instanceof Class ) {
containerClass = (Class) explicitSetting; containerClass = (Class<?>) explicitSetting;
} }
else { else {
final String name = explicitSetting.toString(); final String name = explicitSetting.toString();
// try the StrategySelector service // try the StrategySelector service
final Class selected = serviceRegistry.getService( StrategySelector.class ) final Class<?> selected = serviceRegistry.getService( StrategySelector.class )
.selectStrategyImplementor( BeanContainer.class, name ); .selectStrategyImplementor( BeanContainer.class, name );
if ( selected != null ) { if ( selected != null ) {
containerClass = selected; containerClass = selected;
@ -128,7 +128,7 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator<Ma
} }
} }
public static Class cdiBeanManagerClass(ClassLoaderService classLoaderService) throws ClassLoadingException { public static Class<?> cdiBeanManagerClass(ClassLoaderService classLoaderService) throws ClassLoadingException {
try { try {
return classLoaderService.classForName( "jakarta.enterprise.inject.spi.BeanManager" ); return classLoaderService.classForName( "jakarta.enterprise.inject.spi.BeanManager" );
} }

View File

@ -7,7 +7,7 @@
package org.hibernate.resource.beans.spi; package org.hibernate.resource.beans.spi;
/** /**
* ManagedBean implementation for cases where we have been handed an actual * {@link ManagedBean} implementation for cases where we have been handed an actual
* instance to use. * instance to use.
* *
* @author Steve Ebersole * @author Steve Ebersole

View File

@ -31,7 +31,7 @@ public class TransactionCoordinatorBuilderInitiator implements StandardServiceIn
public static final TransactionCoordinatorBuilderInitiator INSTANCE = new TransactionCoordinatorBuilderInitiator(); public static final TransactionCoordinatorBuilderInitiator INSTANCE = new TransactionCoordinatorBuilderInitiator();
@Override @Override
public TransactionCoordinatorBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public TransactionCoordinatorBuilder initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return registry.getService( StrategySelector.class ).resolveDefaultableStrategy( return registry.getService( StrategySelector.class ).resolveDefaultableStrategy(
TransactionCoordinatorBuilder.class, TransactionCoordinatorBuilder.class,
determineStrategySelection( configurationValues ), determineStrategySelection( configurationValues ),

View File

@ -47,10 +47,10 @@ public final class StandardServiceInitiators {
private StandardServiceInitiators() { private StandardServiceInitiators() {
} }
public static final List<StandardServiceInitiator> LIST = buildStandardServiceInitiatorList(); public static final List<StandardServiceInitiator<?>> LIST = buildStandardServiceInitiatorList();
private static List<StandardServiceInitiator> buildStandardServiceInitiatorList() { private static List<StandardServiceInitiator<?>> buildStandardServiceInitiatorList() {
final ArrayList<StandardServiceInitiator> serviceInitiators = new ArrayList<>(); final ArrayList<StandardServiceInitiator<?>> serviceInitiators = new ArrayList<>();
serviceInitiators.add( DefaultSessionFactoryBuilderInitiator.INSTANCE ); serviceInitiators.add( DefaultSessionFactoryBuilderInitiator.INSTANCE );

View File

@ -50,31 +50,29 @@ public abstract class AbstractServiceRegistryImpl
private volatile ServiceRegistryImplementor parent; private volatile ServiceRegistryImplementor parent;
private final boolean allowCrawling; private final boolean allowCrawling;
private final ConcurrentMap<Class,ServiceBinding> serviceBindingMap = new ConcurrentHashMap<>(); private final ConcurrentMap<Class<?>,ServiceBinding<?>> serviceBindingMap = new ConcurrentHashMap<>();
private final ConcurrentMap<Class,Class> roleXref = new ConcurrentHashMap<>(); private final ConcurrentMap<Class<?>,Class<?>> roleXref = new ConcurrentHashMap<>();
// The services stored in initializedServiceByRole are completely initialized // The services stored in initializedServiceByRole are completely initialized
// (i.e., configured, dependencies injected, and started) // (i.e., configured, dependencies injected, and started)
private final ConcurrentMap<Class,Service> initializedServiceByRole = new ConcurrentHashMap<>(); private final ConcurrentMap<Class<?>,Service> initializedServiceByRole = new ConcurrentHashMap<>();
// IMPL NOTE : the list used for ordered destruction. Cannot used map above because we need to // IMPL NOTE : the list used for ordered destruction. Cannot used map above because we need to
// iterate it in reverse order which is only available through ListIterator // iterate it in reverse order which is only available through ListIterator
// assume 20 services for initial sizing // assume 20 services for initial sizing
// All access guarded by synchronization on the serviceBindingList itself. // All access guarded by synchronization on the serviceBindingList itself.
private final List<ServiceBinding> serviceBindingList = CollectionHelper.arrayList( 20 ); private final List<ServiceBinding<?>> serviceBindingList = CollectionHelper.arrayList( 20 );
// Guarded by synchronization on this. // Guarded by synchronization on this.
private boolean autoCloseRegistry; private final boolean autoCloseRegistry;
// Guarded by synchronization on this. // Guarded by synchronization on this.
private Set<ServiceRegistryImplementor> childRegistries; private Set<ServiceRegistryImplementor> childRegistries;
private final AtomicBoolean active = new AtomicBoolean( true ); private final AtomicBoolean active = new AtomicBoolean( true );
@SuppressWarnings( {"UnusedDeclaration"})
protected AbstractServiceRegistryImpl() { protected AbstractServiceRegistryImpl() {
this( (ServiceRegistryImplementor) null ); this( (ServiceRegistryImplementor) null );
} }
@SuppressWarnings( {"UnusedDeclaration"})
protected AbstractServiceRegistryImpl(boolean autoCloseRegistry) { protected AbstractServiceRegistryImpl(boolean autoCloseRegistry) {
this( (ServiceRegistryImplementor) null, autoCloseRegistry ); this( (ServiceRegistryImplementor) null, autoCloseRegistry );
} }
@ -100,7 +98,7 @@ public abstract class AbstractServiceRegistryImpl
public AbstractServiceRegistryImpl( public AbstractServiceRegistryImpl(
BootstrapServiceRegistry bootstrapServiceRegistry, BootstrapServiceRegistry bootstrapServiceRegistry,
boolean autoCloseRegistry) { boolean autoCloseRegistry) {
if ( ! ServiceRegistryImplementor.class.isInstance( bootstrapServiceRegistry ) ) { if ( !(bootstrapServiceRegistry instanceof ServiceRegistryImplementor) ) {
throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" ); throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" );
} }
this.parent = (ServiceRegistryImplementor) bootstrapServiceRegistry; this.parent = (ServiceRegistryImplementor) bootstrapServiceRegistry;
@ -110,9 +108,8 @@ public abstract class AbstractServiceRegistryImpl
this.parent.registerChild( this ); this.parent.registerChild( this );
} }
@SuppressWarnings({ "unchecked" })
protected <R extends Service> void createServiceBinding(ServiceInitiator<R> initiator) { protected <R extends Service> void createServiceBinding(ServiceInitiator<R> initiator) {
final ServiceBinding serviceBinding = new ServiceBinding( this, initiator ); final ServiceBinding<?> serviceBinding = new ServiceBinding<>( this, initiator );
serviceBindingMap.put( initiator.getServiceInitiated(), serviceBinding ); serviceBindingMap.put( initiator.getServiceInitiated(), serviceBinding );
} }
@ -125,25 +122,23 @@ public abstract class AbstractServiceRegistryImpl
registerService( binding, providedService.getService() ); registerService( binding, providedService.getService() );
} }
protected void visitServiceBindings(Consumer<ServiceBinding> action) { protected void visitServiceBindings(Consumer<ServiceBinding<?>> action) {
serviceBindingList.forEach( action ); serviceBindingList.forEach( action );
} }
@Override @Override
@SuppressWarnings( {"unchecked"})
public ServiceRegistry getParentServiceRegistry() { public ServiceRegistry getParentServiceRegistry() {
return parent; return parent;
} }
@Override @Override
@SuppressWarnings({ "unchecked" })
public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole) { public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole) {
return locateServiceBinding( serviceRole, true ); return locateServiceBinding( serviceRole, true );
} }
@SuppressWarnings({ "unchecked" }) @SuppressWarnings("unchecked")
protected <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole, boolean checkParent) { protected <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole, boolean checkParent) {
ServiceBinding<R> serviceBinding = serviceBindingMap.get( serviceRole ); ServiceBinding<R> serviceBinding = (ServiceBinding<R>) serviceBindingMap.get( serviceRole );
if ( serviceBinding == null && checkParent && parent != null ) { if ( serviceBinding == null && checkParent && parent != null ) {
// look in parent // look in parent
serviceBinding = parent.locateServiceBinding( serviceRole ); serviceBinding = parent.locateServiceBinding( serviceRole );
@ -158,32 +153,32 @@ public abstract class AbstractServiceRegistryImpl
} }
// look for a previously resolved alternate registration // look for a previously resolved alternate registration
final Class alternative = roleXref.get( serviceRole ); final Class<?> alternative = roleXref.get( serviceRole );
if ( alternative != null ) { if ( alternative != null ) {
return serviceBindingMap.get( alternative ); return (ServiceBinding<R>) serviceBindingMap.get( alternative );
} }
// perform a crawl looking for an alternate registration // perform a crawl looking for an alternate registration
for ( ServiceBinding binding : serviceBindingMap.values() ) { for ( ServiceBinding<?> binding : serviceBindingMap.values() ) {
if ( serviceRole.isAssignableFrom( binding.getServiceRole() ) ) { if ( serviceRole.isAssignableFrom( binding.getServiceRole() ) ) {
// we found an alternate... // we found an alternate...
log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() ); log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() );
registerAlternate( serviceRole, binding.getServiceRole() ); registerAlternate( serviceRole, binding.getServiceRole() );
return binding; return (ServiceBinding<R>) binding;
} }
if ( binding.getService() != null && serviceRole.isInstance( binding.getService() ) ) { if ( binding.getService() != null && serviceRole.isInstance( binding.getService() ) ) {
// we found an alternate... // we found an alternate...
log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() ); log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() );
registerAlternate( serviceRole, binding.getServiceRole() ); registerAlternate( serviceRole, binding.getServiceRole() );
return binding; return (ServiceBinding<R>) binding;
} }
} }
return null; return null;
} }
private void registerAlternate(Class alternate, Class target) { private void registerAlternate(Class<?> alternate, Class<?> target) {
roleXref.put( alternate, target ); roleXref.put( alternate, target );
} }
@ -249,7 +244,6 @@ public abstract class AbstractServiceRegistryImpl
return service; return service;
} }
@SuppressWarnings( {"unchecked"})
protected <R extends Service> R createService(ServiceBinding<R> serviceBinding) { protected <R extends Service> R createService(ServiceBinding<R> serviceBinding) {
final ServiceInitiator<R> serviceInitiator = serviceBinding.getServiceInitiator(); final ServiceInitiator<R> serviceInitiator = serviceBinding.getServiceInitiator();
if ( serviceInitiator == null ) { if ( serviceInitiator == null ) {
@ -280,7 +274,7 @@ public abstract class AbstractServiceRegistryImpl
applyInjections( service ); applyInjections( service );
if ( ServiceRegistryAwareService.class.isInstance( service ) ) { if ( service instanceof ServiceRegistryAwareService ) {
( (ServiceRegistryAwareService) service ).injectServices( this ); ( (ServiceRegistryAwareService) service ).injectServices( this );
} }
} }
@ -301,15 +295,15 @@ public abstract class AbstractServiceRegistryImpl
} }
} }
@SuppressWarnings({ "unchecked" })
private <T extends Service> void processInjection(T service, Method injectionMethod, InjectService injectService) { private <T extends Service> void processInjection(T service, Method injectionMethod, InjectService injectService) {
final Class<?>[] parameterTypes = injectionMethod.getParameterTypes(); final Class<?>[] parameterTypes = injectionMethod.getParameterTypes();
if ( parameterTypes == null || injectionMethod.getParameterCount() != 1 ) { if ( injectionMethod.getParameterCount() != 1 ) {
throw new ServiceDependencyException( throw new ServiceDependencyException(
"Encountered @InjectService on method with unexpected number of parameters" "Encountered @InjectService on method with unexpected number of parameters"
); );
} }
//noinspection rawtypes
Class dependentServiceRole = injectService.serviceRole(); Class dependentServiceRole = injectService.serviceRole();
if ( dependentServiceRole == null || dependentServiceRole.equals( Void.class ) ) { if ( dependentServiceRole == null || dependentServiceRole.equals( Void.class ) ) {
dependentServiceRole = parameterTypes[0]; dependentServiceRole = parameterTypes[0];
@ -317,6 +311,7 @@ public abstract class AbstractServiceRegistryImpl
// todo : because of the use of proxies, this is no longer returning null here... // todo : because of the use of proxies, this is no longer returning null here...
//noinspection unchecked
final Service dependantService = getService( dependentServiceRole ); final Service dependantService = getService( dependentServiceRole );
if ( dependantService == null ) { if ( dependantService == null ) {
if ( injectService.required() ) { if ( injectService.required() ) {
@ -336,9 +331,8 @@ public abstract class AbstractServiceRegistryImpl
} }
@Override @Override
@SuppressWarnings({ "unchecked" })
public <R extends Service> void startService(ServiceBinding<R> serviceBinding) { public <R extends Service> void startService(ServiceBinding<R> serviceBinding) {
if ( Startable.class.isInstance( serviceBinding.getService() ) ) { if ( serviceBinding.getService() instanceof Startable ) {
( (Startable) serviceBinding.getService() ).start(); ( (Startable) serviceBinding.getService() ).start();
} }
} }
@ -348,7 +342,6 @@ public abstract class AbstractServiceRegistryImpl
} }
@Override @Override
@SuppressWarnings( {"unchecked"})
public synchronized void destroy() { public synchronized void destroy() {
if ( active.compareAndSet( true, false ) ) { if ( active.compareAndSet( true, false ) ) {
try { try {
@ -356,11 +349,11 @@ public abstract class AbstractServiceRegistryImpl
//threads not owning the synchronization lock can't get an invalid Service: //threads not owning the synchronization lock can't get an invalid Service:
initializedServiceByRole.clear(); initializedServiceByRole.clear();
synchronized (serviceBindingList) { synchronized (serviceBindingList) {
ListIterator<ServiceBinding> serviceBindingsIterator = serviceBindingList.listIterator( ListIterator<ServiceBinding<?>> serviceBindingsIterator = serviceBindingList.listIterator(
serviceBindingList.size() serviceBindingList.size()
); );
while ( serviceBindingsIterator.hasPrevious() ) { while ( serviceBindingsIterator.hasPrevious() ) {
final ServiceBinding serviceBinding = serviceBindingsIterator.previous(); final ServiceBinding<?> serviceBinding = serviceBindingsIterator.previous();
serviceBinding.getLifecycleOwner().stopService( serviceBinding ); serviceBinding.getLifecycleOwner().stopService( serviceBinding );
} }
serviceBindingList.clear(); serviceBindingList.clear();
@ -376,7 +369,7 @@ public abstract class AbstractServiceRegistryImpl
@Override @Override
public synchronized <R extends Service> void stopService(ServiceBinding<R> binding) { public synchronized <R extends Service> void stopService(ServiceBinding<R> binding) {
final Service service = binding.getService(); final Service service = binding.getService();
if ( Stoppable.class.isInstance( service ) ) { if ( service instanceof Stoppable ) {
try { try {
( (Stoppable) service ).stop(); ( (Stoppable) service ).stop();
} }
@ -430,7 +423,7 @@ public abstract class AbstractServiceRegistryImpl
this.parent.deRegisterChild( this ); this.parent.deRegisterChild( this );
} }
if ( newParent != null ) { if ( newParent != null ) {
if ( ! ServiceRegistryImplementor.class.isInstance( newParent ) ) { if ( !(newParent instanceof ServiceRegistryImplementor) ) {
throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" ); throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" );
} }
this.parent = (ServiceRegistryImplementor) newParent; this.parent = (ServiceRegistryImplementor) newParent;
@ -442,10 +435,7 @@ public abstract class AbstractServiceRegistryImpl
} }
public synchronized void reactivate() { public synchronized void reactivate() {
if ( active.compareAndSet( false, true ) ) { if ( !active.compareAndSet(false, true) ) {
//ok
}
else {
throw new IllegalStateException( "Was not inactive, could not reactivate!" ); throw new IllegalStateException( "Was not inactive, could not reactivate!" );
} }
} }

View File

@ -23,8 +23,8 @@ import org.hibernate.service.spi.SessionFactoryServiceRegistryBuilder;
public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryServiceRegistryBuilder { public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryServiceRegistryBuilder {
private final ServiceRegistryImplementor parent; private final ServiceRegistryImplementor parent;
private final List<SessionFactoryServiceInitiator> initiators = StandardSessionFactoryServiceInitiators.buildStandardServiceInitiatorList(); private final List<SessionFactoryServiceInitiator<?>> initiators = StandardSessionFactoryServiceInitiators.buildStandardServiceInitiatorList();
private final List<ProvidedService> providedServices = new ArrayList<>(); private final List<ProvidedService<?>> providedServices = new ArrayList<>();
public SessionFactoryServiceRegistryBuilderImpl(ServiceRegistryImplementor parent) { public SessionFactoryServiceRegistryBuilderImpl(ServiceRegistryImplementor parent) {
this.parent = parent; this.parent = parent;
@ -38,8 +38,7 @@ public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryS
* @return this, for method chaining * @return this, for method chaining
*/ */
@Override @Override
@SuppressWarnings( {"UnusedDeclaration"}) public SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator<?> initiator) {
public SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator initiator) {
initiators.add( initiator ); initiators.add( initiator );
return this; return this;
} }
@ -53,9 +52,8 @@ public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryS
* @return this, for method chaining * @return this, for method chaining
*/ */
@Override @Override
@SuppressWarnings( {"unchecked"}) public <R extends Service> SessionFactoryServiceRegistryBuilder addService(final Class<R> serviceRole, final R service) {
public SessionFactoryServiceRegistryBuilder addService(final Class serviceRole, final Service service) { providedServices.add( new ProvidedService<>( serviceRole, service ) );
providedServices.add( new ProvidedService( serviceRole, service ) );
return this; return this;
} }

View File

@ -24,7 +24,7 @@ public class SessionFactoryServiceRegistryFactoryInitiator implements StandardSe
} }
@Override @Override
public SessionFactoryServiceRegistryFactoryImpl initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public SessionFactoryServiceRegistryFactoryImpl initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new SessionFactoryServiceRegistryFactoryImpl( registry ); return new SessionFactoryServiceRegistryFactoryImpl( registry );
} }
} }

View File

@ -35,11 +35,10 @@ public class SessionFactoryServiceRegistryImpl
private final SessionFactoryOptions sessionFactoryOptions; private final SessionFactoryOptions sessionFactoryOptions;
private final SessionFactoryImplementor sessionFactory; private final SessionFactoryImplementor sessionFactory;
@SuppressWarnings({"unchecked", "rawtypes"})
public SessionFactoryServiceRegistryImpl( public SessionFactoryServiceRegistryImpl(
ServiceRegistryImplementor parent, ServiceRegistryImplementor parent,
List<SessionFactoryServiceInitiator> initiators, List<SessionFactoryServiceInitiator<?>> initiators,
List<ProvidedService> providedServices, List<ProvidedService<?>> providedServices,
SessionFactoryImplementor sessionFactory, SessionFactoryImplementor sessionFactory,
SessionFactoryOptions sessionFactoryOptions) { SessionFactoryOptions sessionFactoryOptions) {
super( parent ); super( parent );
@ -48,7 +47,7 @@ public class SessionFactoryServiceRegistryImpl
this.sessionFactoryOptions = sessionFactoryOptions; this.sessionFactoryOptions = sessionFactoryOptions;
// for now, just use the standard initiator list // for now, just use the standard initiator list
for ( SessionFactoryServiceInitiator initiator : initiators ) { for ( SessionFactoryServiceInitiator<?> initiator : initiators ) {
// create the bindings up front to help identify to which registry services belong // create the bindings up front to help identify to which registry services belong
createServiceBinding( initiator ); createServiceBinding( initiator );
} }

View File

@ -22,8 +22,8 @@ import org.hibernate.stat.internal.StatisticsInitiator;
*/ */
public final class StandardSessionFactoryServiceInitiators { public final class StandardSessionFactoryServiceInitiators {
public static List<SessionFactoryServiceInitiator> buildStandardServiceInitiatorList() { public static List<SessionFactoryServiceInitiator<?>> buildStandardServiceInitiatorList() {
final ArrayList<SessionFactoryServiceInitiator> serviceInitiators = new ArrayList<>(); final ArrayList<SessionFactoryServiceInitiator<?>> serviceInitiators = new ArrayList<>();
serviceInitiators.add( StatisticsInitiator.INSTANCE ); serviceInitiators.add( StatisticsInitiator.INSTANCE );
serviceInitiators.add( CacheInitiator.INSTANCE ); serviceInitiators.add( CacheInitiator.INSTANCE );

View File

@ -18,5 +18,5 @@ public interface Configurable {
* *
* @param configurationValues The configuration properties. * @param configurationValues The configuration properties.
*/ */
void configure(Map configurationValues); void configure(Map<String, Object> configurationValues);
} }

View File

@ -12,8 +12,7 @@ import org.hibernate.service.Service;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface SessionFactoryServiceRegistryBuilder { public interface SessionFactoryServiceRegistryBuilder {
SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator initiator); SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator<?> initiator);
@SuppressWarnings( {"unchecked"}) <R extends Service> SessionFactoryServiceRegistryBuilder addService(Class<R> serviceRole, R service);
SessionFactoryServiceRegistryBuilder addService(Class serviceRole, Service service);
} }

View File

@ -21,7 +21,7 @@ public interface Wrapped {
* *
* @return True/false. * @return True/false.
*/ */
boolean isUnwrappableAs(Class unwrapType); boolean isUnwrappableAs(Class<?> unwrapType);
/** /**
* Unproxy the service proxy * Unproxy the service proxy

View File

@ -125,7 +125,7 @@ public class Helper {
} }
} }
public static boolean interpretNamespaceHandling(Map configurationValues) { public static boolean interpretNamespaceHandling(Map<String,Object> configurationValues) {
//Print a warning if multiple conflicting properties are being set: //Print a warning if multiple conflicting properties are being set:
int count = 0; int count = 0;
if ( configurationValues.containsKey( AvailableSettings.HBM2DDL_CREATE_SCHEMAS ) ) { if ( configurationValues.containsKey( AvailableSettings.HBM2DDL_CREATE_SCHEMAS ) ) {
@ -158,7 +158,7 @@ public class Helper {
); );
} }
public static boolean interpretFormattingEnabled(Map configurationValues) { public static boolean interpretFormattingEnabled(Map<String,Object> configurationValues) {
return ConfigurationHelper.getBoolean( return ConfigurationHelper.getBoolean(
AvailableSettings.FORMAT_SQL, AvailableSettings.FORMAT_SQL,
configurationValues, configurationValues,

View File

@ -9,7 +9,6 @@ package org.hibernate.tool.schema.internal;
import java.sql.Connection; import java.sql.Connection;
import java.util.Map; import java.util.Map;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
@ -83,17 +82,17 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
} }
@Override @Override
public SchemaCreator getSchemaCreator(Map options) { public SchemaCreator getSchemaCreator(Map<String,Object> options) {
return new SchemaCreatorImpl( this, getSchemaFilterProvider( options ).getCreateFilter() ); return new SchemaCreatorImpl( this, getSchemaFilterProvider( options ).getCreateFilter() );
} }
@Override @Override
public SchemaDropper getSchemaDropper(Map options) { public SchemaDropper getSchemaDropper(Map<String,Object> options) {
return new SchemaDropperImpl( this, getSchemaFilterProvider( options ).getDropFilter() ); return new SchemaDropperImpl( this, getSchemaFilterProvider( options ).getDropFilter() );
} }
@Override @Override
public SchemaMigrator getSchemaMigrator(Map options) { public SchemaMigrator getSchemaMigrator(Map<String,Object> options) {
if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) { if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) {
return new GroupedSchemaMigratorImpl( this, getSchemaFilterProvider( options ).getMigrateFilter() ); return new GroupedSchemaMigratorImpl( this, getSchemaFilterProvider( options ).getMigrateFilter() );
} }
@ -103,7 +102,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
} }
@Override @Override
public SchemaValidator getSchemaValidator(Map options) { public SchemaValidator getSchemaValidator(Map<String,Object> options) {
if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) { if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) {
return new GroupedSchemaValidatorImpl( this, getSchemaFilterProvider( options ).getValidateFilter() ); return new GroupedSchemaValidatorImpl( this, getSchemaFilterProvider( options ).getValidateFilter() );
} }
@ -112,7 +111,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
} }
} }
private SchemaFilterProvider getSchemaFilterProvider(Map options) { private SchemaFilterProvider getSchemaFilterProvider(Map<String,Object> options) {
final Object configuredOption = (options == null) final Object configuredOption = (options == null)
? null ? null
: options.get( AvailableSettings.HBM2DDL_FILTER_PROVIDER ); : options.get( AvailableSettings.HBM2DDL_FILTER_PROVIDER );
@ -123,7 +122,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
); );
} }
private JdbcMetadaAccessStrategy determineJdbcMetadaAccessStrategy(Map options) { private JdbcMetadaAccessStrategy determineJdbcMetadaAccessStrategy(Map<String,Object> options) {
return JdbcMetadaAccessStrategy.interpretSetting( options ); return JdbcMetadaAccessStrategy.interpretSetting( options );
} }
@ -144,7 +143,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
GenerationTarget[] buildGenerationTargets( GenerationTarget[] buildGenerationTargets(
TargetDescriptor targetDescriptor, TargetDescriptor targetDescriptor,
JdbcContext jdbcContext, JdbcContext jdbcContext,
Map options, Map<String,Object> options,
boolean needsAutoCommit) { boolean needsAutoCommit) {
final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" ); final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" );
@ -178,7 +177,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
GenerationTarget[] buildGenerationTargets( GenerationTarget[] buildGenerationTargets(
TargetDescriptor targetDescriptor, TargetDescriptor targetDescriptor,
DdlTransactionIsolator ddlTransactionIsolator, DdlTransactionIsolator ddlTransactionIsolator,
Map options) { Map<String,Object> options) {
final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" ); final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" );
final GenerationTarget[] targets = new GenerationTarget[ targetDescriptor.getTargetTypes().size() ]; final GenerationTarget[] targets = new GenerationTarget[ targetDescriptor.getTargetTypes().size() ];
@ -215,7 +214,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
return serviceRegistry.getService( TransactionCoordinatorBuilder.class ).buildDdlTransactionIsolator( jdbcContext ); return serviceRegistry.getService( TransactionCoordinatorBuilder.class ).buildDdlTransactionIsolator( jdbcContext );
} }
public JdbcContext resolveJdbcContext(Map configurationValues) { public JdbcContext resolveJdbcContext(Map<String,Object> configurationValues) {
final JdbcContextBuilder jdbcContextBuilder = new JdbcContextBuilder( serviceRegistry ); final JdbcContextBuilder jdbcContextBuilder = new JdbcContextBuilder( serviceRegistry );
// see if a specific connection has been provided // see if a specific connection has been provided

View File

@ -97,7 +97,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
public SchemaCreatorImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) { public SchemaCreatorImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) {
SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class ); SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class );
if ( !HibernateSchemaManagementTool.class.isInstance( smt ) ) { if ( !(smt instanceof HibernateSchemaManagementTool) ) {
smt = new HibernateSchemaManagementTool(); smt = new HibernateSchemaManagementTool();
( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); ( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry );
} }
@ -382,9 +382,9 @@ public class SchemaCreatorImpl implements SchemaCreator {
} }
// indexes // indexes
final Iterator indexItr = table.getIndexIterator(); final Iterator<Index> indexItr = table.getIndexIterator();
while ( indexItr.hasNext() ) { while ( indexItr.hasNext() ) {
final Index index = (Index) indexItr.next(); final Index index = indexItr.next();
checkExportIdentifier( index, exportIdentifiers ); checkExportIdentifier( index, exportIdentifiers );
applySqlStrings( applySqlStrings(
dialect.getIndexExporter().getSqlCreateStrings( index, metadata, dialect.getIndexExporter().getSqlCreateStrings( index, metadata,
@ -397,9 +397,9 @@ public class SchemaCreatorImpl implements SchemaCreator {
} }
// unique keys // unique keys
final Iterator ukItr = table.getUniqueKeyIterator(); final Iterator<UniqueKey> ukItr = table.getUniqueKeyIterator();
while ( ukItr.hasNext() ) { while ( ukItr.hasNext() ) {
final UniqueKey uniqueKey = (UniqueKey) ukItr.next(); final UniqueKey uniqueKey = ukItr.next();
checkExportIdentifier( uniqueKey, exportIdentifiers ); checkExportIdentifier( uniqueKey, exportIdentifiers );
applySqlStrings( applySqlStrings(
dialect.getUniqueKeyExporter().getSqlCreateStrings( uniqueKey, metadata, dialect.getUniqueKeyExporter().getSqlCreateStrings( uniqueKey, metadata,
@ -431,9 +431,9 @@ public class SchemaCreatorImpl implements SchemaCreator {
} }
// foreign keys // foreign keys
final Iterator fkItr = table.getForeignKeyIterator(); final Iterator<ForeignKey> fkItr = table.getForeignKeyIterator();
while ( fkItr.hasNext() ) { while ( fkItr.hasNext() ) {
final ForeignKey foreignKey = (ForeignKey) fkItr.next(); final ForeignKey foreignKey = fkItr.next();
applySqlStrings( applySqlStrings(
dialect.getForeignKeyExporter().getSqlCreateStrings( foreignKey, metadata, dialect.getForeignKeyExporter().getSqlCreateStrings( foreignKey, metadata,
sqlStringGenerationContext sqlStringGenerationContext
@ -549,7 +549,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
for ( String currentFile : importFiles.split( "," ) ) { for ( String currentFile : importFiles.split( "," ) ) {
final String resourceName = currentFile.trim(); final String resourceName = currentFile.trim();
if ( resourceName != null && resourceName.isEmpty() ) { if ( resourceName.isEmpty() ) {
//skip empty resource names //skip empty resource names
continue; continue;
} }
@ -602,7 +602,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
} }
@Override @Override
public Map getConfigurationValues() { public Map<String,Object> getConfigurationValues() {
return Collections.emptyMap(); return Collections.emptyMap();
} }
@ -647,7 +647,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
public void doCreation( public void doCreation(
Metadata metadata, Metadata metadata,
final ServiceRegistry serviceRegistry, final ServiceRegistry serviceRegistry,
final Map settings, final Map<String,Object> settings,
final boolean manageNamespaces, final boolean manageNamespaces,
GenerationTarget... targets) { GenerationTarget... targets) {
doCreation( doCreation(
@ -660,7 +660,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
} }
@Override @Override
public Map getConfigurationValues() { public Map<String,Object> getConfigurationValues() {
return settings; return settings;
} }

View File

@ -91,7 +91,7 @@ public class SchemaDropperImpl implements SchemaDropper {
public SchemaDropperImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) { public SchemaDropperImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) {
SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class ); SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class );
if ( !HibernateSchemaManagementTool.class.isInstance( smt ) ) { if ( !(smt instanceof HibernateSchemaManagementTool) ) {
smt = new HibernateSchemaManagementTool(); smt = new HibernateSchemaManagementTool();
( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); ( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry );
} }
@ -370,9 +370,9 @@ public class SchemaDropperImpl implements SchemaDropper {
continue; continue;
} }
final Iterator fks = table.getForeignKeyIterator(); final Iterator<ForeignKey> fks = table.getForeignKeyIterator();
while ( fks.hasNext() ) { while ( fks.hasNext() ) {
final ForeignKey foreignKey = (ForeignKey) fks.next(); final ForeignKey foreignKey = fks.next();
applySqlStrings( applySqlStrings(
dialect.getForeignKeyExporter().getSqlDropStrings( foreignKey, metadata, dialect.getForeignKeyExporter().getSqlDropStrings( foreignKey, metadata,
sqlStringGenerationContext sqlStringGenerationContext
@ -448,7 +448,7 @@ public class SchemaDropperImpl implements SchemaDropper {
} }
@Override @Override
public Map getConfigurationValues() { public Map<String,Object> getConfigurationValues() {
return Collections.emptyMap(); return Collections.emptyMap();
} }
@ -502,7 +502,7 @@ public class SchemaDropperImpl implements SchemaDropper {
public void doDrop( public void doDrop(
Metadata metadata, Metadata metadata,
final ServiceRegistry serviceRegistry, final ServiceRegistry serviceRegistry,
final Map settings, final Map<String,Object> settings,
final boolean manageNamespaces, final boolean manageNamespaces,
GenerationTarget... targets) { GenerationTarget... targets) {
if ( targets == null || targets.length == 0 ) { if ( targets == null || targets.length == 0 ) {
@ -524,7 +524,7 @@ public class SchemaDropperImpl implements SchemaDropper {
} }
@Override @Override
public Map getConfigurationValues() { public Map<String,Object> getConfigurationValues() {
return settings; return settings;
} }

View File

@ -20,7 +20,7 @@ import org.hibernate.tool.schema.spi.SchemaManagementTool;
public class SchemaManagementToolInitiator implements StandardServiceInitiator<SchemaManagementTool> { public class SchemaManagementToolInitiator implements StandardServiceInitiator<SchemaManagementTool> {
public static final SchemaManagementToolInitiator INSTANCE = new SchemaManagementToolInitiator(); public static final SchemaManagementToolInitiator INSTANCE = new SchemaManagementToolInitiator();
public SchemaManagementTool initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public SchemaManagementTool initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final Object setting = configurationValues.get( AvailableSettings.SCHEMA_MANAGEMENT_TOOL ); final Object setting = configurationValues.get( AvailableSettings.SCHEMA_MANAGEMENT_TOOL );
SchemaManagementTool tool = registry.getService( StrategySelector.class ).resolveStrategy( SchemaManagementTool.class, setting ); SchemaManagementTool tool = registry.getService( StrategySelector.class ).resolveStrategy( SchemaManagementTool.class, setting );
if ( tool == null ) { if ( tool == null ) {

View File

@ -27,7 +27,7 @@ public class SqlScriptExtractorInitiator implements StandardServiceInitiator<Sql
} }
@Override @Override
public SqlScriptCommandExtractor initiateService(Map configurationValues, ServiceRegistryImplementor registry) { public SqlScriptCommandExtractor initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final Object explicitSettingValue = configurationValues.get( Environment.HBM2DDL_IMPORT_FILES_SQL_EXTRACTOR ); final Object explicitSettingValue = configurationValues.get( Environment.HBM2DDL_IMPORT_FILES_SQL_EXTRACTOR );
if ( explicitSettingValue == null ) { if ( explicitSettingValue == null ) {

View File

@ -18,7 +18,7 @@ import org.hibernate.boot.model.relational.Exportable;
*/ */
@Incubating @Incubating
public interface ExecutionOptions { public interface ExecutionOptions {
Map getConfigurationValues(); Map<String,Object> getConfigurationValues();
boolean shouldManageNamespaces(); boolean shouldManageNamespaces();

View File

@ -19,10 +19,10 @@ import org.hibernate.tool.schema.internal.exec.GenerationTarget;
*/ */
@Incubating @Incubating
public interface SchemaManagementTool extends Service { public interface SchemaManagementTool extends Service {
SchemaCreator getSchemaCreator(Map options); SchemaCreator getSchemaCreator(Map<String,Object> options);
SchemaDropper getSchemaDropper(Map options); SchemaDropper getSchemaDropper(Map<String,Object> options);
SchemaMigrator getSchemaMigrator(Map options); SchemaMigrator getSchemaMigrator(Map<String,Object> options);
SchemaValidator getSchemaValidator(Map options); SchemaValidator getSchemaValidator(Map<String,Object> options);
/** /**
* This allows to set an alternative implementation for the Database * This allows to set an alternative implementation for the Database

View File

@ -63,7 +63,7 @@ public class SchemaManagementToolCoordinator {
public static void process( public static void process(
final Metadata metadata, final Metadata metadata,
final ServiceRegistry serviceRegistry, final ServiceRegistry serviceRegistry,
final Map<?,?> configurationValues, final Map<String,Object> configurationValues,
DelayedDropRegistry delayedDropRegistry) { DelayedDropRegistry delayedDropRegistry) {
final Set<ActionGrouping> groupings = ActionGrouping.interpret( metadata, configurationValues ); final Set<ActionGrouping> groupings = ActionGrouping.interpret( metadata, configurationValues );
@ -169,7 +169,7 @@ public class SchemaManagementToolCoordinator {
} }
public static ExecutionOptions buildExecutionOptions( public static ExecutionOptions buildExecutionOptions(
final Map<?,?> configurationValues, final Map<String,Object> configurationValues,
final ExceptionHandler exceptionHandler) { final ExceptionHandler exceptionHandler) {
return buildExecutionOptions( return buildExecutionOptions(
configurationValues, configurationValues,
@ -179,7 +179,7 @@ public class SchemaManagementToolCoordinator {
} }
public static ExecutionOptions buildExecutionOptions( public static ExecutionOptions buildExecutionOptions(
final Map<?,?> configurationValues, final Map<String,Object> configurationValues,
final SchemaFilter schemaFilter, final SchemaFilter schemaFilter,
final ExceptionHandler exceptionHandler) { final ExceptionHandler exceptionHandler) {
return new ExecutionOptions() { return new ExecutionOptions() {
@ -189,7 +189,7 @@ public class SchemaManagementToolCoordinator {
} }
@Override @Override
public Map<?,?> getConfigurationValues() { public Map<String,Object> getConfigurationValues() {
return configurationValues; return configurationValues;
} }

View File

@ -7,6 +7,7 @@
//$Id$ //$Id$
package org.hibernate.orm.test.annotations; package org.hibernate.orm.test.annotations;
import org.junit.Test; import org.junit.Test;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
@ -23,7 +24,7 @@ import static org.junit.Assert.fail;
*/ */
public class SafeMappingTest { public class SafeMappingTest {
@Test @Test
public void testDeclarativeMix() throws Exception { public void testDeclarativeMix() {
Configuration cfg = new Configuration(); Configuration cfg = new Configuration();
cfg.addAnnotatedClass( IncorrectEntity.class ); cfg.addAnnotatedClass( IncorrectEntity.class );
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );

View File

@ -27,7 +27,7 @@ public class SecuredBindingTest {
@Test @Test
public void testConfigurationMethods() throws Exception { public void testConfigurationMethods() {
Configuration ac = new Configuration(); Configuration ac = new Configuration();
Properties p = new Properties(); Properties p = new Properties();
p.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" ); p.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" );

View File

@ -50,7 +50,7 @@ public class BeanValidationDisabledTest extends BaseNonConfigCoreFunctionalTestC
} }
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
settings.put( "javax.persistence.validation.mode", "none" ); settings.put( "javax.persistence.validation.mode", "none" );
} }

View File

@ -83,7 +83,7 @@ public class DDLTest extends BaseNonConfigCoreFunctionalTestCase {
} }
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
settings.put( "javax.persistence.validation.mode", "ddl" ); settings.put( "javax.persistence.validation.mode", "ddl" );
} }

View File

@ -33,7 +33,7 @@ import static org.junit.Assert.fail;
public class DDLWithoutCallbackTest extends BaseNonConfigCoreFunctionalTestCase { public class DDLWithoutCallbackTest extends BaseNonConfigCoreFunctionalTestCase {
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
settings.put( "javax.persistence.validation.mode", "ddl" ); settings.put( "javax.persistence.validation.mode", "ddl" );
} }

View File

@ -24,7 +24,7 @@ import org.junit.Test;
*/ */
public class DuplicateTest { public class DuplicateTest {
@Test @Test
public void testDuplicateEntityName() throws Exception { public void testDuplicateEntityName() {
Configuration cfg = new Configuration(); Configuration cfg = new Configuration();
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
ServiceRegistry serviceRegistry = null; ServiceRegistry serviceRegistry = null;

View File

@ -41,7 +41,7 @@ public class ImmutableEntityUpdateQueryHandlingModeExceptionTest extends BaseNon
} }
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
settings.put( AvailableSettings.IMMUTABLE_ENTITY_UPDATE_QUERY_HANDLING_MODE, "exception" ); settings.put( AvailableSettings.IMMUTABLE_ENTITY_UPDATE_QUERY_HANDLING_MODE, "exception" );
} }

View File

@ -21,6 +21,7 @@ import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources; import org.hibernate.boot.MetadataSources;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.mapping.UniqueKey; import org.hibernate.mapping.UniqueKey;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
@ -44,7 +45,7 @@ public abstract class AbstractCharsetNamingStrategyTest extends BaseUnitTestCase
@Before @Before
public void setUp() { public void setUp() {
Map<Object, Object> properties = new HashMap<>( Environment.getProperties() ); Map<String, Object> properties = PropertiesHelper.map( Environment.getProperties() );
properties.put( AvailableSettings.HBM2DDL_CHARSET_NAME, charsetName() ); properties.put( AvailableSettings.HBM2DDL_CHARSET_NAME, charsetName() );
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( properties ); serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( properties );
} }

View File

@ -574,7 +574,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
} }
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
super.addSettings( settings ); super.addSettings( settings );
// needed for `#testListWithBagSemanticAndOrderBy` // needed for `#testListWithBagSemanticAndOrderBy`
settings.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() ); settings.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );

View File

@ -43,7 +43,7 @@ public class BatchOptimisticLockingTest extends
} }
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
settings.put( AvailableSettings.STATEMENT_BATCH_SIZE, String.valueOf( 2 ) ); settings.put( AvailableSettings.STATEMENT_BATCH_SIZE, String.valueOf( 2 ) );
} }

View File

@ -105,7 +105,7 @@ public class OptionalSecondaryTableBatchTest extends BaseNonConfigCoreFunctional
} }
@Override @Override
protected void addSettings(Map settings) { protected void addSettings(Map<String,Object> settings) {
super.addSettings( settings ); super.addSettings( settings );
settings.put( AvailableSettings.STATEMENT_BATCH_SIZE, 5 ); settings.put( AvailableSettings.STATEMENT_BATCH_SIZE, 5 );
} }

Some files were not shown because too many files have changed in this diff Show More