HHH-9949 - Recognize legacy http://hibernate.sourceforge.net/hibernate-configuration DTD base identifier

This commit is contained in:
Steve Ebersole 2015-07-18 17:18:36 -05:00
parent 6812c07a16
commit 837e9913c1
1 changed files with 21 additions and 5 deletions

View File

@ -12,14 +12,15 @@ import java.net.URL;
import javax.xml.stream.XMLStreamException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.log.DeprecationLogger;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
private static final CoreMessageLogger log = CoreLogging.messageLogger( LocalXmlResourceResolver.class );
private static final Logger log = Logger.getLogger( LocalXmlResourceResolver.class );
public static final String CLASSPATH_EXTENSION_URL_BASE = "classpath://";
@ -61,7 +62,7 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
return openUrlStream( HBM_DTD_MAPPING.getMappedLocalUrl() );
}
else if ( LEGACY_HBM_DTD_MAPPING.matches( publicID, systemID ) ) {
log.recognizedObsoleteHibernateNamespace(
DeprecationLogger.DEPRECATION_LOGGER.recognizedObsoleteHibernateNamespace(
LEGACY_HBM_DTD_MAPPING.getIdentifierBase(),
HBM_DTD_MAPPING.getIdentifierBase()
);
@ -71,7 +72,7 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
return openUrlStream( HBM_DTD_MAPPING.getMappedLocalUrl() );
}
else if ( LEGACY2_HBM_DTD_MAPPING.matches( publicID, systemID ) ) {
log.recognizedObsoleteHibernateNamespace(
DeprecationLogger.DEPRECATION_LOGGER.recognizedObsoleteHibernateNamespace(
LEGACY2_HBM_DTD_MAPPING.getIdentifierBase(),
HBM_DTD_MAPPING.getIdentifierBase()
);
@ -86,6 +87,16 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
);
return openUrlStream( CFG_DTD_MAPPING.getMappedLocalUrl() );
}
else if ( LEGACY_CFG_DTD_MAPPING.matches( publicID, systemID ) ) {
DeprecationLogger.DEPRECATION_LOGGER.recognizedObsoleteHibernateNamespace(
LEGACY_CFG_DTD_MAPPING.getIdentifierBase(),
CFG_DTD_MAPPING.getIdentifierBase()
);
log.debug(
"Recognized hibernate-configuration identifier; attempting to resolve on classpath under org/hibernate/"
);
return openUrlStream( CFG_DTD_MAPPING.getMappedLocalUrl() );
}
}
if ( systemID != null ) {
@ -177,6 +188,11 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
"org/hibernate/hibernate-configuration-3.0.dtd"
);
public static final DtdMapping LEGACY_CFG_DTD_MAPPING = new DtdMapping(
"http://hibernate.sourceforge.net/hibernate-configuration",
"org/hibernate/hibernate-configuration-3.0.dtd"
);
public static class NamespaceSchemaMapping {
private final String namespace;