public void processPersistenceUnitMetadata() {
// For each orm xml instance document, process persistence unit
// metadata/defaults and mapped superclasses.
for (Map.Entry<URL, Document> mfDocPair : m_project.getMappingFiles().entrySet()) {
// Initialize a helper for navigating the instance document.
XMLHelper helper = new XMLHelper(mfDocPair.getValue(), mfDocPair.getKey().getFile(), m_loader);
// Store all mapped-superclasses.
NodeList nodes = helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.MAPPED_SUPERCLASS);
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
Class cls = helper.getNodeValue(nodes.item(i), XMLConstants.ATT_CLASS, void.class);
m_project.addMappedSuperclass(cls, node, helper);
}
// Store all embeddable classes.
nodes = helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.EMBEDDABLE);
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
Class cls = helper.getNodeValue(nodes.item(i), XMLConstants.ATT_CLASS, void.class);
m_project.addEmbeddable(cls, node, helper);
}
// Look for a persistence-unit-metadata node.
Node persistenceUnitMetadataNode = helper.getNode(new String[] {XMLConstants.ENTITY_MAPPINGS, XMLConstants.PU_METADATA});
if (persistenceUnitMetadataNode != null) {
MetadataPersistenceUnit persistenceUnit = new MetadataPersistenceUnit();
// Process the xml-mapping-metadata-complete tag.
persistenceUnit.setIsMetadataComplete(helper.getNode(persistenceUnitMetadataNode, XMLConstants.METADATA_COMPLETE) != null);
// process persistence unit defaults
Node persistenceUnitDefaultsNode = helper.getNode(persistenceUnitMetadataNode, XMLConstants.PU_DEFAULTS);
if (persistenceUnitDefaultsNode != null) {
// Process the persistence unit access.
persistenceUnit.setAccess(helper.getNodeTextValue(persistenceUnitDefaultsNode, XMLConstants.ACCESS));
// Process the persitence unit schema.
persistenceUnit.setSchema(helper.getNodeTextValue(persistenceUnitDefaultsNode, XMLConstants.SCHEMA));
// Process the persistence unit catalog.
persistenceUnit.setCatalog(helper.getNodeTextValue(persistenceUnitDefaultsNode, XMLConstants.CATALOG));
// Process the persistence unit cascade-persist.
persistenceUnit.setIsCascadePersist(helper.getNode(persistenceUnitDefaultsNode, XMLConstants.CASCADE_PERSIST) != null);
// Process the default entity-listeners. No conflict
// checking will be done, that is, any and all
// default listeners will be added to the project.
NodeList listenerNodes = helper.getNodes(persistenceUnitDefaultsNode, XMLConstants.ENTITY_LISTENERS, XMLConstants.ENTITY_LISTENER);
if (listenerNodes != null) {
m_project.addDefaultListeners(listenerNodes, helper);
}
}