* @param persistenceProvider classloader will be used to load the persistence provider adapter
* @return the persistence provider adaptor for the provider class
*/
public static PersistenceProviderAdaptor loadPersistenceAdapter(final PersistenceProvider persistenceProvider, final Platform platform)
{
PersistenceProviderAdaptor persistenceProviderAdaptor=null;
final ServiceLoader<PersistenceProviderAdaptor> serviceLoader =
ServiceLoader.load(PersistenceProviderAdaptor.class, persistenceProvider.getClass().getClassLoader());
if (serviceLoader != null) {
for (PersistenceProviderAdaptor adaptor : serviceLoader) {
if (persistenceProviderAdaptor != null) {
throw JpaLogger.ROOT_LOGGER.classloaderHasMultipleAdapters(persistenceProvider.getClass().getClassLoader().toString());
}
persistenceProviderAdaptor = adaptor;
JPA_LOGGER.debugf("loaded persistence provider adapter %s from classloader %s",
persistenceProviderAdaptor.getClass().getName(),
persistenceProvider.getClass().getClassLoader().toString());
}
if (persistenceProviderAdaptor != null) {
persistenceProviderAdaptor.injectJtaManager(JtaManagerImpl.getInstance());
persistenceProviderAdaptor.injectPlatform(platform);
}
}
return persistenceProviderAdaptor == null ?
noopAdaptor: