private void incrementPersistenceUnitCount(DeploymentUnit deploymentUnit, int persistenceUnitCount) {
if (deploymentUnit.getParent() != null) {
deploymentUnit = deploymentUnit.getParent();
}
PersistenceUnitCount counter;
// create persistence unit counter if not done already
synchronized (deploymentUnit) { // ensure that only deployment thread sets this
counter = deploymentUnit.getAttachment(PersistenceUnitCount.PERSISTENCE_UNIT_COUNT);
if (counter == null) {
counter = new PersistenceUnitCount();
deploymentUnit.putAttachment(PersistenceUnitCount.PERSISTENCE_UNIT_COUNT, counter);
}
}
counter.increment(persistenceUnitCount);
JPA_LOGGER.tracef("incrementing PU count for %s by %d", deploymentUnit.getName(), persistenceUnitCount);
}