private static PersistenceProviderAdaptor getPersistenceProviderAdaptor ( final PersistenceUnitMetadata pu , final PersistenceProviderDeploymentHolder persistenceProviderDeploymentHolder , final DeploymentUnit deploymentUnit , final PersistenceProvider provider , final Platform platform ) throws DeploymentUnitProcessingException { String adapterClass = pu . getProperties ( ) . getProperty ( Configuration . ADAPTER_CLASS ) ; /** * use adapter packaged in application deployment. */ if ( persistenceProviderDeploymentHolder != null && adapterClass != null ) { List < PersistenceProviderAdaptor > persistenceProviderAdaptors = persistenceProviderDeploymentHolder . getAdapters ( ) ; for ( PersistenceProviderAdaptor persistenceProviderAdaptor : persistenceProviderAdaptors ) { if ( adapterClass . equals ( persistenceProviderAdaptor . getClass ( ) . getName ( ) ) ) { return persistenceProviderAdaptor ; } } } String adaptorModule = pu . getProperties ( ) . getProperty ( Configuration . ADAPTER_MODULE ) ; PersistenceProviderAdaptor adaptor ; adaptor = getPerDeploymentSharedPersistenceProviderAdaptor ( deploymentUnit , adaptorModule , provider ) ; if ( adaptor == null ) { try { // will load the persistence provider adaptor (integration classes). if adaptorModule is null // the noop adaptor is returned (can be used against any provider but the integration classes // are handled externally via properties or code in the persistence provider). if ( adaptorModule != null ) { // legacy way of loading adapter module adaptor = PersistenceProviderAdaptorLoader . loadPersistenceAdapterModule ( adaptorModule , platform , createManager ( deploymentUnit ) ) ; } else { adaptor = PersistenceProviderAdaptorLoader . loadPersistenceAdapter ( provider , platform , createManager ( deploymentUnit ) ) ; } } catch ( ModuleLoadException e ) { throw JpaLogger . ROOT_LOGGER . persistenceProviderAdaptorModuleLoadError ( e , adaptorModule ) ; } adaptor = savePerDeploymentSharedPersistenceProviderAdaptor ( deploymentUnit , adaptorModule , adaptor , provider ) ; } if ( adaptor == null ) { throw JpaLogger . ROOT_LOGGER . failedToGetAdapter ( pu . getPersistenceProviderClassName ( ) ) ; } return adaptor ; }
Get the persistence provider adaptor . Will load the adapter module if needed .