if (beanManagerInjector.getOptionalValue() != null) {
// update the bean manager proxy to the actual CDI bean manager
proxyBeanManager = phaseOnePersistenceUnitService.getBeanManager();
proxyBeanManager.setDelegate(beanManagerInjector.getOptionalValue());
}
EntityManagerFactoryBuilder emfBuilder = phaseOnePersistenceUnitService.getEntityManagerFactoryBuilder();
// always pass the ValidatorFactory before starting the second phase of the
// persistence unit bootstrap.
if (validatorFactory != null) {
emfBuilder.withValidatorFactory(validatorFactory);
}
// get the EntityManagerFactory from the second phase of the persistence unit bootstrap
entityManagerFactory = emfBuilder.build();
} else {
JPA_LOGGER.startingService("Persistence Unit", pu.getScopedPersistenceUnitName());
// start the persistence unit in one pass (1 of 1)
pu.setTempClassLoaderFactory(new TempClassLoaderFactoryImpl(classLoader));
pu.setJtaDataSource(jtaDataSource.getOptionalValue());