public PersistenceContext get(String persistenceUnit, URI defaultURI, String version, Map<String, Object> initializationProperties) {
PersistenceContext app = getDynamicPersistenceContext(persistenceUnit);
if (app == null){
try{
DynamicClassLoader dcl = new DynamicClassLoader(Thread.currentThread().getContextClassLoader());
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PersistenceUnitProperties.CLASSLOADER, dcl);
if (initializationProperties != null){
properties.putAll(initializationProperties);
}
EntityManagerFactoryImpl factory = (EntityManagerFactoryImpl) Persistence.createEntityManagerFactory(persistenceUnit, 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);