66
77import java .lang .reflect .InvocationTargetException ;
88import java .sql .Connection ;
9- import java .util .Collection ;
109import java .util .HashSet ;
1110import java .util .Map ;
1211import java .util .Properties ;
2423import org .hibernate .resource .beans .internal .Helper ;
2524import org .hibernate .service .spi .ServiceRegistryImplementor ;
2625
26+ import static java .lang .Integer .parseInt ;
2727import static java .sql .Connection .TRANSACTION_NONE ;
2828import static java .sql .Connection .TRANSACTION_READ_COMMITTED ;
2929import static java .sql .Connection .TRANSACTION_READ_UNCOMMITTED ;
@@ -90,8 +90,8 @@ public ConnectionProvider initiateService(
9090 return null ;
9191 }
9292
93- final BeanContainer beanContainer = Helper .getBeanContainer ( registry );
94- final StrategySelector strategySelector = registry .requireService ( StrategySelector .class );
93+ final var beanContainer = Helper .getBeanContainer ( registry );
94+ final var strategySelector = registry .requireService ( StrategySelector .class );
9595 final Object explicitSetting = configurationValues .get ( CONNECTION_PROVIDER );
9696 if ( explicitSetting != null ) {
9797 // if we are explicitly supplied a ConnectionProvider to use (in some form) -> use it..
@@ -119,16 +119,14 @@ private static Class<? extends ConnectionProvider> connectionProviderClass(Class
119119 + "' does not implement 'ConnectionProvider'" );
120120 }
121121 @ SuppressWarnings ("unchecked" )
122- final Class <? extends ConnectionProvider > connectionProviderClass =
123- (Class <? extends ConnectionProvider >) providerClass ;
122+ final var connectionProviderClass = (Class <? extends ConnectionProvider >) providerClass ;
124123 return connectionProviderClass ;
125124 }
126125
127126 private ConnectionProvider instantiateNamedConnectionProvider (
128127 String providerName , StrategySelector strategySelector , BeanContainer beanContainer ) {
129128 LOG .instantiatingExplicitConnectionProvider ( providerName );
130- final Class <? extends ConnectionProvider > providerClass =
131- strategySelector .selectStrategyImplementor ( ConnectionProvider .class , providerName );
129+ final var providerClass = strategySelector .selectStrategyImplementor ( ConnectionProvider .class , providerName );
132130 try {
133131 return instantiateExplicitConnectionProvider ( providerClass , beanContainer );
134132 }
@@ -143,8 +141,7 @@ private ConnectionProvider instantiateConnectionProvider(
143141 return new DataSourceConnectionProvider ();
144142 }
145143
146- final Class <? extends ConnectionProvider > singleRegisteredProvider =
147- getSingleRegisteredProvider ( strategySelector );
144+ final var singleRegisteredProvider = getSingleRegisteredProvider ( strategySelector );
148145 if ( singleRegisteredProvider != null ) {
149146 try {
150147 return singleRegisteredProvider .getConstructor ().newInstance ();
@@ -188,8 +185,7 @@ private ConnectionProvider noAppropriateConnectionProvider() {
188185 }
189186
190187 private Class <? extends ConnectionProvider > getSingleRegisteredProvider (StrategySelector strategySelector ) {
191- final Collection <Class <? extends ConnectionProvider >> implementors =
192- strategySelector .getRegisteredStrategyImplementors ( ConnectionProvider .class );
188+ final var implementors = strategySelector .getRegisteredStrategyImplementors ( ConnectionProvider .class );
193189 return implementors != null && implementors .size () == 1
194190 ? implementors .iterator ().next ()
195191 : null ;
@@ -245,7 +241,7 @@ private static ConnectionProvider instantiateProvider(StrategySelector selector,
245241 * @return The connection properties.
246242 */
247243 public static Properties getConnectionProperties (Map <String , Object > properties ) {
248- final Properties result = new Properties ();
244+ final var result = new Properties ();
249245 for ( var entry : properties .entrySet () ) {
250246 if ( entry .getValue () instanceof String value ) {
251247 final String key = entry .getKey ();
@@ -343,7 +339,7 @@ else if ( ISOLATION_VALUE_MAP.containsKey( string ) ) {
343339 else {
344340 // it could be a String representation of the isolation numeric value
345341 try {
346- final int isolationLevel = Integer . parseInt ( string );
342+ final int isolationLevel = parseInt ( string );
347343 checkIsolationLevel ( isolationLevel );
348344 return isolationLevel ;
349345 }
@@ -397,8 +393,8 @@ public static String toIsolationNiceName(Integer isolation) {
397393
398394 public static String extractSetting (Map <String , Object > settings , String ... names ) {
399395 for ( String name : names ) {
400- if ( settings .containsKey (name ) ) {
401- return (String ) settings .get (name );
396+ if ( settings .containsKey ( name ) ) {
397+ return (String ) settings .get ( name );
402398 }
403399 }
404400 return null ;
0 commit comments