final class PersistenceUnitReader
extends java.lang.Object
persistence.xml
files.Modifier and Type | Field and Description |
---|---|
private DataSourceLookup |
dataSourceLookup |
private static java.lang.String |
EXCLUDE_UNLISTED_CLASSES |
private static java.lang.String |
JAR_FILE_URL |
private static java.lang.String |
JTA_DATA_SOURCE |
private static Log |
logger |
private static java.lang.String |
MANAGED_CLASS_NAME |
private static java.lang.String |
MAPPING_FILE_NAME |
private static java.lang.String |
META_INF |
private static java.lang.String |
NON_JTA_DATA_SOURCE |
private static java.lang.String |
PERSISTENCE_UNIT |
private static java.lang.String |
PERSISTENCE_VERSION |
private static java.lang.String |
PROPERTIES |
private static java.lang.String |
PROVIDER |
private ResourcePatternResolver |
resourcePatternResolver |
private static java.lang.String |
SHARED_CACHE_MODE |
private static java.lang.String |
TRANSACTION_TYPE |
private static java.lang.String |
UNIT_NAME |
private static java.lang.String |
VALIDATION_MODE |
Constructor and Description |
---|
PersistenceUnitReader(ResourcePatternResolver resourcePatternResolver,
DataSourceLookup dataSourceLookup)
Create a new PersistenceUnitReader.
|
Modifier and Type | Method and Description |
---|---|
protected org.w3c.dom.Document |
buildDocument(org.xml.sax.ErrorHandler handler,
java.io.InputStream stream)
Validate the given stream and return a valid DOM document for parsing.
|
(package private) static java.net.URL |
determinePersistenceUnitRootUrl(Resource resource)
Determine the persistence unit root URL based on the given resource
(which points to the
persistence.xml file we're reading). |
protected java.util.List<SpringPersistenceUnitInfo> |
parseDocument(Resource resource,
org.w3c.dom.Document document,
java.util.List<SpringPersistenceUnitInfo> infos)
Parse the validated document and add entries to the given unit info list.
|
protected void |
parseJarFiles(org.w3c.dom.Element persistenceUnit,
SpringPersistenceUnitInfo unitInfo)
Parse the
jar-file XML elements. |
protected void |
parseManagedClasses(org.w3c.dom.Element persistenceUnit,
SpringPersistenceUnitInfo unitInfo)
Parse the
class XML elements. |
protected void |
parseMappingFiles(org.w3c.dom.Element persistenceUnit,
SpringPersistenceUnitInfo unitInfo)
Parse the
mapping-file XML elements. |
protected SpringPersistenceUnitInfo |
parsePersistenceUnitInfo(org.w3c.dom.Element persistenceUnit,
java.lang.String version,
java.net.URL rootUrl)
Parse the unit info DOM element.
|
protected void |
parseProperties(org.w3c.dom.Element persistenceUnit,
SpringPersistenceUnitInfo unitInfo)
Parse the
property XML elements. |
SpringPersistenceUnitInfo[] |
readPersistenceUnitInfos(java.lang.String persistenceXmlLocation)
Parse and build all persistence unit infos defined in the specified XML file(s).
|
SpringPersistenceUnitInfo[] |
readPersistenceUnitInfos(java.lang.String[] persistenceXmlLocations)
Parse and build all persistence unit infos defined in the given XML files.
|
private static final java.lang.String PERSISTENCE_VERSION
private static final java.lang.String PERSISTENCE_UNIT
private static final java.lang.String UNIT_NAME
private static final java.lang.String MAPPING_FILE_NAME
private static final java.lang.String JAR_FILE_URL
private static final java.lang.String MANAGED_CLASS_NAME
private static final java.lang.String PROPERTIES
private static final java.lang.String PROVIDER
private static final java.lang.String TRANSACTION_TYPE
private static final java.lang.String JTA_DATA_SOURCE
private static final java.lang.String NON_JTA_DATA_SOURCE
private static final java.lang.String EXCLUDE_UNLISTED_CLASSES
private static final java.lang.String SHARED_CACHE_MODE
private static final java.lang.String VALIDATION_MODE
private static final java.lang.String META_INF
private static final Log logger
private final ResourcePatternResolver resourcePatternResolver
private final DataSourceLookup dataSourceLookup
public PersistenceUnitReader(ResourcePatternResolver resourcePatternResolver, DataSourceLookup dataSourceLookup)
resourcePatternResolver
- the ResourcePatternResolver to use for loading resourcesdataSourceLookup
- the DataSourceLookup to resolve DataSource names in
persistence.xml
files againstpublic SpringPersistenceUnitInfo[] readPersistenceUnitInfos(java.lang.String persistenceXmlLocation)
persistenceXmlLocation
- the resource location (can be a pattern)public SpringPersistenceUnitInfo[] readPersistenceUnitInfos(java.lang.String[] persistenceXmlLocations)
persistenceXmlLocations
- the resource locations (can be patterns)protected org.w3c.dom.Document buildDocument(org.xml.sax.ErrorHandler handler, java.io.InputStream stream) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
protected java.util.List<SpringPersistenceUnitInfo> parseDocument(Resource resource, org.w3c.dom.Document document, java.util.List<SpringPersistenceUnitInfo> infos) throws java.io.IOException
java.io.IOException
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo(org.w3c.dom.Element persistenceUnit, java.lang.String version, @Nullable java.net.URL rootUrl) throws java.io.IOException
java.io.IOException
protected void parseProperties(org.w3c.dom.Element persistenceUnit, SpringPersistenceUnitInfo unitInfo)
property
XML elements.protected void parseManagedClasses(org.w3c.dom.Element persistenceUnit, SpringPersistenceUnitInfo unitInfo)
class
XML elements.protected void parseMappingFiles(org.w3c.dom.Element persistenceUnit, SpringPersistenceUnitInfo unitInfo)
mapping-file
XML elements.protected void parseJarFiles(org.w3c.dom.Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) throws java.io.IOException
jar-file
XML elements.java.io.IOException
@Nullable static java.net.URL determinePersistenceUnitRootUrl(Resource resource) throws java.io.IOException
persistence.xml
file we're reading).resource
- the resource to checkjava.io.IOException
- if the checking failed