@ Override public List < PersistenceProvider > getPersistenceProviders ( ) { List < PersistenceProvider > providersCopy = new ArrayList <> ( providers . size ( ) ) ; /** * Add the application specified providers first so they are found before the global providers */ synchronized ( persistenceProviderPerClassLoader ) { if ( persistenceProviderPerClassLoader . size ( ) > 0 ) { // get the deployment or subdeployment classloader ClassLoader deploymentClassLoader = findParentModuleCl ( WildFlySecurityManager . getCurrentContextClassLoaderPrivileged ( ) ) ; ROOT_LOGGER . tracef ( "get application level Persistence Provider for classloader %s" , deploymentClassLoader ) ; // collect persistence providers associated with deployment/each sub-deployment List < Class < ? extends PersistenceProvider > > deploymentSpecificPersistenceProviders = persistenceProviderPerClassLoader . get ( deploymentClassLoader ) ; ROOT_LOGGER . tracef ( "got application level Persistence Provider list %s" , deploymentSpecificPersistenceProviders ) ; if ( deploymentSpecificPersistenceProviders != null ) { for ( Class < ? extends PersistenceProvider > providerClass : deploymentSpecificPersistenceProviders ) { try { ROOT_LOGGER . tracef ( "application has its own Persistence Provider %s" , providerClass . getName ( ) ) ; providersCopy . add ( providerClass . newInstance ( ) ) ; } catch ( InstantiationException e ) { throw JpaLogger . ROOT_LOGGER . couldNotCreateInstanceProvider ( e , providerClass . getName ( ) ) ; } catch ( IllegalAccessException e ) { throw JpaLogger . ROOT_LOGGER . couldNotCreateInstanceProvider ( e , providerClass . getName ( ) ) ; } } } } } // add global persistence providers last (so application packaged providers have priority) for ( Class < ? > providerClass : providers ) { try { providersCopy . add ( ( PersistenceProvider ) providerClass . newInstance ( ) ) ; ROOT_LOGGER . tracef ( "returning global (module) Persistence Provider %s" , providerClass . getName ( ) ) ; } catch ( InstantiationException e ) { throw JpaLogger . ROOT_LOGGER . couldNotCreateInstanceProvider ( e , providerClass . getName ( ) ) ; } catch ( IllegalAccessException e ) { throw JpaLogger . ROOT_LOGGER . couldNotCreateInstanceProvider ( e , providerClass . getName ( ) ) ; } } return providersCopy ; }
Return a new instance of each persistence provider class