{
if(container instanceof ExtendedInjectionContainer)
{
ExtendedInjectionContainer eic = (ExtendedInjectionContainer) container;
String beanName = eic.resolvePersistenceUnitSupplier(unitName);
ManagedEntityManagerFactory managedFactory = ((org.jboss.jpa.deployment.PersistenceUnitDeployment) PersistenceUnitRegistry.getPersistenceUnit(beanName)).getManagedFactory();
return new InjectedEntityManagerFactory(managedFactory);
}
throw new UnsupportedOperationException("Container " + container + " does not implement ExtendedInjectionContainer, can't resolve persistence unit " + unitName);
}