if(emfs == null) {
try {
emfs = new HashMap<String, EntityManagerFactory>();
//Get hold of the provider
PersistenceProvider providerService = (PersistenceProvider) containerContext.getService(provider);
if(providerService == null) {
_logger.warn("The PersistenceProvider service hosting persistence units in bundle "
+ bundle.getSymbolicName() + "_" + bundle.getVersion() + " is no longer available. " +
"Persistence units defined by the bundle will not be available until the bundle is refreshed");
throw new InvalidPersistenceUnitException();
}
for(ManagedPersistenceUnitInfo info : persistenceUnits){
PersistenceUnitInfo pUnitInfo = info.getPersistenceUnitInfo();
emfs.put(pUnitInfo.getPersistenceUnitName(),
providerService.createContainerEntityManagerFactory(
pUnitInfo, info.getContainerProperties()));
}
} finally {
//Remember to unget the provider
containerContext.ungetService(provider);