public static List < PersistenceProvider > loadProviderModuleByName ( String moduleName ) throws ModuleLoadException { final ModuleLoader moduleLoader = Module . getBootModuleLoader ( ) ; Module module = moduleLoader . loadModule ( ModuleIdentifier . fromString ( moduleName ) ) ; final ServiceLoader < PersistenceProvider > serviceLoader = module . loadService ( PersistenceProvider . class ) ; List < PersistenceProvider > result = new ArrayList <> ( ) ; if ( serviceLoader != null ) { for ( PersistenceProvider provider1 : serviceLoader ) { // persistence provider jar may contain multiple provider service implementations // save each provider PersistenceProviderResolverImpl . getInstance ( ) . addPersistenceProvider ( provider1 ) ; result . add ( provider1 ) ; } } return result ; }
Loads the specified JPA persistence provider module