properties.put(PersistenceUnitProperties.CLASSLOADER, dcl);
if (initializationProperties != null) {
properties.putAll(initializationProperties);
}
EntityManagerFactoryImpl factory = (EntityManagerFactoryImpl) Persistence.createEntityManagerFactory(persistenceUnitName, properties);
ClassLoader sessionLoader = factory.getServerSession().getLoader();
if (!DynamicClassLoader.class.isAssignableFrom(sessionLoader.getClass())) {
properties = new HashMap<String, Object>();
dcl = new DynamicClassLoader(sessionLoader);
properties.put(PersistenceUnitProperties.CLASSLOADER, dcl);
if (initializationProperties != null) {
properties.putAll(initializationProperties);
}
factory.refreshMetadata(properties);
}
if (factory != null) {
persistenceContext = bootstrapPersistenceContext(persistenceUnitName, factory, defaultURI, version, true);
Set<PersistenceContext> persistenceContextSet = getDynamicPersistenceContextSet(persistenceUnitName);