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.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
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.Stoppable;
import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool;
@ -88,7 +89,7 @@ public abstract class AbstractMultiTenancyTest extends BaseUnitTestCase {
DriverManagerConnectionProviderImpl connectionProvider =
new DriverManagerConnectionProviderImpl();
connectionProvider.configure(properties);
connectionProvider.configure( PropertiesHelper.map(properties) );
connectionProviderMap.put(tenantIdentifier, connectionProvider);
}
//end::multitenacy-hibernate-MultiTenantConnectionProvider-example[]

View File

@ -34,6 +34,7 @@ import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
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.Stoppable;
import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool;
@ -101,12 +102,12 @@ public class DatabaseTimeZoneMultiTenancyTest extends BaseUnitTestCase {
Properties properties = properties();
properties.put(
Environment.URL,
tenantUrl(properties.getProperty(Environment.URL), tenantIdentifier)
tenantUrl( properties.getProperty(Environment.URL), tenantIdentifier )
);
DriverManagerConnectionProviderImpl connectionProvider =
new DriverManagerConnectionProviderImpl();
connectionProvider.configure(properties);
connectionProvider.configure( PropertiesHelper.map(properties) );
connectionProviderMap.put(tenantIdentifier, connectionProvider);

View File

@ -58,7 +58,7 @@ public class AgroalConnectionProvider implements ConnectionProvider, Configurabl
// --- 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 );
if ( isolation != null ) {
// 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) {
String value = properties.get( key );
if ( value != null ) {
consumer.accept( converter.apply( value ) );
private static <T> void copyProperty(Map<String, Object> properties, String key, Consumer<T> consumer, Function<String, T> converter) {
Object value = properties.get( key );
if ( value instanceof String ) {
consumer.accept( converter.apply( (String) value ) );
}
}
@Override
@SuppressWarnings( "unchecked" )
public void configure(Map props) throws HibernateException {
public void configure(Map<String, Object> props) throws HibernateException {
LOGGER.debug( "Configuring Agroal" );
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 -> {
copyProperty( props, AvailableSettings.DRIVER, cf::connectionProviderClassName, Function.identity() );
copyProperty( props, AvailableSettings.URL, cf::jdbcUrl, Function.identity() );
@ -119,15 +119,17 @@ public class AgroalConnectionProvider implements ConnectionProvider, Configurabl
}
@Override
@SuppressWarnings( "rawtypes" )
public boolean isUnwrappableAs(Class unwrapType) {
return ConnectionProvider.class.equals( unwrapType ) || AgroalConnectionProvider.class.isAssignableFrom( unwrapType ) || DataSource.class.isAssignableFrom( unwrapType );
public boolean isUnwrappableAs(Class<?> unwrapType) {
return ConnectionProvider.class.equals( unwrapType )
|| AgroalConnectionProvider.class.isAssignableFrom( unwrapType )
|| DataSource.class.isAssignableFrom( unwrapType );
}
@Override
@SuppressWarnings( "unchecked" )
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;
}
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.engine.jdbc.connections.internal.ConnectionProviderInitiator;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.UnknownUnwrapTypeException;
import org.hibernate.service.spi.Configurable;
@ -67,11 +68,10 @@ public class C3P0ConnectionProvider
private ServiceRegistryImplementor serviceRegistry;
@Override
@SuppressWarnings("UnnecessaryUnboxing")
public Connection getConnection() throws SQLException {
final Connection c = ds.getConnection();
if ( isolation != null && !isolation.equals( c.getTransactionIsolation() ) ) {
c.setTransactionIsolation( isolation.intValue() );
if ( isolation != null && isolation != c.getTransactionIsolation() ) {
c.setTransactionIsolation( isolation );
}
if ( c.getAutoCommit() != autocommit ) {
c.setAutoCommit( autocommit );
@ -85,7 +85,7 @@ public class C3P0ConnectionProvider
}
@Override
public boolean isUnwrappableAs(Class unwrapType) {
public boolean isUnwrappableAs(Class<?> unwrapType) {
return ConnectionProvider.class.equals( unwrapType ) ||
C3P0ConnectionProvider.class.isAssignableFrom( unwrapType ) ||
DataSource.class.isAssignableFrom( unwrapType );
@ -107,8 +107,7 @@ public class C3P0ConnectionProvider
}
@Override
@SuppressWarnings({"unchecked"})
public void configure(Map props) {
public void configure(Map<String, Object> props) {
final String jdbcDriverClass = (String) props.get( Environment.DRIVER );
final String jdbcUrl = (String) props.get( Environment.URL );
final Properties connectionProps = ConnectionProviderInitiator.getConnectionProperties( props );
@ -145,11 +144,7 @@ public class C3P0ConnectionProvider
// turn hibernate.c3p0.* into c3p0.*, so c3p0
// gets a chance to see all hibernate.c3p0.*
for ( Object o : props.keySet() ) {
if ( !String.class.isInstance( o ) ) {
continue;
}
final String key = (String) o;
for ( String key : props.keySet() ) {
if ( key.startsWith( "hibernate.c3p0." ) ) {
final String newKey = key.substring( 15 );
if ( props.containsKey( newKey ) ) {
@ -185,9 +180,9 @@ public class C3P0ConnectionProvider
final DataSource unpooled = DataSources.unpooledDataSource( jdbcUrl, connectionProps );
final Map allProps = new HashMap();
final Map<String,Object> allProps = new HashMap<>();
allProps.putAll( props );
allProps.putAll( c3props );
allProps.putAll( PropertiesHelper.map(c3props) );
ds = DataSources.pooledDataSource( unpooled, allProps );
}
@ -208,7 +203,7 @@ public class C3P0ConnectionProvider
private void setOverwriteProperty(
String hibernateStyleKey,
String c3p0StyleKey,
Map hibp,
Map<String,Object> hibp,
Properties c3p,
Integer value) {
if ( value != null ) {

View File

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

View File

@ -46,7 +46,7 @@ public class C3P0DefaultIsolationLevelTest extends
}
@Override
protected void addSettings(Map settings) {
protected void addSettings(Map<String,Object> settings) {
connectionProvider = new C3P0ProxyConnectionProvider();
settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider );
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.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@ -47,7 +46,7 @@ public class C3P0DifferentIsolationLevelTest extends
}
@Override
protected void addSettings(Map settings) {
protected void addSettings(Map<String,Object> settings) {
connectionProvider = new C3P0ProxyConnectionProvider();
settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider );
settings.put( AvailableSettings.ISOLATION, "REPEATABLE_READ" );

View File

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

View File

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

View File

@ -17,7 +17,7 @@ import org.hibernate.boot.cfgxml.spi.LoadedConfig;
public class CfgXmlAccessServiceImpl implements CfgXmlAccessService {
private final LoadedConfig aggregatedCfgXml;
public CfgXmlAccessServiceImpl(Map configurationValues) {
public CfgXmlAccessServiceImpl(Map<?,?> configurationValues) {
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();
@Override
public CfgXmlAccessService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
public CfgXmlAccessService initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new CfgXmlAccessServiceImpl( configurationValues );
}

View File

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

View File

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

View File

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

View File

@ -54,7 +54,6 @@ public class TypeBeanInstanceProducer implements BeanInstanceProducer, TypeBoots
}
@Override
@SuppressWarnings("unchecked")
public Map<String, Object> getConfigurationSettings() {
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.
*/
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.List;
import java.util.Map;
import java.util.Properties;
import org.hibernate.boot.cfgxml.internal.ConfigLoader;
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.integrator.spi.Integrator;
import org.hibernate.integrator.spi.IntegratorService;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry;
@ -47,13 +49,13 @@ public class StandardServiceRegistryBuilder {
public static StandardServiceRegistryBuilder forJpa(BootstrapServiceRegistry bootstrapServiceRegistry) {
final LoadedConfig loadedConfig = new LoadedConfig( null ) {
@Override
protected void addConfigurationValues(Map configurationValues) {
protected void addConfigurationValues(Map<String,Object> configurationValues) {
// here, do nothing
}
};
return new StandardServiceRegistryBuilder(
bootstrapServiceRegistry,
new HashMap(),
new HashMap<>(),
loadedConfig
) {
@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";
private final Map settings;
private final List<StandardServiceInitiator> initiators;
private final List<ProvidedService> providedServices = new ArrayList<>();
private final Map<String,Object> settings;
private final List<StandardServiceInitiator<?>> initiators;
private final List<ProvidedService<?>> providedServices = new ArrayList<>();
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.
*
* @see #forJpa
*/
protected StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry,
Map settings,
Map<String,Object> settings,
LoadedConfig loadedConfig) {
this.bootstrapServiceRegistry = 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.
* Consider this an SPI.
* @deprecated Quarkus will switch to use {@link #StandardServiceRegistryBuilder(BootstrapServiceRegistry, Map, ConfigLoader, LoadedConfig, List)}
@ -122,9 +124,9 @@ public class StandardServiceRegistryBuilder {
@Deprecated
protected StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry,
Map settings,
Map <String,Object> settings,
LoadedConfig loadedConfig,
List<StandardServiceInitiator> initiators) {
List<StandardServiceInitiator<?>> initiators) {
this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
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.
* Consider this an SPI.
*/
protected StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry,
Map settings,
Map<String,Object> settings,
ConfigLoader loader,
LoadedConfig loadedConfig,
List<StandardServiceInitiator> initiators) {
List<StandardServiceInitiator<?>> initiators) {
this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = loader;
this.settings = settings;
@ -158,7 +160,7 @@ public class StandardServiceRegistryBuilder {
public StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry,
LoadedConfig loadedConfigBaseline) {
this.settings = Environment.getProperties();
this.settings = PropertiesHelper.map( Environment.getProperties() );
this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
this.aggregatedCfgXml = loadedConfigBaseline;
@ -181,13 +183,12 @@ public class StandardServiceRegistryBuilder {
*
* @return List of standard initiators
*/
private static List<StandardServiceInitiator> standardInitiatorList() {
final List<StandardServiceInitiator> initiators = new ArrayList<>( StandardServiceInitiators.LIST.size() );
private static List<StandardServiceInitiator<?>> standardInitiatorList() {
final List<StandardServiceInitiator<?>> initiators = new ArrayList<>( StandardServiceInitiators.LIST.size() );
initiators.addAll( StandardServiceInitiators.LIST );
return initiators;
}
@SuppressWarnings("unused")
public BootstrapServiceRegistry getBootstrapServiceRegistry() {
return bootstrapServiceRegistry;
}
@ -205,9 +206,8 @@ public class StandardServiceRegistryBuilder {
* @see #configure()
* @see #configure(String)
*/
@SuppressWarnings({"unchecked"})
public StandardServiceRegistryBuilder loadProperties(String resourceName) {
settings.putAll( configLoader.loadProperties( resourceName ) );
settings.putAll( PropertiesHelper.map( configLoader.loadProperties( resourceName ) ) );
return this;
}
@ -224,9 +224,8 @@ public class StandardServiceRegistryBuilder {
* @see #configure()
* @see #configure(String)
*/
@SuppressWarnings({"unchecked"})
public StandardServiceRegistryBuilder loadProperties(File file) {
settings.putAll( configLoader.loadProperties( file ) );
settings.putAll( PropertiesHelper.map( configLoader.loadProperties( file ) ) );
return this;
}
@ -262,7 +261,6 @@ public class StandardServiceRegistryBuilder {
return configure( configLoader.loadConfigXmlUrl( url ) );
}
@SuppressWarnings({"unchecked"})
public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig) {
aggregatedCfgXml.merge( loadedConfig );
settings.putAll( loadedConfig.getConfigurationValues() );
@ -278,25 +276,38 @@ public class StandardServiceRegistryBuilder {
*
* @return this, for method chaining
*/
@SuppressWarnings({"unchecked", "UnusedDeclaration"})
public StandardServiceRegistryBuilder applySetting(String settingName, Object value) {
settings.put( settingName, value );
return this;
}
/**
* Apply a groups of setting values.
* Apply a group of settings.
*
* @param settings The incoming settings to apply
*
* @return this, for method chaining
*/
@SuppressWarnings({"unchecked", "UnusedDeclaration"})
public StandardServiceRegistryBuilder applySettings(Map settings) {
public StandardServiceRegistryBuilder applySettings(Map<String,Object> settings) {
this.settings.putAll( settings );
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() {
settings.clear();
}
@ -308,8 +319,7 @@ public class StandardServiceRegistryBuilder {
*
* @return this, for method chaining
*/
@SuppressWarnings({"UnusedDeclaration"})
public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator<?> initiator) {
initiators.add( initiator );
return this;
}
@ -322,9 +332,8 @@ public class StandardServiceRegistryBuilder {
*
* @return this, for method chaining
*/
@SuppressWarnings({"unchecked"})
public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) {
providedServices.add( new ProvidedService( serviceRole, service ) );
public <T extends Service> StandardServiceRegistryBuilder addService(final Class<T> serviceRole, final T service) {
providedServices.add( new ProvidedService<>( serviceRole, service ) );
return this;
}
@ -362,12 +371,11 @@ public class StandardServiceRegistryBuilder {
*
* @return The StandardServiceRegistry.
*/
@SuppressWarnings("unchecked")
public StandardServiceRegistry build() {
applyServiceContributingIntegrators();
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 );
ConfigurationHelper.resolvePlaceHolders( settingsCopy );
@ -384,9 +392,9 @@ public class StandardServiceRegistryBuilder {
private void applyServiceContributingIntegrators() {
for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class )
.getIntegrators() ) {
if ( org.hibernate.integrator.spi.ServiceContributingIntegrator.class.isInstance( integrator ) ) {
org.hibernate.integrator.spi.ServiceContributingIntegrator.class.cast( integrator ).prepareServices(
this );
if ( integrator instanceof org.hibernate.integrator.spi.ServiceContributingIntegrator ) {
( (org.hibernate.integrator.spi.ServiceContributingIntegrator) integrator )
.prepareServices(this );
}
}
}
@ -411,7 +419,7 @@ public class StandardServiceRegistryBuilder {
* This allows code to configure the builder and access that to configure Configuration object.
*/
@Deprecated
public Map getSettings() {
public Map<String,Object> getSettings() {
return settings;
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.boot.registry.internal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -28,7 +27,7 @@ import org.hibernate.service.spi.ServiceInitiator;
public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl implements StandardServiceRegistry {
//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
@ -41,12 +40,11 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
*
* @see org.hibernate.boot.registry.StandardServiceRegistryBuilder
*/
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryImpl(
BootstrapServiceRegistry bootstrapServiceRegistry,
List<StandardServiceInitiator> serviceInitiators,
List<ProvidedService> providedServices,
Map<?, ?> configurationValues) {
List<StandardServiceInitiator<?>> serviceInitiators,
List<ProvidedService<?>> providedServices,
Map<String,Object> configurationValues) {
this( true, bootstrapServiceRegistry, serviceInitiators, providedServices, configurationValues );
}
@ -63,13 +61,12 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
*
* @see org.hibernate.boot.registry.StandardServiceRegistryBuilder
*/
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryImpl(
boolean autoCloseRegistry,
BootstrapServiceRegistry bootstrapServiceRegistry,
List<StandardServiceInitiator> serviceInitiators,
List<ProvidedService> providedServices,
Map<?, ?> configurationValues) {
List<StandardServiceInitiator<?>> serviceInitiators,
List<ProvidedService<?>> providedServices,
Map<String,Object> configurationValues) {
super( bootstrapServiceRegistry, autoCloseRegistry );
this.configurationValues = configurationValues;
@ -77,15 +74,17 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
applyServiceRegistrations( serviceInitiators, providedServices );
}
private void applyServiceRegistrations(List<StandardServiceInitiator> serviceInitiators, List<ProvidedService> providedServices) {
private void applyServiceRegistrations(List<StandardServiceInitiator<?>> serviceInitiators, List<ProvidedService<?>> providedServices) {
try {
// process initiators
for ( ServiceInitiator initiator : serviceInitiators ) {
for ( ServiceInitiator<?> initiator : serviceInitiators ) {
createServiceBinding( initiator );
}
// then, explicitly provided service instances
//noinspection rawtypes
for ( ProvidedService providedService : providedServices ) {
//noinspection unchecked
createServiceBinding( providedService );
}
}
@ -103,27 +102,11 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
@Override
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 );
}
}
/**
* 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
public synchronized void destroy() {
super.destroy();

View File

@ -21,7 +21,7 @@ public final class BytecodeProviderInitiator implements StandardServiceInitiator
public static final StandardServiceInitiator<BytecodeProvider> INSTANCE = new BytecodeProviderInitiator();
@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,
// but move to a component which can be reconfigured differently in each registry.
return Environment.getBytecodeProvider();

View File

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

View File

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

View File

@ -43,7 +43,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFa
}
@Override
public RegionFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
public RegionFactory initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final RegionFactory regionFactory = resolveRegionFactory( configurationValues, registry );
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();
p.putAll( configurationValues );
@ -83,8 +83,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFa
if ( setting == null && implementors.size() != 1 ) {
// if either is explicitly defined as TRUE we need a RegionFactory
if ( ( useSecondLevelCache != null && useSecondLevelCache == TRUE )
|| ( useQueryCache != null && useQueryCache == TRUE ) ) {
if ( useSecondLevelCache == TRUE || useQueryCache == TRUE ) {
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;
}
protected RegionFactory getFallback(Map configurationValues, ServiceRegistryImplementor registry) {
protected RegionFactory getFallback(Map<?,?> configurationValues, ServiceRegistryImplementor registry) {
return null;
}
}

View File

@ -79,7 +79,7 @@ public abstract class AbstractRegionFactory implements RegionFactory {
}
@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 ) ) {
synchronized (this) {
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
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}
* 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

View File

@ -165,7 +165,7 @@ public class Configuration {
entityTuplizerFactory = new EntityTuplizerFactory();
interceptor = EmptyInterceptor.INSTANCE;
properties = new Properties( );
properties.putAll( standardServiceRegistryBuilder.getSettings());
properties.putAll( standardServiceRegistryBuilder.getSettings() );
}
@ -320,7 +320,7 @@ public class Configuration {
*
* @param type The type to register.
*/
public Configuration registerTypeOverride(BasicType type) {
public Configuration registerTypeOverride(BasicType<?> type) {
basicTypes.add( type );
return this;
}
@ -865,7 +865,7 @@ public class Configuration {
* @return this for method chaining
*/
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() ) ) {
continue;
}

View File

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

View File

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

View File

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

View File

@ -38,7 +38,7 @@ public class BatchBuilderInitiator implements StandardServiceInitiator<BatchBuil
}
@Override
public BatchBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
public BatchBuilder initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final Object builder = configurationValues.get( BUILDER );
if ( builder == null ) {
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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -47,7 +47,7 @@ public abstract class AbstractMultiTenantConnectionProvider implements MultiTena
}
@Override
public boolean isUnwrappableAs(Class unwrapType) {
public boolean isUnwrappableAs(Class<?> unwrapType) {
return
ConnectionProvider.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();
@Override
public RefCursorSupport initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
public RefCursorSupport initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new StandardRefCursorSupport();
}

View File

@ -53,7 +53,7 @@ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareS
}
@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 );
Dialect dialect = !isEmpty( dialectReference ) ?
constructDialect( dialectReference, resolutionInfoSource ) :

View File

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

View File

@ -36,7 +36,7 @@ public class DialectResolverInitiator implements StandardServiceInitiator<Dialec
}
@Override
public DialectResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
public DialectResolver initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final DialectResolverSet resolverSet = new DialectResolverSet();
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.
*/
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
public JdbcEnvironment initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
public JdbcEnvironment initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final DialectFactory dialectFactory = registry.getService( DialectFactory.class );
// '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 ) );
}
private JdbcConnectionAccess buildJdbcConnectionAccess(Map configValues, ServiceRegistryImplementor registry) {
private JdbcConnectionAccess buildJdbcConnectionAccess(Map<?,?> configValues, ServiceRegistryImplementor registry) {
if ( !configValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) {
ConnectionProvider connectionProvider = registry.getService( ConnectionProvider.class );
return new ConnectionProviderJdbcConnectionAccess( connectionProvider );

View File

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

View File

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

View File

@ -34,14 +34,14 @@ public class SqlStatementLogger {
private final long logSlowQuery;
/**
* Constructs a new SqlStatementLogger instance.
* Constructs a new {@code SqlStatementLogger} instance.
*/
public SqlStatementLogger() {
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 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 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 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.util.Hashtable;
import java.util.Map;
import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.InvalidNameException;
@ -39,14 +38,14 @@ final class JndiServiceImpl implements JndiService {
JndiServiceImpl.class.getName()
);
private final Hashtable initialContextSettings;
private final Hashtable<String,Object> initialContextSettings;
/**
* Constructs a JndiServiceImpl
*
* @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 );
}
@ -57,18 +56,17 @@ final class JndiServiceImpl implements JndiService {
*
* @return The extracted JNDI specific properties.
*/
@SuppressWarnings({ "unchecked" })
private static Hashtable extractJndiProperties(Map configurationValues) {
final Hashtable jndiProperties = new Hashtable();
private static Hashtable<String,Object> extractJndiProperties(Map<?,?> configurationValues) {
final Hashtable<String,Object> jndiProperties = new Hashtable<>();
for ( Map.Entry entry : (Set<Map.Entry>) configurationValues.entrySet() ) {
if ( !String.class.isInstance( entry.getKey() ) ) {
for ( Map.Entry<?,?> entry : configurationValues.entrySet() ) {
if ( !(entry.getKey() instanceof String) ) {
continue;
}
final String propertyName = (String) entry.getKey();
final Object propertyValue = entry.getValue();
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
if ( Environment.JNDI_CLASS.equals( propertyName ) ) {
if ( propertyValue != null ) {
@ -81,8 +79,8 @@ final class JndiServiceImpl implements JndiService {
}
}
else {
final String passThruPropertyname = propertyName.substring( Environment.JNDI_PREFIX.length() + 1 );
jndiProperties.put( passThruPropertyname, propertyValue );
final String passThruPropertyName = propertyName.substring( Environment.JNDI_PREFIX.length() + 1 );
jndiProperties.put( passThruPropertyName, propertyValue );
}
}
}

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ public class JtaPlatformResolverInitiator implements StandardServiceInitiator<Jt
private static final Logger log = Logger.getLogger( JtaPlatformResolverInitiator.class );
@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 JtaPlatformResolver resolver = registry.getService( StrategySelector.class )
.resolveStrategy( JtaPlatformResolver.class, setting );

View File

@ -32,7 +32,7 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( EntityCopyObserverFactoryInitiator.class );
@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 );
if ( value.equals( EntityCopyNotAllowedObserver.SHORT_NAME ) || value.equals( EntityCopyNotAllowedObserver.class.getName() ) ) {
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
//and that they are indeed of the right type.
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() );
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 );
if ( o == null ) {
return EntityCopyNotAllowedObserver.SHORT_NAME; //default
@ -77,9 +77,9 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia
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;
}

View File

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

View File

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

View File

@ -10,7 +10,8 @@ import java.sql.SQLException;
/**
* 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
*/

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();
}
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties) {
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map<?,?> properties) {
return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, null, null );
}
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties,
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map<?,?> properties,
ClassLoader providedClassLoader) {
return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, providedClassLoader, null );
}
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties,
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map<?,?> properties,
ClassLoaderService 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) {
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;
try {
units = PersistenceXmlParser.locatePersistenceUnits( integration );
@ -124,8 +124,7 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
return null;
}
@SuppressWarnings("unchecked")
protected static Map wrap(Map properties) {
protected static Map<?,?> wrap(Map<?,?> properties) {
return properties == null ? Collections.emptyMap() : Collections.unmodifiableMap( properties );
}
@ -166,17 +165,17 @@ public class HibernatePersistenceProvider implements PersistenceProvider {
return true;
}
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitInfo info, Map integration) {
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitInfo info, Map<?,?> integration) {
return Bootstrap.getEntityManagerFactoryBuilder( info, integration );
}
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor,
Map integration, ClassLoader providedClassLoader) {
Map<?,?> integration, ClassLoader providedClassLoader) {
return Bootstrap.getEntityManagerFactoryBuilder( persistenceUnitDescriptor, integration, providedClassLoader );
}
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor,
Map integration, ClassLoaderService providedClassLoaderService) {
Map<?,?> integration, ClassLoaderService 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.internal.EntityManagerMessageLogger;
import org.hibernate.internal.util.NullnessHelper;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
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
private final Map<Object,Object> configurationValues;
private final Map<String,Object> configurationValues;
private final StandardServiceRegistry standardServiceRegistry;
private final ManagedResources managedResources;
private final MetadataBuilderImplementor metamodelBuilder;
@ -184,20 +185,20 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
public EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings) {
Map<String, Object> integrationSettings) {
this( persistenceUnit, integrationSettings, null, null, null );
}
public EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings,
Map<String, Object> integrationSettings,
ClassLoader providedClassLoader ) {
this( persistenceUnit, integrationSettings, providedClassLoader, null, null );
}
public EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings,
Map<String, Object> integrationSettings,
ClassLoaderService providedClassLoaderService ) {
this( persistenceUnit, integrationSettings, null, providedClassLoaderService, null );
}
@ -208,14 +209,14 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
@Internal
public EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnitDescriptor,
Map<?,?> integration,
Map<String, Object> integration,
Consumer<MergedSettings> mergedSettingsBaseline) {
this( persistenceUnitDescriptor, integration, null, null, mergedSettingsBaseline );
}
private EntityManagerFactoryBuilderImpl(
PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings,
Map<String,Object> integrationSettings,
ClassLoader providedClassLoader,
ClassLoaderService providedClassLoaderService,
Consumer<MergedSettings> mergedSettingsBaseline) {
@ -514,7 +515,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
private MergedSettings mergeSettings(
PersistenceUnitDescriptor persistenceUnit,
Map<?,?> integrationSettings,
Map<String,Object> integrationSettings,
StandardServiceRegistryBuilder ssrBuilder,
Consumer<MergedSettings> mergedSettingsBaseline) {
final MergedSettings mergedSettings = new MergedSettings();
@ -541,17 +542,17 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
// 2) additional cache region declarations
//
// 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() ) {
final Map.Entry<Object,Object> entry = itr.next();
final Map.Entry<String,Object> entry = itr.next();
if ( entry.getValue() == null ) {
// remove entries with null values
itr.remove();
break;
}
if ( entry.getKey() instanceof String && entry.getValue() instanceof String) {
final String keyString = (String) entry.getKey();
if ( entry.getValue() instanceof String) {
final String keyString = entry.getKey();
final String valueString = (String) entry.getValue();
if ( keyString.startsWith( CLASS_CACHE_PREFIX ) ) {
@ -584,10 +585,10 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
*/
private void normalizeSettings(
PersistenceUnitDescriptor persistenceUnit,
Map<?, ?> integrationSettings,
Map<String, Object> integrationSettings,
MergedSettings mergedSettings) {
// 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 );
@ -630,7 +631,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
//
// NOTE that this occurs after the specialized normalize calls above which remove
// any specially-handled settings.
for ( Map.Entry<?,?> entry : integrationSettingsCopy.entrySet() ) {
for ( Map.Entry<String,Object> entry : integrationSettingsCopy.entrySet() ) {
if ( entry.getKey() == null ) {
continue;
}
@ -1515,7 +1516,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
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;
@ -1523,12 +1524,12 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
* MergedSettings is initialized with hibernate.properties
*/
private MergedSettings() {
configurationValues.putAll( Environment.getProperties() );
configurationValues.putAll( PropertiesHelper.map( Environment.getProperties() ) );
}
public void processPersistenceUnitDescriptorProperties(PersistenceUnitDescriptor persistenceUnit) {
if ( persistenceUnit.getProperties() != null ) {
configurationValues.putAll( persistenceUnit.getProperties() );
configurationValues.putAll( PropertiesHelper.map( persistenceUnit.getProperties() ) );
}
configurationValues.put( PERSISTENCE_UNIT_NAME, persistenceUnit.getName() );
@ -1551,7 +1552,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
configurationValues.putAll( loadedConfig.getConfigurationValues() );
}
public Map<Object,Object> getConfigurationValues() {
public Map<String,Object> getConfigurationValues() {
return configurationValues;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@
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
* the release
*

View File

@ -11,7 +11,7 @@ import jakarta.enterprise.inject.spi.BeanManager;
/**
* 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
* registration of BeanManager lifecycle callbacks
* registration of {@link BeanManager} lifecycle callbacks
*
* @author Steve Ebersole
*/

View File

@ -7,7 +7,7 @@
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
*/

View File

@ -10,7 +10,7 @@ import org.hibernate.resource.beans.container.spi.BeanContainer;
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/>
* 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).

View File

@ -22,7 +22,7 @@ import org.hibernate.resource.beans.internal.ManagedBeanRegistryImpl;
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}
*
@ -41,12 +41,12 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator<Ma
@Override
public ManagedBeanRegistry initiateService(
Map configurationValues,
Map<String, Object> configurationValues,
ServiceRegistryImplementor 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 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
final Class containerClass;
final Class<?> containerClass;
if ( explicitSetting instanceof Class ) {
containerClass = (Class) explicitSetting;
containerClass = (Class<?>) explicitSetting;
}
else {
final String name = explicitSetting.toString();
// try the StrategySelector service
final Class selected = serviceRegistry.getService( StrategySelector.class )
final Class<?> selected = serviceRegistry.getService( StrategySelector.class )
.selectStrategyImplementor( BeanContainer.class, name );
if ( selected != null ) {
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 {
return classLoaderService.classForName( "jakarta.enterprise.inject.spi.BeanManager" );
}

View File

@ -7,7 +7,7 @@
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.
*
* @author Steve Ebersole

View File

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

View File

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

View File

@ -50,31 +50,29 @@ public abstract class AbstractServiceRegistryImpl
private volatile ServiceRegistryImplementor parent;
private final boolean allowCrawling;
private final ConcurrentMap<Class,ServiceBinding> serviceBindingMap = new ConcurrentHashMap<>();
private final ConcurrentMap<Class,Class> roleXref = new ConcurrentHashMap<>();
private final ConcurrentMap<Class<?>,ServiceBinding<?>> serviceBindingMap = new ConcurrentHashMap<>();
private final ConcurrentMap<Class<?>,Class<?>> roleXref = new ConcurrentHashMap<>();
// The services stored in initializedServiceByRole are completely initialized
// (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
// iterate it in reverse order which is only available through ListIterator
// assume 20 services for initial sizing
// 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.
private boolean autoCloseRegistry;
private final boolean autoCloseRegistry;
// Guarded by synchronization on this.
private Set<ServiceRegistryImplementor> childRegistries;
private final AtomicBoolean active = new AtomicBoolean( true );
@SuppressWarnings( {"UnusedDeclaration"})
protected AbstractServiceRegistryImpl() {
this( (ServiceRegistryImplementor) null );
}
@SuppressWarnings( {"UnusedDeclaration"})
protected AbstractServiceRegistryImpl(boolean autoCloseRegistry) {
this( (ServiceRegistryImplementor) null, autoCloseRegistry );
}
@ -100,7 +98,7 @@ public abstract class AbstractServiceRegistryImpl
public AbstractServiceRegistryImpl(
BootstrapServiceRegistry bootstrapServiceRegistry,
boolean autoCloseRegistry) {
if ( ! ServiceRegistryImplementor.class.isInstance( bootstrapServiceRegistry ) ) {
if ( !(bootstrapServiceRegistry instanceof ServiceRegistryImplementor) ) {
throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" );
}
this.parent = (ServiceRegistryImplementor) bootstrapServiceRegistry;
@ -110,9 +108,8 @@ public abstract class AbstractServiceRegistryImpl
this.parent.registerChild( this );
}
@SuppressWarnings({ "unchecked" })
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 );
}
@ -125,25 +122,23 @@ public abstract class AbstractServiceRegistryImpl
registerService( binding, providedService.getService() );
}
protected void visitServiceBindings(Consumer<ServiceBinding> action) {
protected void visitServiceBindings(Consumer<ServiceBinding<?>> action) {
serviceBindingList.forEach( action );
}
@Override
@SuppressWarnings( {"unchecked"})
public ServiceRegistry getParentServiceRegistry() {
return parent;
}
@Override
@SuppressWarnings({ "unchecked" })
public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole) {
return locateServiceBinding( serviceRole, true );
}
@SuppressWarnings({ "unchecked" })
@SuppressWarnings("unchecked")
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 ) {
// look in parent
serviceBinding = parent.locateServiceBinding( serviceRole );
@ -158,32 +153,32 @@ public abstract class AbstractServiceRegistryImpl
}
// look for a previously resolved alternate registration
final Class alternative = roleXref.get( serviceRole );
final Class<?> alternative = roleXref.get( serviceRole );
if ( alternative != null ) {
return serviceBindingMap.get( alternative );
return (ServiceBinding<R>) serviceBindingMap.get( alternative );
}
// perform a crawl looking for an alternate registration
for ( ServiceBinding binding : serviceBindingMap.values() ) {
for ( ServiceBinding<?> binding : serviceBindingMap.values() ) {
if ( serviceRole.isAssignableFrom( binding.getServiceRole() ) ) {
// we found an alternate...
log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() );
registerAlternate( serviceRole, binding.getServiceRole() );
return binding;
return (ServiceBinding<R>) binding;
}
if ( binding.getService() != null && serviceRole.isInstance( binding.getService() ) ) {
// we found an alternate...
log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() );
registerAlternate( serviceRole, binding.getServiceRole() );
return binding;
return (ServiceBinding<R>) binding;
}
}
return null;
}
private void registerAlternate(Class alternate, Class target) {
private void registerAlternate(Class<?> alternate, Class<?> target) {
roleXref.put( alternate, target );
}
@ -249,7 +244,6 @@ public abstract class AbstractServiceRegistryImpl
return service;
}
@SuppressWarnings( {"unchecked"})
protected <R extends Service> R createService(ServiceBinding<R> serviceBinding) {
final ServiceInitiator<R> serviceInitiator = serviceBinding.getServiceInitiator();
if ( serviceInitiator == null ) {
@ -280,7 +274,7 @@ public abstract class AbstractServiceRegistryImpl
applyInjections( service );
if ( ServiceRegistryAwareService.class.isInstance( service ) ) {
if ( service instanceof ServiceRegistryAwareService ) {
( (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) {
final Class<?>[] parameterTypes = injectionMethod.getParameterTypes();
if ( parameterTypes == null || injectionMethod.getParameterCount() != 1 ) {
if ( injectionMethod.getParameterCount() != 1 ) {
throw new ServiceDependencyException(
"Encountered @InjectService on method with unexpected number of parameters"
);
}
//noinspection rawtypes
Class dependentServiceRole = injectService.serviceRole();
if ( dependentServiceRole == null || dependentServiceRole.equals( Void.class ) ) {
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...
//noinspection unchecked
final Service dependantService = getService( dependentServiceRole );
if ( dependantService == null ) {
if ( injectService.required() ) {
@ -336,9 +331,8 @@ public abstract class AbstractServiceRegistryImpl
}
@Override
@SuppressWarnings({ "unchecked" })
public <R extends Service> void startService(ServiceBinding<R> serviceBinding) {
if ( Startable.class.isInstance( serviceBinding.getService() ) ) {
if ( serviceBinding.getService() instanceof Startable ) {
( (Startable) serviceBinding.getService() ).start();
}
}
@ -348,7 +342,6 @@ public abstract class AbstractServiceRegistryImpl
}
@Override
@SuppressWarnings( {"unchecked"})
public synchronized void destroy() {
if ( active.compareAndSet( true, false ) ) {
try {
@ -356,11 +349,11 @@ public abstract class AbstractServiceRegistryImpl
//threads not owning the synchronization lock can't get an invalid Service:
initializedServiceByRole.clear();
synchronized (serviceBindingList) {
ListIterator<ServiceBinding> serviceBindingsIterator = serviceBindingList.listIterator(
ListIterator<ServiceBinding<?>> serviceBindingsIterator = serviceBindingList.listIterator(
serviceBindingList.size()
);
while ( serviceBindingsIterator.hasPrevious() ) {
final ServiceBinding serviceBinding = serviceBindingsIterator.previous();
final ServiceBinding<?> serviceBinding = serviceBindingsIterator.previous();
serviceBinding.getLifecycleOwner().stopService( serviceBinding );
}
serviceBindingList.clear();
@ -376,7 +369,7 @@ public abstract class AbstractServiceRegistryImpl
@Override
public synchronized <R extends Service> void stopService(ServiceBinding<R> binding) {
final Service service = binding.getService();
if ( Stoppable.class.isInstance( service ) ) {
if ( service instanceof Stoppable ) {
try {
( (Stoppable) service ).stop();
}
@ -430,7 +423,7 @@ public abstract class AbstractServiceRegistryImpl
this.parent.deRegisterChild( this );
}
if ( newParent != null ) {
if ( ! ServiceRegistryImplementor.class.isInstance( newParent ) ) {
if ( !(newParent instanceof ServiceRegistryImplementor) ) {
throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" );
}
this.parent = (ServiceRegistryImplementor) newParent;
@ -442,10 +435,7 @@ public abstract class AbstractServiceRegistryImpl
}
public synchronized void reactivate() {
if ( active.compareAndSet( false, true ) ) {
//ok
}
else {
if ( !active.compareAndSet(false, true) ) {
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 {
private final ServiceRegistryImplementor parent;
private final List<SessionFactoryServiceInitiator> initiators = StandardSessionFactoryServiceInitiators.buildStandardServiceInitiatorList();
private final List<ProvidedService> providedServices = new ArrayList<>();
private final List<SessionFactoryServiceInitiator<?>> initiators = StandardSessionFactoryServiceInitiators.buildStandardServiceInitiatorList();
private final List<ProvidedService<?>> providedServices = new ArrayList<>();
public SessionFactoryServiceRegistryBuilderImpl(ServiceRegistryImplementor parent) {
this.parent = parent;
@ -38,8 +38,7 @@ public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryS
* @return this, for method chaining
*/
@Override
@SuppressWarnings( {"UnusedDeclaration"})
public SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator initiator) {
public SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator<?> initiator) {
initiators.add( initiator );
return this;
}
@ -53,9 +52,8 @@ public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryS
* @return this, for method chaining
*/
@Override
@SuppressWarnings( {"unchecked"})
public SessionFactoryServiceRegistryBuilder addService(final Class serviceRole, final Service service) {
providedServices.add( new ProvidedService( serviceRole, service ) );
public <R extends Service> SessionFactoryServiceRegistryBuilder addService(final Class<R> serviceRole, final R service) {
providedServices.add( new ProvidedService<>( serviceRole, service ) );
return this;
}

View File

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

View File

@ -35,11 +35,10 @@ public class SessionFactoryServiceRegistryImpl
private final SessionFactoryOptions sessionFactoryOptions;
private final SessionFactoryImplementor sessionFactory;
@SuppressWarnings({"unchecked", "rawtypes"})
public SessionFactoryServiceRegistryImpl(
ServiceRegistryImplementor parent,
List<SessionFactoryServiceInitiator> initiators,
List<ProvidedService> providedServices,
List<SessionFactoryServiceInitiator<?>> initiators,
List<ProvidedService<?>> providedServices,
SessionFactoryImplementor sessionFactory,
SessionFactoryOptions sessionFactoryOptions) {
super( parent );
@ -48,7 +47,7 @@ public class SessionFactoryServiceRegistryImpl
this.sessionFactoryOptions = sessionFactoryOptions;
// 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
createServiceBinding( initiator );
}

View File

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

View File

@ -18,5 +18,5 @@ public interface Configurable {
*
* @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
*/
public interface SessionFactoryServiceRegistryBuilder {
SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator initiator);
SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator<?> initiator);
@SuppressWarnings( {"unchecked"})
SessionFactoryServiceRegistryBuilder addService(Class serviceRole, Service service);
<R extends Service> SessionFactoryServiceRegistryBuilder addService(Class<R> serviceRole, R service);
}

View File

@ -21,7 +21,7 @@ public interface Wrapped {
*
* @return True/false.
*/
boolean isUnwrappableAs(Class unwrapType);
boolean isUnwrappableAs(Class<?> unwrapType);
/**
* 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:
int count = 0;
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(
AvailableSettings.FORMAT_SQL,
configurationValues,

View File

@ -9,7 +9,6 @@ package org.hibernate.tool.schema.internal;
import java.sql.Connection;
import java.util.Map;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cfg.AvailableSettings;
@ -83,17 +82,17 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
}
@Override
public SchemaCreator getSchemaCreator(Map options) {
public SchemaCreator getSchemaCreator(Map<String,Object> options) {
return new SchemaCreatorImpl( this, getSchemaFilterProvider( options ).getCreateFilter() );
}
@Override
public SchemaDropper getSchemaDropper(Map options) {
public SchemaDropper getSchemaDropper(Map<String,Object> options) {
return new SchemaDropperImpl( this, getSchemaFilterProvider( options ).getDropFilter() );
}
@Override
public SchemaMigrator getSchemaMigrator(Map options) {
public SchemaMigrator getSchemaMigrator(Map<String,Object> options) {
if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) {
return new GroupedSchemaMigratorImpl( this, getSchemaFilterProvider( options ).getMigrateFilter() );
}
@ -103,7 +102,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
}
@Override
public SchemaValidator getSchemaValidator(Map options) {
public SchemaValidator getSchemaValidator(Map<String,Object> options) {
if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) {
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)
? null
: 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 );
}
@ -144,7 +143,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
GenerationTarget[] buildGenerationTargets(
TargetDescriptor targetDescriptor,
JdbcContext jdbcContext,
Map options,
Map<String,Object> options,
boolean needsAutoCommit) {
final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" );
@ -178,7 +177,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
GenerationTarget[] buildGenerationTargets(
TargetDescriptor targetDescriptor,
DdlTransactionIsolator ddlTransactionIsolator,
Map options) {
Map<String,Object> options) {
final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" );
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 );
}
public JdbcContext resolveJdbcContext(Map configurationValues) {
public JdbcContext resolveJdbcContext(Map<String,Object> configurationValues) {
final JdbcContextBuilder jdbcContextBuilder = new JdbcContextBuilder( serviceRegistry );
// 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) {
SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class );
if ( !HibernateSchemaManagementTool.class.isInstance( smt ) ) {
if ( !(smt instanceof HibernateSchemaManagementTool) ) {
smt = new HibernateSchemaManagementTool();
( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry );
}
@ -382,9 +382,9 @@ public class SchemaCreatorImpl implements SchemaCreator {
}
// indexes
final Iterator indexItr = table.getIndexIterator();
final Iterator<Index> indexItr = table.getIndexIterator();
while ( indexItr.hasNext() ) {
final Index index = (Index) indexItr.next();
final Index index = indexItr.next();
checkExportIdentifier( index, exportIdentifiers );
applySqlStrings(
dialect.getIndexExporter().getSqlCreateStrings( index, metadata,
@ -397,9 +397,9 @@ public class SchemaCreatorImpl implements SchemaCreator {
}
// unique keys
final Iterator ukItr = table.getUniqueKeyIterator();
final Iterator<UniqueKey> ukItr = table.getUniqueKeyIterator();
while ( ukItr.hasNext() ) {
final UniqueKey uniqueKey = (UniqueKey) ukItr.next();
final UniqueKey uniqueKey = ukItr.next();
checkExportIdentifier( uniqueKey, exportIdentifiers );
applySqlStrings(
dialect.getUniqueKeyExporter().getSqlCreateStrings( uniqueKey, metadata,
@ -431,9 +431,9 @@ public class SchemaCreatorImpl implements SchemaCreator {
}
// foreign keys
final Iterator fkItr = table.getForeignKeyIterator();
final Iterator<ForeignKey> fkItr = table.getForeignKeyIterator();
while ( fkItr.hasNext() ) {
final ForeignKey foreignKey = (ForeignKey) fkItr.next();
final ForeignKey foreignKey = fkItr.next();
applySqlStrings(
dialect.getForeignKeyExporter().getSqlCreateStrings( foreignKey, metadata,
sqlStringGenerationContext
@ -549,7 +549,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
for ( String currentFile : importFiles.split( "," ) ) {
final String resourceName = currentFile.trim();
if ( resourceName != null && resourceName.isEmpty() ) {
if ( resourceName.isEmpty() ) {
//skip empty resource names
continue;
}
@ -602,7 +602,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
}
@Override
public Map getConfigurationValues() {
public Map<String,Object> getConfigurationValues() {
return Collections.emptyMap();
}
@ -647,7 +647,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
public void doCreation(
Metadata metadata,
final ServiceRegistry serviceRegistry,
final Map settings,
final Map<String,Object> settings,
final boolean manageNamespaces,
GenerationTarget... targets) {
doCreation(
@ -660,7 +660,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
}
@Override
public Map getConfigurationValues() {
public Map<String,Object> getConfigurationValues() {
return settings;
}

View File

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

View File

@ -20,7 +20,7 @@ import org.hibernate.tool.schema.spi.SchemaManagementTool;
public class SchemaManagementToolInitiator implements StandardServiceInitiator<SchemaManagementTool> {
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 );
SchemaManagementTool tool = registry.getService( StrategySelector.class ).resolveStrategy( SchemaManagementTool.class, setting );
if ( tool == null ) {

View File

@ -27,7 +27,7 @@ public class SqlScriptExtractorInitiator implements StandardServiceInitiator<Sql
}
@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 );
if ( explicitSettingValue == null ) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@ public class ImmutableEntityUpdateQueryHandlingModeExceptionTest extends BaseNon
}
@Override
protected void addSettings(Map settings) {
protected void addSettings(Map<String,Object> settings) {
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.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.PropertiesHelper;
import org.hibernate.mapping.UniqueKey;
import org.hibernate.service.ServiceRegistry;
@ -44,7 +45,7 @@ public abstract class AbstractCharsetNamingStrategyTest extends BaseUnitTestCase
@Before
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() );
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( properties );
}

View File

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

View File

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

View File

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

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