PersistenceUnitDescriptor pu = PersistenceUnitDescriptor.class.cast(
descriptor);
Result result = getInitializedResult();
addErrorDetails(result, getVerifierContext().getComponentNameConstructor());
result.setStatus(Result.PASSED); // default status is PASSED
int count = 0;
for(PersistenceUnitDescriptor nextPU : getPUsInSameScope(pu)) {
result.addErrorDetails(smh.getLocalString(getClass().getName() + "puName",
"Found a persistence unit by name [ {0} ] in persistence unit root [ {1} ]",
new Object[]{nextPU.getName(), nextPU.getPuRoot()}));
if (nextPU.getName().equals(pu.getName())) count++;
}
if (count != 1) {
result.failed(smh.getLocalString(getClass().getName() + "failed",
"There are [ {0} ] number of persistence units by name [ {1} ]",
new Object[]{count, pu.getName()}));
}
return result;