if (module == null)
throw new DeploymentUnitProcessingException("Failed to get module attachment for " + phaseContext.getDeploymentUnit());
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final ModuleClassLoader classLoader = module.getClassLoader();
PersistenceProviderDeploymentHolder persistenceProviderDeploymentHolder = deploymentUnit.getAttachment(JpaAttachments.DEPLOYED_PERSISTENCE_PROVIDER);
if (persistenceProviderDeploymentHolder == null && deploymentUnit.getParent() != null) {
persistenceProviderDeploymentHolder = deploymentUnit.getParent().getAttachment(JpaAttachments.DEPLOYED_PERSISTENCE_PROVIDER);
}
for (PersistenceUnitMetadataHolder holder : puList) {
for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) {
pu.setClassLoader(classLoader);
pu.setTempClassloader(new TempClassLoader(classLoader));
try {
final HashMap properties = new HashMap();
if (!ValidationMode.NONE.equals(pu.getValidationMode())) {
ValidatorFactory validatorFactory = SerializableValidatorFactory.getINSTANCE();
properties.put("javax.persistence.validation.factory", validatorFactory);
}
final PersistenceProviderAdaptor adaptor = getPersistenceProviderAdaptor(pu, persistenceProviderDeploymentHolder);
final PersistenceProvider provider;
if (persistenceProviderDeploymentHolder != null &&
persistenceProviderDeploymentHolder.getProvider() != null &&
persistenceProviderDeploymentHolder.getProvider().getClass().getName().equals(pu.getPersistenceProviderClassName())) {
provider = persistenceProviderDeploymentHolder.getProvider();
} else {
provider = lookupProvider(pu);
}
final PersistenceUnitService service = new PersistenceUnitService(pu, adaptor, provider);