127127import static java .util .Collections .unmodifiableSet ;
128128import static org .hibernate .cfg .AvailableSettings .CURRENT_SESSION_CONTEXT_CLASS ;
129129import static org .hibernate .internal .FetchProfileHelper .addFetchProfiles ;
130+ import static org .hibernate .internal .SessionFactoryLogging .SESSION_FACTORY_LOGGER ;
130131import static org .hibernate .internal .SessionFactorySettings .determineJndiName ;
131132import static org .hibernate .internal .SessionFactorySettings .getMaskedSettings ;
132133import static org .hibernate .internal .SessionFactorySettings .getSessionFactoryName ;
155156 * @author Chris Cranford
156157 */
157158public class SessionFactoryImpl implements SessionFactoryImplementor {
158- private static final CoreMessageLogger LOG = CoreLogging .messageLogger ( SessionFactoryImpl .class );
159159
160160 private final String name ;
161161 private final String jndiName ;
@@ -211,7 +211,7 @@ public SessionFactoryImpl(
211211 final MetadataImplementor bootMetamodel ,
212212 final SessionFactoryOptions options ,
213213 final BootstrapContext bootstrapContext ) {
214- LOG . trace ( "Building session factory" );
214+ SESSION_FACTORY_LOGGER . buildingSessionFactory ( );
215215 typeConfiguration = bootstrapContext .getTypeConfiguration ();
216216
217217 sessionFactoryOptions = options ;
@@ -228,7 +228,7 @@ public SessionFactoryImpl(
228228 jdbcServices = serviceRegistry .requireService ( JdbcServices .class );
229229
230230 settings = getMaskedSettings ( options , serviceRegistry );
231- LOG .instantiatingFactory ( uuid , settings );
231+ SESSION_FACTORY_LOGGER .instantiatingFactory ( uuid , settings );
232232
233233 sqlStringGenerationContext = createSqlStringGenerationContext ( bootMetamodel , options , jdbcServices );
234234
@@ -330,14 +330,12 @@ public SessionFactoryImpl(
330330 close ();
331331 }
332332 catch (Exception closeException ) {
333- LOG . trace ( "Eating error closing factory after failed instantiation" );
333+ SESSION_FACTORY_LOGGER . eatingErrorClosingFactoryAfterFailedInstantiation ( );
334334 }
335335 throw e ;
336336 }
337337
338- if ( LOG .isTraceEnabled () ) {
339- LOG .trace ( "Instantiated factory: " + uuid );
340- }
338+ SESSION_FACTORY_LOGGER .instantiatedFactory ( uuid );
341339 }
342340
343341 private JavaType <Object > tenantIdentifierType (SessionFactoryOptions options ) {
@@ -762,7 +760,7 @@ public Interceptor getInterceptor() {
762760 @ Override
763761 public Reference getReference () {
764762 // from javax.naming.Referenceable
765- LOG . trace ( "Returning a Reference to the factory" );
763+ SESSION_FACTORY_LOGGER . returningReferenceToFactory ( );
766764 return new Reference (
767765 SessionFactoryImpl .class .getName (),
768766 new StringRefAddr ( "uuid" , getUuid () ),
@@ -792,16 +790,14 @@ public void close() {
792790 if ( getSessionFactoryOptions ().getJpaCompliance ().isJpaClosedComplianceEnabled () ) {
793791 throw new IllegalStateException ( "EntityManagerFactory is already closed" );
794792 }
795-
796- LOG .trace ( "Already closed" );
793+ SESSION_FACTORY_LOGGER .alreadyClosed ();
797794 return ;
798795 }
799-
800796 status = Status .CLOSING ;
801797 }
802798
803799 try {
804- LOG .closingFactory ( getUuid () );
800+ SESSION_FACTORY_LOGGER .closingFactory ( uuid );
805801 observer .sessionFactoryClosing ( this );
806802
807803 // NOTE: the null checks below handle cases where close is called
@@ -1036,8 +1032,8 @@ private CurrentSessionContext createSessionContext(String sessionContextType) {
10361032 .getConstructor ( new Class []{ SessionFactoryImplementor .class } )
10371033 .newInstance ( this );
10381034 }
1039- catch ( Throwable t ) {
1040- LOG .unableToConstructCurrentSessionContext ( sessionContextType , t );
1035+ catch ( Throwable throwable ) {
1036+ SESSION_FACTORY_LOGGER .unableToConstructCurrentSessionContext ( sessionContextType , throwable );
10411037 return null ;
10421038 }
10431039 }
@@ -1109,9 +1105,9 @@ boolean connectionProviderHandlesConnectionSchema() {
11091105 */
11101106 @ Serial
11111107 private void writeObject (ObjectOutputStream out ) throws IOException {
1112- LOG .serializingFactory ( getUuid () );
1108+ SESSION_FACTORY_LOGGER .serializingFactory ( uuid );
11131109 out .defaultWriteObject ();
1114- LOG . trace ( "Serialized factory" );
1110+ SESSION_FACTORY_LOGGER . serializedFactory ( );
11151111 }
11161112
11171113 /**
@@ -1124,9 +1120,9 @@ private void writeObject(ObjectOutputStream out) throws IOException {
11241120 */
11251121 @ Serial
11261122 private void readObject (ObjectInputStream in ) throws IOException , ClassNotFoundException {
1127- LOG . trace ( "Deserializing factory" );
1123+ SESSION_FACTORY_LOGGER . deserializingFactory ( );
11281124 in .defaultReadObject ();
1129- LOG .deserializedFactory ( getUuid () );
1125+ SESSION_FACTORY_LOGGER .deserializedFactory ( uuid );
11301126 }
11311127
11321128 /**
@@ -1142,27 +1138,27 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
11421138 */
11431139 @ Serial
11441140 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 );
11471143 }
11481144
11491145 private static SessionFactory locateSessionFactoryOnDeserialization (String uuid , String name )
11501146 throws InvalidObjectException {
1151- final SessionFactory uuidResult = SessionFactoryRegistry .INSTANCE .getSessionFactory ( uuid );
1147+ final var uuidResult = SessionFactoryRegistry .INSTANCE .getSessionFactory ( uuid );
11521148 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 );
11551151 }
11561152 return uuidResult ;
11571153 }
11581154
11591155 // in case we were deserialized in a different JVM, look for an instance with the same name
11601156 // (provided we were given a name)
11611157 if ( name != null ) {
1162- final SessionFactory namedResult = SessionFactoryRegistry .INSTANCE .getNamedSessionFactory ( name );
1158+ final var namedResult = SessionFactoryRegistry .INSTANCE .getNamedSessionFactory ( name );
11631159 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 );
11661162 }
11671163 return namedResult ;
11681164 }
@@ -1193,7 +1189,7 @@ void serialize(ObjectOutputStream oos) throws IOException {
11931189 * @throws IOException indicates problems reading back serial data stream
11941190 */
11951191 static SessionFactoryImpl deserialize (ObjectInputStream ois ) throws IOException {
1196- LOG . trace ( "Resolving factory from deserialized session" );
1192+ SESSION_FACTORY_LOGGER . resolvingFactoryFromDeserializedSession ( );
11971193 final String uuid = ois .readUTF ();
11981194 boolean isNamed = ois .readBoolean ();
11991195 final String name = isNamed ? ois .readUTF () : null ;
0 commit comments