final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (isEarDeployment(deploymentUnit)) {
// 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);
markDU(holder, deploymentUnit);
// 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().getLowerCaseName().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);
markDU(holder, deploymentUnit);
}
}
log.trace("parsed persistence unit definitions for ear " + deploymentRoot.getRootName());
}
}