Skip to content

Commit 49b322f

Browse files
committed
cleanup to boot packages
- use more 'var' - move all logging to BootLogging and JaxbLogging
1 parent 83b8e3e commit 49b322f

27 files changed

+621
-517
lines changed

hibernate-core/src/main/java/org/hibernate/boot/BootLogging.java

Lines changed: 141 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,24 @@
55
package org.hibernate.boot;
66

77
import org.hibernate.Internal;
8+
import org.hibernate.boot.jaxb.Origin;
89
import org.hibernate.boot.model.relational.Namespace;
910
import org.hibernate.internal.log.SubSystemLogging;
1011

11-
import java.io.File;
12-
import java.io.FileNotFoundException;
1312
import java.lang.invoke.MethodHandles;
1413

15-
import org.hibernate.type.SerializationException;
1614
import org.jboss.logging.BasicLogger;
1715
import org.jboss.logging.Logger;
1816
import org.jboss.logging.annotations.Cause;
1917
import org.jboss.logging.annotations.LogMessage;
2018
import org.jboss.logging.annotations.Message;
2119
import org.jboss.logging.annotations.MessageLogger;
2220
import org.jboss.logging.annotations.ValidIdRange;
21+
import org.jboss.logging.annotations.ValidIdRanges;
2322

2423
import static org.jboss.logging.Logger.Level.DEBUG;
2524
import static org.jboss.logging.Logger.Level.TRACE;
2625
import static org.jboss.logging.Logger.Level.WARN;
27-
import static org.jboss.logging.Logger.Level.INFO;
2826

