Also, I have full access to MC at this point, so what I'm doing for @EJB injection is to lookup the EjbReferenceResolver MC bean and use it to get the JNDI name for the injection point.
After injecting PersistenceUnitDependencyResolver, this piece of pseudo code should do the trick:
String beanName = persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(deploymentUnit, persistenceUnitName); PersistenceUnitDeployment deployment = lookup(beanName); ManagedEntityManagerFactory managedFactory = deployment.getManagedFactory(); return new InjectedEntityManagerFactory(managedFactory);
Although PersistenceUnitDeployment is an internal. Maybe we should add a simple utility class to jpa-deployers.