HHH-13838 Allow extension of PersistenceXmlParser

This commit is contained in:
Sanne Grinovero 2020-01-31 14:45:36 +00:00 committed by Sanne Grinovero
parent eb524aa3a4
commit ddb810510c
1 changed files with 10 additions and 3 deletions

View File

@ -50,6 +50,7 @@ import static org.hibernate.internal.HEMLogging.messageLogger;
* @author Steve Ebersole
*/
public class PersistenceXmlParser {
private static final EntityManagerMessageLogger LOG = messageLogger( PersistenceXmlParser.class );
/**
@ -214,12 +215,16 @@ public class PersistenceXmlParser {
private final PersistenceUnitTransactionType defaultTransactionType;
private final Map<String, ParsedPersistenceXmlDescriptor> persistenceUnits;
private PersistenceXmlParser(ClassLoaderService classLoaderService, PersistenceUnitTransactionType defaultTransactionType) {
protected PersistenceXmlParser(ClassLoaderService classLoaderService, PersistenceUnitTransactionType defaultTransactionType) {
this.classLoaderService = classLoaderService;
this.defaultTransactionType = defaultTransactionType;
this.persistenceUnits = new ConcurrentHashMap<>();
}
protected List<ParsedPersistenceXmlDescriptor> getResolvedPersistenceUnits() {
return new ArrayList<>(persistenceUnits.values());
}
private void doResolve(Map integration) {
final List<URL> xmlUrls = classLoaderService.locateResources( "META-INF/persistence.xml" );
if ( xmlUrls.isEmpty() ) {
@ -236,8 +241,10 @@ public class PersistenceXmlParser {
}
}
private void parsePersistenceXml(URL xmlUrl, Map integration) {
LOG.tracef( "Attempting to parse persistence.xml file : %s", xmlUrl.toExternalForm() );
protected void parsePersistenceXml(URL xmlUrl, Map integration) {
if ( LOG.isTraceEnabled() ) {
LOG.tracef( "Attempting to parse persistence.xml file : %s", xmlUrl.toExternalForm() );
}
final Document doc = loadUrl( xmlUrl );
final Element top = doc.getDocumentElement();