// synchronized to prevent overriding of the class loader
// and also calls to predeploy and undeploy by other threads -
// the latter may alter result of shouldRedeploy method.
synchronized(emSetupImpl) {
if(emSetupImpl.shouldRedeploy()) {
SEPersistenceUnitInfo persistenceInfo = (SEPersistenceUnitInfo)emSetupImpl.getPersistenceUnitInfo();
persistenceInfo.setClassLoader(JavaSECMPInitializer.getMainLoader());
// if we are in undeployed state, this is a redeploy of an initial deployment that worked
// so if weaving were going to occur, it already occured. Therefore we can use the main classloader
if (emSetupImpl.isUndeployed()){
persistenceInfo.setNewTempClassLoader(JavaSECMPInitializer.getMainLoader());
}
}
// call predeploy
// this will just increment the factory count since we should already be deployed
emSetupImpl.predeploy(emSetupImpl.getPersistenceUnitInfo(), nonNullProperties);