Search in sources :

Example 1 with JpaIntegrator

use of org.hibernate.jpa.event.spi.JpaIntegrator in project hibernate-orm by hibernate.

the class EntityManagerFactoryBuilderImpl method buildBootstrapServiceRegistry.

/**
	 * Builds the {@link BootstrapServiceRegistry} used to eventually build the {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder}; mainly
	 * used here during instantiation to define class-loading behavior.
	 *
	 * @param integrationSettings Any integration settings passed by the EE container or SE application
	 *
	 * @return The built BootstrapServiceRegistry
	 */
private BootstrapServiceRegistry buildBootstrapServiceRegistry(Map integrationSettings, ClassLoader providedClassLoader, ClassLoaderService providedClassLoaderService) {
    final BootstrapServiceRegistryBuilder bsrBuilder = new BootstrapServiceRegistryBuilder();
    bsrBuilder.applyIntegrator(new JpaIntegrator());
    final IntegratorProvider integratorProvider = (IntegratorProvider) integrationSettings.get(INTEGRATOR_PROVIDER);
    if (integratorProvider != null) {
        for (Integrator integrator : integratorProvider.getIntegrators()) {
            bsrBuilder.applyIntegrator(integrator);
        }
    }
    final StrategyRegistrationProviderList strategyRegistrationProviderList = (StrategyRegistrationProviderList) integrationSettings.get(STRATEGY_REGISTRATION_PROVIDERS);
    if (strategyRegistrationProviderList != null) {
        for (StrategyRegistrationProvider strategyRegistrationProvider : strategyRegistrationProviderList.getStrategyRegistrationProviders()) {
            bsrBuilder.applyStrategySelectors(strategyRegistrationProvider);
        }
    }
    if (providedClassLoaderService != null) {
        bsrBuilder.applyClassLoaderService(providedClassLoaderService);
    } else {
        if (persistenceUnit.getClassLoader() != null) {
            bsrBuilder.applyClassLoader(persistenceUnit.getClassLoader());
        }
        if (providedClassLoader != null) {
            bsrBuilder.applyClassLoader(providedClassLoader);
        }
        final ClassLoader appClassLoader = (ClassLoader) integrationSettings.get(org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER);
        if (appClassLoader != null) {
            LOG.debugf("Found use of deprecated `%s` setting; use `%s` instead.", org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER, org.hibernate.cfg.AvailableSettings.CLASSLOADERS);
        }
        final Object classLoadersSetting = integrationSettings.get(org.hibernate.cfg.AvailableSettings.CLASSLOADERS);
        if (classLoadersSetting != null) {
            if (java.util.Collection.class.isInstance(classLoadersSetting)) {
                for (ClassLoader classLoader : (java.util.Collection<ClassLoader>) classLoadersSetting) {
                    bsrBuilder.applyClassLoader(classLoader);
                }
            } else if (classLoadersSetting.getClass().isArray()) {
                for (ClassLoader classLoader : (ClassLoader[]) classLoadersSetting) {
                    bsrBuilder.applyClassLoader(classLoader);
                }
            } else if (ClassLoader.class.isInstance(classLoadersSetting)) {
                bsrBuilder.applyClassLoader((ClassLoader) classLoadersSetting);
            }
        }
        //configurationValues not assigned yet, using directly the properties of the PU
        Properties puProperties = persistenceUnit.getProperties();
        if (puProperties != null) {
            final String tcclLookupPrecedence = puProperties.getProperty(org.hibernate.cfg.AvailableSettings.TC_CLASSLOADER);
            if (tcclLookupPrecedence != null) {
                bsrBuilder.applyTcclLookupPrecedence(TcclLookupPrecedence.valueOf(tcclLookupPrecedence.toUpperCase(Locale.ROOT)));
            }
        }
    }
    return bsrBuilder.build();
}
Also used : BootstrapServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder) Properties(java.util.Properties) StrategyRegistrationProviderList(org.hibernate.jpa.boot.spi.StrategyRegistrationProviderList) StrategyRegistrationProvider(org.hibernate.boot.registry.selector.StrategyRegistrationProvider) JpaIntegrator(org.hibernate.jpa.event.spi.JpaIntegrator) BeanValidationIntegrator(org.hibernate.cfg.beanvalidation.BeanValidationIntegrator) Integrator(org.hibernate.integrator.spi.Integrator) JpaIntegrator(org.hibernate.jpa.event.spi.JpaIntegrator) IntegratorProvider(org.hibernate.jpa.boot.spi.IntegratorProvider)

Aggregations

Properties (java.util.Properties)1 BootstrapServiceRegistryBuilder (org.hibernate.boot.registry.BootstrapServiceRegistryBuilder)1 StrategyRegistrationProvider (org.hibernate.boot.registry.selector.StrategyRegistrationProvider)1 BeanValidationIntegrator (org.hibernate.cfg.beanvalidation.BeanValidationIntegrator)1 Integrator (org.hibernate.integrator.spi.Integrator)1 IntegratorProvider (org.hibernate.jpa.boot.spi.IntegratorProvider)1 StrategyRegistrationProviderList (org.hibernate.jpa.boot.spi.StrategyRegistrationProviderList)1 JpaIntegrator (org.hibernate.jpa.event.spi.JpaIntegrator)1