HHH-10365: Initializing ClassLoaderService in OsgiPersistenceProvider.
This commit is contained in:
parent
bf9b3f524d
commit
585a8aa757
|
@ -43,6 +43,7 @@ import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
||||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
||||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||||
import org.hibernate.boot.spi.MetadataBuilderImplementor;
|
import org.hibernate.boot.spi.MetadataBuilderImplementor;
|
||||||
|
@ -165,6 +166,14 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
||||||
PersistenceUnitDescriptor persistenceUnit,
|
PersistenceUnitDescriptor persistenceUnit,
|
||||||
Map integrationSettings,
|
Map integrationSettings,
|
||||||
ClassLoader providedClassLoader ) {
|
ClassLoader providedClassLoader ) {
|
||||||
|
this(persistenceUnit,integrationSettings,providedClassLoader,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityManagerFactoryBuilderImpl(
|
||||||
|
PersistenceUnitDescriptor persistenceUnit,
|
||||||
|
Map integrationSettings,
|
||||||
|
ClassLoader providedClassLoader,
|
||||||
|
ClassLoaderService providedClassLoaderService) {
|
||||||
|
|
||||||
LogHelper.logPersistenceUnitInformation( persistenceUnit );
|
LogHelper.logPersistenceUnitInformation( persistenceUnit );
|
||||||
|
|
||||||
|
@ -175,7 +184,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the boot-strap service registry, which mainly handles class loader interactions
|
// Build the boot-strap service registry, which mainly handles class loader interactions
|
||||||
final BootstrapServiceRegistry bsr = buildBootstrapServiceRegistry( integrationSettings, providedClassLoader );
|
final BootstrapServiceRegistry bsr = buildBootstrapServiceRegistry( integrationSettings, providedClassLoader, providedClassLoaderService);
|
||||||
|
|
||||||
// merge configuration sources and build the "standard" service registry
|
// merge configuration sources and build the "standard" service registry
|
||||||
final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr );
|
final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr );
|
||||||
|
@ -312,8 +321,12 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
||||||
*/
|
*/
|
||||||
private BootstrapServiceRegistry buildBootstrapServiceRegistry(
|
private BootstrapServiceRegistry buildBootstrapServiceRegistry(
|
||||||
Map integrationSettings,
|
Map integrationSettings,
|
||||||
ClassLoader providedClassLoader) {
|
ClassLoader providedClassLoader,
|
||||||
|
ClassLoaderService providedClassLoaderService) {
|
||||||
final BootstrapServiceRegistryBuilder bsrBuilder = new BootstrapServiceRegistryBuilder();
|
final BootstrapServiceRegistryBuilder bsrBuilder = new BootstrapServiceRegistryBuilder();
|
||||||
|
if (providedClassLoaderService != null) {
|
||||||
|
bsrBuilder.applyClassLoaderService(providedClassLoaderService);
|
||||||
|
}
|
||||||
bsrBuilder.applyIntegrator( new JpaIntegrator() );
|
bsrBuilder.applyIntegrator( new JpaIntegrator() );
|
||||||
|
|
||||||
final IntegratorProvider integratorProvider = (IntegratorProvider) integrationSettings.get( INTEGRATOR_PROVIDER );
|
final IntegratorProvider integratorProvider = (IntegratorProvider) integrationSettings.get( INTEGRATOR_PROVIDER );
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.jpa.boot.spi;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.spi.PersistenceUnitInfo;
|
import javax.persistence.spi.PersistenceUnitInfo;
|
||||||
|
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||||
import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor;
|
import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor;
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ public final class Bootstrap {
|
||||||
Map integration) {
|
Map integration) {
|
||||||
return new EntityManagerFactoryBuilderImpl( persistenceUnitDescriptor, integration );
|
return new EntityManagerFactoryBuilderImpl( persistenceUnitDescriptor, integration );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(
|
public static EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(
|
||||||
PersistenceUnitDescriptor persistenceUnitDescriptor,
|
PersistenceUnitDescriptor persistenceUnitDescriptor,
|
||||||
Map integration,
|
Map integration,
|
||||||
|
@ -34,6 +36,14 @@ public final class Bootstrap {
|
||||||
return new EntityManagerFactoryBuilderImpl( persistenceUnitDescriptor, integration, providedClassLoader );
|
return new EntityManagerFactoryBuilderImpl( persistenceUnitDescriptor, integration, providedClassLoader );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(
|
||||||
|
PersistenceUnitDescriptor persistenceUnitDescriptor,
|
||||||
|
Map integration,
|
||||||
|
ClassLoader providedClassLoader,
|
||||||
|
ClassLoaderService providedClassLoaderService) {
|
||||||
|
return new EntityManagerFactoryBuilderImpl( persistenceUnitDescriptor, integration, providedClassLoader, providedClassLoaderService );
|
||||||
|
}
|
||||||
|
|
||||||
public static EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(
|
public static EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(
|
||||||
PersistenceUnitInfo persistenceUnitInfo,
|
PersistenceUnitInfo persistenceUnitInfo,
|
||||||
Map integration) {
|
Map integration) {
|
||||||
|
@ -46,4 +56,12 @@ public final class Bootstrap {
|
||||||
ClassLoader providedClassLoader) {
|
ClassLoader providedClassLoader) {
|
||||||
return getEntityManagerFactoryBuilder( new PersistenceUnitInfoDescriptor( persistenceUnitInfo ), integration, providedClassLoader );
|
return getEntityManagerFactoryBuilder( new PersistenceUnitInfoDescriptor( persistenceUnitInfo ), integration, providedClassLoader );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(
|
||||||
|
PersistenceUnitInfo persistenceUnitInfo,
|
||||||
|
Map integration,
|
||||||
|
ClassLoader providedClassLoader,
|
||||||
|
ClassLoaderService providedClassLoaderService) {
|
||||||
|
return getEntityManagerFactoryBuilder( new PersistenceUnitInfoDescriptor( persistenceUnitInfo ), integration, providedClassLoader, providedClassLoaderService );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class OsgiPersistenceProvider extends HibernatePersistenceProvider {
|
||||||
|
|
||||||
osgiClassLoader.addClassLoader( info.getClassLoader() );
|
osgiClassLoader.addClassLoader( info.getClassLoader() );
|
||||||
|
|
||||||
return Bootstrap.getEntityManagerFactoryBuilder( info, settings, osgiClassLoader ).build();
|
return Bootstrap.getEntityManagerFactoryBuilder( info, settings, osgiClassLoader, new OSGiClassLoaderServiceImpl( osgiClassLoader, osgiServiceUtil ) ).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
Loading…
Reference in New Issue