2927
/**
3028
* Logging related to Hibernate bootstrapping
@@ -34,7 +32,10 @@
3432
description = "Logging related to bootstrapping of a SessionFactory / EntityManagerFactory"
3533
)
3634
@MessageLogger(projectCode = "HHH")
37-
@ValidIdRange(min = 160101, max = 160200)
35+
@ValidIdRanges({
36+
@ValidIdRange(min = 160101, max = 160200),
37+
@ValidIdRange(min = 160201, max = 160260)
38+
})
3839
@Internal
3940
public interface BootLogging extends BasicLogger {
4041
String NAME = SubSystemLogging.BASE + ".boot";
@@ -44,34 +45,6 @@ public interface BootLogging extends BasicLogger {
4445
@Message(id = 160101, value = "Duplicate generator name %s")
4546
void duplicateGeneratorName(String name);
4647

47-
@LogMessage(level = INFO)
48-
@Message(id = 160102, value = "Reading mappings from file: %s")
49-
void readingMappingsFromFile(String path);
50-
51-
@LogMessage(level = INFO)
52-
@Message(id = 160103, value = "Reading mappings from cache file: %s")
53-
void readingCachedMappings(File cachedFile);
54-
55-
@LogMessage(level = WARN)
56-
@Message(id = 160104, value = "Could not deserialize cache file [%s]: %s")
57-
void unableToDeserializeCache(String path, SerializationException error);
58-
59-
@LogMessage(level = WARN)
60-
@Message(id = 160105, value = "I/O reported error writing cached file: [%s]: %s")
61-
void unableToWriteCachedFile(String path, String message);
62-
63-
@LogMessage(level = WARN)
64-
@Message(id = 160106, value = "Could not update cached file timestamp: [%s]")
65-
@SuppressWarnings("unused")
66-
void unableToUpdateCachedFileTimestamp(String path);
67-
68-
@LogMessage(level = WARN)
69-
@Message(id = 160107, value = "I/O reported cached file could not be found: [%s]: %s")
70-
void cachedFileNotFound(String path, FileNotFoundException error);
71-
72-
@LogMessage(level = INFO)
73-
@Message(id = 160108, value = "Omitting cached file [%s] as the mapping file is newer")
74-
void cachedFileObsolete(File cachedFile);
7548

7649
@LogMessage(level = DEBUG)
7750
@Message(id = 160111, value = "Package not found or no package-info.java: %s")
@@ -268,10 +241,6 @@ public interface BootLogging extends BasicLogger {
268241
@Message(id = 160178, value = "Mapping entity secondary table: %s -> %s")
269242
void mappingEntitySecondaryTableToTable(String entityName, String tableName);
270243

271-
@LogMessage(level = TRACE)
272-
@Message(id = 160179, value = "Writing cache file for: %s to: %s")
273-
void writingCacheFile(String xmlPath, String serPath);
274-
275244
@LogMessage(level = DEBUG)
276245
@Message(id = 160180, value = "Unexpected ServiceRegistry type [%s] encountered during building of MetadataSources; may cause problems later attempting to construct MetadataBuilder")
277246
void unexpectedServiceRegistryType(String registryType);
@@ -340,4 +309,139 @@ public interface BootLogging extends BasicLogger {
340309
ServiceRegistry passed to MetadataBuilder was a BootstrapServiceRegistry; \
341310
this likely won't end well if attempt is made to build SessionFactory""")
342311
void badServiceRegistry();
312+
313+
@LogMessage(level = DEBUG)
314+
@Message(id = 160201, value = "Unable to close cfg.xml resource stream")
315+
void unableToCloseCfgXmlResourceStream(@Cause Throwable e);
316+
317+
@LogMessage(level = DEBUG)
318+
@Message(id = 160202, value = "Unable to close cfg.xml URL stream")
319+
void unableToCloseCfgXmlUrlStream(@Cause Throwable e);
320+
321+
@LogMessage(level = DEBUG)
322+
@Message(id = 160203, value = "Unable to close properties file stream [%s]")
323+
void unableToClosePropertiesFileStream(String path, @Cause Throwable e);
324+
325+
@LogMessage(level = DEBUG)
326+
@Message(id = 160204, value = "cfg.xml document did not define namespaces; wrapping in custom event reader to introduce namespace information")
327+
void cfgXmlDocumentDidNotDefineNamespaces();
328+
329+
@LogMessage(level = DEBUG)
330+
@Message(id = 160212, value = "Unable to adjust relative <jar-file/> URL [%s] relative to root URL [%s]")
331+
void unableToAdjustRelativeJarFileUrl(String filePart, String rootPath, @Cause Throwable e);
332+
333+
@LogMessage(level = TRACE)
334+
@Message(id = 160213, value = "JAR URL from URL Entry: %s >> %s")
335+
void jarUrlFromUrlEntry(String url, String jarUrl);
336+
337+
@LogMessage(level = TRACE)
338+
@Message(id = 160217, value = "Registering AttributeConverter '%s'")
339+
void registeringAttributeConverter(String converter);
340+
341+
@LogMessage(level = DEBUG)
342+
@Message(id = 160218, value = "Skipping registration of discovered AttributeConverter '%s' for auto-apply")
343+
void skippingRegistrationOfDiscoveredAttributeConverterForAutoApply(String converter);
344+
345+
@LogMessage(level = DEBUG)
346+
@Message(id = 160219, value = "Skipping duplicate '@ConverterRegistration' for '%s'")
347+
void skippingDuplicateConverterRegistration(String converter);
348+
349+
@LogMessage(level = DEBUG)
350+
@Message(id = 160220, value = "Removed potentially auto-applicable converter '%s' due to @ConverterRegistration")
351+
void removedPotentiallyAutoApplicableConverterDueToRegistration(String converter);
352+
353+
@LogMessage(level = DEBUG)
354+
@Message(id = 160221, value = "Overwrote existing registration [%s] for type definition.")
355+
void overwroteExistingRegistrationForTypeDefinition(String name);
356+
357+
@LogMessage(level = TRACE)
358+
@Message(id = 160222, value = "Injecting JPA temp ClassLoader [%s] into BootstrapContext; was [%s]")
359+
void injectingJpaTempClassLoader(Object newLoader, Object oldLoader);
360+
361+
@LogMessage(level = TRACE)
362+
@Message(id = 160223, value = "Injecting ScanOptions [%s] into BootstrapContext; was [%s]")
363+
void injectingScanOptions(Object newOptions, Object oldOptions);
364+
365+
@LogMessage(level = TRACE)
366+
@Message(id = 160224, value = "Injecting ScanEnvironment [%s] into BootstrapContext; was [%s]")
367+
void injectingScanEnvironment(Object newEnv, Object oldEnv);
368+
369+
@LogMessage(level = TRACE)
370+
@Message(id = 160225, value = "Injecting Scanner [%s] into BootstrapContext; was [%s]")
371+
void injectingScanner(Object newScanner, Object oldScanner);
372+
373+
@LogMessage(level = TRACE)
374+
@Message(id = 160226, value = "Injecting ArchiveDescriptorFactory [%s] into BootstrapContext; was [%s]")
375+
void injectingArchiveDescriptorFactory(Object newFactory, Object oldFactory);
376+
377+
// Strategy selector tracing
378+
@LogMessage(level = TRACE)
379+
@Message(id = 160227, value = "Strategy selector for %s: '%s' -> %s")
380+
void strategySelectorMapping(String strategySimpleName, String name, String implementationName);
381+
382+
@LogMessage(level = TRACE)
383+
@Message(id = 160228, value = "Strategy selector for %s: '%s' -> %s (replacing %s)")
384+
void strategySelectorMappingReplacing(String strategySimpleName, String name, String implementationName, String oldImplementationName);
385+
386+
@LogMessage(level = DEBUG)
387+
@Message(id = 160229, value = "Named strategy map did not exist on call to unregister")
388+
void namedStrategyMapDidNotExistOnUnregister();
389+
390+
// LoadedConfig messages
391+
@LogMessage(level = DEBUG)
392+
@Message(id = 160230, value = "Listener [%s] defined as part of a group also defined event type")
393+
void listenerDefinedAlsoDefinedEventType(String listenerClass);
394+
395+
@LogMessage(level = DEBUG)
396+
@Message(id = 160231, value = "More than one cfg.xml file attempted to supply SessionFactory name: [%s], [%s]. Keeping initially discovered one [%s]")
397+
void moreThanOneCfgXmlSuppliedSessionFactoryName(String first, String second, String keeping);
398+
399+
// Additional HBM binding traces
400+
@LogMessage(level = TRACE)
401+
@Message(id = 160233, value = "Creating FetchProfile: %s")
402+
void creatingFetchProfile(String name);
403+
404+
@LogMessage(level = TRACE)
405+
@Message(id = 160234, value = "Processing <identifier-generator/> : %s")
406+
void processingIdentifierGenerator(String name);
407+
408+
@LogMessage(level = TRACE)
409+
@Message(id = 160235, value = "Processed type definition : %s -> %s")
410+
void processedTypeDefinition(String name, String impl);
411+
412+
@LogMessage(level = TRACE)
413+
@Message(id = 160236, value = "No temp ClassLoader provided; using live ClassLoader to load potentially unsafe class: %s")
414+
void noTempClassLoaderProvidedUsingLiveClassLoader(String className);
415+
416+
@LogMessage(level = TRACE)
417+
@Message(id = 160237, value = "Registering non-interface strategy : %s")
418+
void registeringNonInterfaceStrategy(String roleName);
419+
420+
@LogMessage(level = TRACE)
421+
@Message(id = 160238, value = "Indexing mapping document [%s] for purpose of building entity hierarchy ordering")
422+
void indexingMappingDocumentForHierarchyOrdering(String mappingDocumentName);
423+
424+
@LogMessage(level = DEBUG)
425+
@Message(id = 160239, value = "Applying filter definition with condition: %s")
426+
void applyingFilterDefinitionCondition(String condition);
427+
428+
@LogMessage(level = TRACE)
429+
@Message(id = 160240, value = "Processed filter definition: %s")
430+
void processedFilterDefinition(String name);
431+
432+
@LogMessage(level = DEBUG)
433+
@Message(id = 160241, value = "Entity supertype named as extends [%s] for subclass [%s:%s] not found")
434+
void entitySupertypeExtendsNotFound(String extendsName, Origin origin, String subclassName);
435+
436+
@LogMessage(level = DEBUG)
437+
@Message(id = 160242, value = "filter-def [name=%s, origin=%s] defined multiple conditions, accepting arbitrary one")
438+
void filterDefDefinedMultipleConditions(String name, String origin);
439+
440+
@LogMessage(level = TRACE)
441+
@Message(id = 160243, value = "Checking auto-apply AttributeConverter [%s] (domain-type=%s) for match against %s : %s.%s (type=%s)")
442+
void checkingAutoApplyAttributeConverter(String converterClass, String domainTypeSignature, String siteDescriptor, String declaringType, String memberName, String memberTypeName);
443+
444+
@LogMessage(level = DEBUG)
445+
@Message(id = 160244, value = "Skipping HBM processing of entity hierarchy [%s], as at least one entity [%s] has been processed")
446+
void skippingHbmProcessingOfEntityHierarchy(String rootEntityName, String processedEntity);
343447
}

hibernate-core/src/main/java/org/hibernate/boot/archive/internal/ArchiveHelper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import org.hibernate.boot.archive.spi.ArchiveException;
1616

17-
import org.jboss.logging.Logger;
1817

1918
/**
2019
* Helper for dealing with archives
@@ -23,7 +22,6 @@
2322
* @author Steve Ebersole
2423
*/
2524
public class ArchiveHelper {
26-
private static final Logger LOG = Logger.getLogger( ArchiveHelper.class );
2725

2826
/**
2927
* Get the JAR URL of the JAR containing the given entry.
@@ -91,7 +89,7 @@ else if ( "zip".equals( protocol )
9189
"Unable to determine JAR Url from " + url + ". Cause: " + e.getMessage()
9290
);
9391
}
94-
LOG.tracef( "JAR URL from URL Entry: %s >> %s", url, jarUrl );
92+
org.hibernate.boot.BootLogging.BOOT_LOGGER.jarUrlFromUrlEntry( String.valueOf(url), String.valueOf(jarUrl) );
9593
return jarUrl;
9694
}
9795

hibernate-core/src/main/java/org/hibernate/boot/archive/internal/StandardArchiveDescriptorFactory.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.hibernate.boot.archive.spi.JarFileEntryUrlAdjuster;
1515
import org.hibernate.internal.util.StringHelper;
1616

17-
import org.jboss.logging.Logger;
17+
import static org.hibernate.boot.BootLogging.BOOT_LOGGER;
1818

1919
/**
2020
* Standard implementation of ArchiveDescriptorFactory
@@ -23,7 +23,6 @@
2323
* @author Steve Ebersole
2424
*/
2525
public class StandardArchiveDescriptorFactory implements ArchiveDescriptorFactory, JarFileEntryUrlAdjuster {
26-
private static final Logger LOG = Logger.getLogger( StandardArchiveDescriptorFactory.class );
2726

2827
/**
2928
* Singleton access
@@ -129,14 +128,11 @@ public URL adjustJarFileEntryUrl(URL url, URL rootUrl) {
129128
}
130129
catch (MalformedURLException e) {
131130
// allow to pass through to return the original URL
132-
if ( LOG.isDebugEnabled() ) {
133-
LOG.debugf(
134-
e,
135-
"Unable to adjust relative <jar-file/> URL [%s] relative to root URL [%s]",
136-
filePart,
137-
rootUrlFile.getAbsolutePath()
138-
);
139-
}
131+
BOOT_LOGGER.unableToAdjustRelativeJarFileUrl(
132+
filePart,
133+
rootUrlFile.getAbsolutePath(),
134+
e
135+
);
140136
}
141137

142138
return url;

0 commit comments

Comments
 (0)