if (isEarDeployment(deploymentUnit)) {
int puCount = 0;
// ordered list of PUs
List<PersistenceUnitMetadataHolder> listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
// handle META-INF/persistence.xml
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
VirtualFile persistence_xml = deploymentRoot.getRoot().getChild(META_INF_PERSISTENCE_XML);
parse(persistence_xml, listPUHolders, deploymentUnit, deploymentRoot);
PersistenceUnitMetadataHolder holder = normalize(listPUHolders);
deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
addApplicationDependenciesOnProvider( deploymentUnit, holder);
markDU(holder, deploymentUnit);
puCount = holder.getPersistenceUnits().size();
// Parsing persistence.xml in EJB jar/war files is handled as subdeployments.
// We need to handle jars in the EAR/lib folder here
List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
assert resourceRoots != null;
for (ResourceRoot resourceRoot : resourceRoots) {
// look at lib/*.jar files that aren't subdeployments (subdeployments are passed
// to deploy(DeploymentPhaseContext)).
if (!SubDeploymentMarker.isSubDeployment(resourceRoot) &&
resourceRoot.getRoot().getName().toLowerCase().endsWith(JAR_FILE_EXTENSION) &&
resourceRoot.getRoot().getParent().getName().equals(LIB_FOLDER)) {
listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
persistence_xml = resourceRoot.getRoot().getChild(META_INF_PERSISTENCE_XML);
parse(persistence_xml, listPUHolders, deploymentUnit, resourceRoot);
holder = normalize(listPUHolders);
resourceRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
addApplicationDependenciesOnProvider( deploymentUnit, holder);
markDU(holder, deploymentUnit);
puCount += holder.getPersistenceUnits().size();
}
}
JPA_LOGGER.tracef("parsed persistence unit definitions for ear %s", deploymentRoot.getRootName());
incrementPersistenceUnitCount(deploymentUnit, puCount);
}
}