127
127
import static java .util .Collections .unmodifiableSet ;
128
128
import static org .hibernate .cfg .AvailableSettings .CURRENT_SESSION_CONTEXT_CLASS ;
129
129
import static org .hibernate .internal .FetchProfileHelper .addFetchProfiles ;
130
+ import static org .hibernate .internal .SessionFactoryLogging .SESSION_FACTORY_LOGGER ;
130
131
import static org .hibernate .internal .SessionFactorySettings .determineJndiName ;
131
132
import static org .hibernate .internal .SessionFactorySettings .getMaskedSettings ;
132
133
import static org .hibernate .internal .SessionFactorySettings .getSessionFactoryName ;
155
156
* @author Chris Cranford
156
157
*/
157
158
public class SessionFactoryImpl implements SessionFactoryImplementor {
158
- private static final CoreMessageLogger LOG = CoreLogging .messageLogger ( SessionFactoryImpl .class );
159
159
160
160
private final String name ;
161
161
private final String jndiName ;
@@ -211,7 +211,7 @@ public SessionFactoryImpl(
211
211
final MetadataImplementor bootMetamodel ,
212
212
final SessionFactoryOptions options ,
213
213
final BootstrapContext bootstrapContext ) {
214
- LOG . trace ( "Building session factory" );
214
+ SESSION_FACTORY_LOGGER . buildingSessionFactory ( );
215
215
typeConfiguration = bootstrapContext .getTypeConfiguration ();
216
216
217
217
sessionFactoryOptions = options ;
@@ -228,7 +228,7 @@ public SessionFactoryImpl(
228
228
jdbcServices = serviceRegistry .requireService ( JdbcServices .class );
229
229
230
230
settings = getMaskedSettings ( options , serviceRegistry );
231
- LOG .instantiatingFactory ( uuid , settings );
231
+ SESSION_FACTORY_LOGGER .instantiatingFactory ( uuid , settings );
232
232
233
233
sqlStringGenerationContext = createSqlStringGenerationContext ( bootMetamodel , options , jdbcServices );
234
234
@@ -330,14 +330,12 @@ public SessionFactoryImpl(
330
330
close ();
331
331
}
332
332
catch (Exception closeException ) {
333
- LOG . trace ( "Eating error closing factory after failed instantiation" );
333
+ SESSION_FACTORY_LOGGER . eatingErrorClosingFactoryAfterFailedInstantiation ( );
334
334
}
335
335
throw e ;
336
336
}
337
337
338
- if ( LOG .isTraceEnabled () ) {
339
- LOG .trace ( "Instantiated factory: " + uuid );
340
- }
338
+ SESSION_FACTORY_LOGGER .instantiatedFactory ( uuid );
341
339
}
342
340
343
341
private JavaType <Object > tenantIdentifierType (SessionFactoryOptions options ) {
@@ -762,7 +760,7 @@ public Interceptor getInterceptor() {
762
760
@ Override
763
761
public Reference getReference () {
764
762
// from javax.naming.Referenceable
765
- LOG . trace ( "Returning a Reference to the factory" );
763
+ SESSION_FACTORY_LOGGER . returningReferenceToFactory ( );
766
764
return new Reference (
767
765
SessionFactoryImpl .class .getName (),
768
766
new StringRefAddr ( "uuid" , getUuid () ),
@@ -792,16 +790,14 @@ public void close() {
792
790
if ( getSessionFactoryOptions ().getJpaCompliance ().isJpaClosedComplianceEnabled () ) {
793
791
throw new IllegalStateException ( "EntityManagerFactory is already closed" );
794
792
}
795
-
796
- LOG .trace ( "Already closed" );
793
+ SESSION_FACTORY_LOGGER .alreadyClosed ();
797
794
return ;
798
795
}
799
-
800
796
status = Status .CLOSING ;
801
797
}
802
798
803
799
try {
804
- LOG .closingFactory ( getUuid () );
800
+ SESSION_FACTORY_LOGGER .closingFactory ( uuid );
805
801
observer .sessionFactoryClosing ( this );
806
802
807
803
// NOTE: the null checks below handle cases where close is called
@@ -1036,8 +1032,8 @@ private CurrentSessionContext createSessionContext(String sessionContextType) {
1036
1032
.getConstructor ( new Class []{ SessionFactoryImplementor .class } )
1037
1033
.newInstance ( this );
1038
1034
}
1039
- catch ( Throwable t ) {
1040
- LOG .unableToConstructCurrentSessionContext ( sessionContextType , t );
1035
+ catch ( Throwable throwable ) {
1036
+ SESSION_FACTORY_LOGGER .unableToConstructCurrentSessionContext ( sessionContextType , throwable );
1041
1037
return null ;
1042
1038
}
1043
1039
}
@@ -1109,9 +1105,9 @@ boolean connectionProviderHandlesConnectionSchema() {
1109
1105
*/
1110
1106
@ Serial
1111
1107
private void writeObject (ObjectOutputStream out ) throws IOException {
1112
- LOG .serializingFactory ( getUuid () );
1108
+ SESSION_FACTORY_LOGGER .serializingFactory ( uuid );
1113
1109
out .defaultWriteObject ();
1114
- LOG . trace ( "Serialized factory" );
1110
+ SESSION_FACTORY_LOGGER . serializedFactory ( );
1115
1111
}
1116
1112
1117
1113
/**
@@ -1124,9 +1120,9 @@ private void writeObject(ObjectOutputStream out) throws IOException {
1124
1120
*/
1125
1121
@ Serial
1126
1122
private void readObject (ObjectInputStream in ) throws IOException , ClassNotFoundException {
1127
- LOG . trace ( "Deserializing factory" );
1123
+ SESSION_FACTORY_LOGGER . deserializingFactory ( );
1128
1124
in .defaultReadObject ();
1129
- LOG .deserializedFactory ( getUuid () );
1125
+ SESSION_FACTORY_LOGGER .deserializedFactory ( uuid );
1130
1126
}
1131
1127
1132
1128
/**
@@ -1142,27 +1138,27 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
1142
1138
*/
1143
1139
@ Serial
1144
1140
private Object readResolve () throws InvalidObjectException {
1145
- LOG .trace ( "Resolving serialized factory" );
1146
- return locateSessionFactoryOnDeserialization ( getUuid () , name );
1141
+ SESSION_FACTORY_LOGGER .trace ( "Resolving serialized factory" );
1142
+ return locateSessionFactoryOnDeserialization ( uuid , name );
1147
1143
}
1148
1144
1149
1145
private static SessionFactory locateSessionFactoryOnDeserialization (String uuid , String name )
1150
1146
throws InvalidObjectException {
1151
- final SessionFactory uuidResult = SessionFactoryRegistry .INSTANCE .getSessionFactory ( uuid );
1147
+ final var uuidResult = SessionFactoryRegistry .INSTANCE .getSessionFactory ( uuid );
1152
1148
if ( uuidResult != null ) {
1153
- if ( LOG .isTraceEnabled () ) {
1154
- LOG . trace ( "Resolved factory by UUID: " + uuid );
1149
+ if ( SESSION_FACTORY_LOGGER .isTraceEnabled () ) {
1150
+ SESSION_FACTORY_LOGGER . resolvedFactoryByUuid ( uuid );
1155
1151
}
1156
1152
return uuidResult ;
1157
1153
}
1158
1154
1159
1155
// in case we were deserialized in a different JVM, look for an instance with the same name
1160
1156
// (provided we were given a name)
1161
1157
if ( name != null ) {
1162
- final SessionFactory namedResult = SessionFactoryRegistry .INSTANCE .getNamedSessionFactory ( name );
1158
+ final var namedResult = SessionFactoryRegistry .INSTANCE .getNamedSessionFactory ( name );
1163
1159
if ( namedResult != null ) {
1164
- if ( LOG .isTraceEnabled () ) {
1165
- LOG . trace ( "Resolved factory by name: " + name );
1160
+ if ( SESSION_FACTORY_LOGGER .isTraceEnabled () ) {
1161
+ SESSION_FACTORY_LOGGER . resolvedFactoryByName ( name );
1166
1162
}
1167
1163
return namedResult ;
1168
1164
}
@@ -1193,7 +1189,7 @@ void serialize(ObjectOutputStream oos) throws IOException {
1193
1189
* @throws IOException indicates problems reading back serial data stream
1194
1190
*/
1195
1191
static SessionFactoryImpl deserialize (ObjectInputStream ois ) throws IOException {
1196
- LOG . trace ( "Resolving factory from deserialized session" );
1192
+ SESSION_FACTORY_LOGGER . resolvingFactoryFromDeserializedSession ( );
1197
1193
final String uuid = ois .readUTF ();
1198
1194
boolean isNamed = ois .readBoolean ();
1199
1195
final String name = isNamed ? ois .readUTF () : null ;
0 commit comments