use of org.jboss.as.jpa.interceptor.WebNonTxEmCloserAction in project wildfly by wildfly.
the class PersistenceUnitServiceHandler method handleWarDeployment.
private static void handleWarDeployment(DeploymentPhaseContext phaseContext, boolean startEarly, Platform platform) 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);
String deploymentRootName = null;
// 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);
deploymentRootName = deploymentRoot.getRootName();
}
// look for persistence.xml in war files in the META-INF/persistence.xml directory
List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
for (ResourceRoot resourceRoot : resourceRoots) {
if (resourceRoot.getRoot().getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
if ((holder = resourceRoot.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS)) != null && holder.getPersistenceUnits().size() > 0) {
// assemble and install the PU service
puList.add(holder);
}
}
}
if (startEarly) {
// only add the WebNonTxEmCloserAction valve on the earlier invocation (AS7-6690).
deploymentUnit.addToAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS, new WebNonTxEmCloserAction());
}
ROOT_LOGGER.tracef("install persistence unit definitions for war %s", deploymentRootName);
addPuService(phaseContext, puList, startEarly, platform);
}
}
Aggregations