private void handleWarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (isWarDeployment(deploymentUnit) && JPADeploymentMarker.isJPADeployment(deploymentUnit)) {
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
PersistenceUnitMetadataHolder holder;
ArrayList<PersistenceUnitMetadataHolder> puList = new ArrayList<PersistenceUnitMetadataHolder>(1);
// handle persistence.xml definition in the root of the war
if (deploymentRoot != null &&
(holder = deploymentRoot.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS)) != null &&
holder.getPersistenceUnits().size() > 0) {
// assemble and install the PU service
puList.add(holder);
}
// look for persistence.xml in war files in the META-INF/persistence.xml directory
List<ResourceRoot> resourceRoots = deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS);
assert resourceRoots != null;
for (ResourceRoot resourceRoot : resourceRoots) {
if (resourceRoot.getRoot().getLowerCaseName().endsWith(".jar")) {
if ((holder = resourceRoot.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS)) != null
&& holder.getPersistenceUnits().size() > 0) {
// assemble and install the PU service
puList.add(holder);
}
}