/** * @deprecated Use {@link #applyClassLoader} instead */ @Deprecated public BootstrapServiceRegistryBuilder with(ClassLoader classLoader) { return applyClassLoader( classLoader ); }
bsrBuilder.applyClassLoader( persistenceUnit.getClassLoader() ); bsrBuilder.applyClassLoader( providedClassLoader ); if ( java.util.Collection.class.isInstance( classLoadersSetting ) ) { for ( ClassLoader classLoader : (java.util.Collection<ClassLoader>) classLoadersSetting ) { bsrBuilder.applyClassLoader( classLoader ); bsrBuilder.applyClassLoader( classLoader ); bsrBuilder.applyClassLoader( (ClassLoader) classLoadersSetting );
/** * Create a new LocalSessionFactoryBuilder for the given DataSource. * @param dataSource the JDBC DataSource that the resulting Hibernate SessionFactory should be using * (may be {@code null}) * @param resourceLoader the ResourceLoader to load application classes from */ public LocalSessionFactoryBuilder(@Nullable DataSource dataSource, ResourceLoader resourceLoader) { this(dataSource, resourceLoader, new MetadataSources( new BootstrapServiceRegistryBuilder().applyClassLoader(resourceLoader.getClassLoader()).build())); }
bsrBuilder.applyClassLoader( persistenceUnit.getClassLoader() ); bsrBuilder.applyClassLoader( providedClassLoader ); if ( java.util.Collection.class.isInstance( classLoadersSetting ) ) { for ( ClassLoader classLoader : (java.util.Collection<ClassLoader>) classLoadersSetting ) { bsrBuilder.applyClassLoader( classLoader ); bsrBuilder.applyClassLoader( classLoader ); bsrBuilder.applyClassLoader( (ClassLoader) classLoadersSetting );
protected BootstrapServiceRegistry buildBootstrapServiceRegistry() { final BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder(); builder.applyClassLoader( getClass().getClassLoader() ); prepareBootstrapRegistryBuilder( builder ); return builder.build(); }
/** * Create a new LocalSessionFactoryBuilder for the given DataSource. * @param dataSource the JDBC DataSource that the resulting Hibernate SessionFactory should be using * (may be {@code null}) * @param resourceLoader the ResourceLoader to load application classes from */ public LocalSessionFactoryBuilder(@Nullable DataSource dataSource, ResourceLoader resourceLoader) { this(dataSource, resourceLoader, new MetadataSources( new BootstrapServiceRegistryBuilder().applyClassLoader(resourceLoader.getClassLoader()).build())); }
/** * Determine the Hibernate {@link MetadataSources} to use. * <p>Can also be externally called to initialize and pre-populate a {@link MetadataSources} * instance which is then going to be used for {@link SessionFactory} building. * @return the MetadataSources to use (never {@code null}) * @since 4.3 * @see LocalSessionFactoryBuilder#LocalSessionFactoryBuilder(DataSource, ResourceLoader, MetadataSources) */ public MetadataSources getMetadataSources() { this.metadataSourcesAccessed = true; if (this.metadataSources == null) { BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder(); if (this.resourcePatternResolver != null) { builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader()); } if (this.hibernateIntegrators != null) { for (Integrator integrator : this.hibernateIntegrators) { builder = builder.applyIntegrator(integrator); } } this.metadataSources = new MetadataSources(builder.build()); } return this.metadataSources; }
protected final StandardServiceRegistryBuilder constructStandardServiceRegistryBuilder() { final BootstrapServiceRegistryBuilder bsrb = new BootstrapServiceRegistryBuilder(); bsrb.applyClassLoader( getClass().getClassLoader() ); // by default we do not share the BootstrapServiceRegistry nor the StandardServiceRegistry, // so we want the BootstrapServiceRegistry to be automatically closed when the // StandardServiceRegistry is closed. bsrb.enableAutoClose(); configureBootstrapServiceRegistryBuilder( bsrb ); final BootstrapServiceRegistry bsr = bsrb.build(); afterBootstrapServiceRegistryBuilt( bsr ); final Map settings = new HashMap(); addSettings( settings ); final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder( bsr ); initialize( ssrb ); ssrb.applySettings( settings ); configureStandardServiceRegistryBuilder( ssrb ); return ssrb; }
@Test public void test_bootstrap_bootstrap_native_registry_BootstrapServiceRegistry_example() { ClassLoader customClassLoader = Thread.currentThread().getContextClassLoader(); Integrator customIntegrator = new BeanValidationIntegrator(); //tag::bootstrap-bootstrap-native-registry-BootstrapServiceRegistry-example[] BootstrapServiceRegistryBuilder bootstrapRegistryBuilder = new BootstrapServiceRegistryBuilder(); // add a custom ClassLoader bootstrapRegistryBuilder.applyClassLoader( customClassLoader ); // manually add an Integrator bootstrapRegistryBuilder.applyIntegrator( customIntegrator ); BootstrapServiceRegistry bootstrapRegistry = bootstrapRegistryBuilder.build(); //end::bootstrap-bootstrap-native-registry-BootstrapServiceRegistry-example[] }
/** * Determine the Hibernate {@link MetadataSources} to use. * <p>Can also be externally called to initialize and pre-populate a {@link MetadataSources} * instance which is then going to be used for {@link SessionFactory} building. * @return the MetadataSources to use (never {@code null}) * @since 4.3 * @see LocalSessionFactoryBuilder#LocalSessionFactoryBuilder(DataSource, ResourceLoader, MetadataSources) */ public MetadataSources getMetadataSources() { this.metadataSourcesAccessed = true; if (this.metadataSources == null) { BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder(); if (this.resourcePatternResolver != null) { builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader()); } if (this.hibernateIntegrators != null) { for (Integrator integrator : this.hibernateIntegrators) { builder = builder.applyIntegrator(integrator); } } this.metadataSources = new MetadataSources(builder.build()); } return this.metadataSources; }
/** * @deprecated Use {@link #applyClassLoader} instead */ @Deprecated public BootstrapServiceRegistryBuilder with(ClassLoader classLoader) { return applyClassLoader( classLoader ); }
/** * Create a new LocalSessionFactoryBuilder for the given DataSource. * @param dataSource the JDBC DataSource that the resulting Hibernate SessionFactory should be using * (may be {@code null}) * @param resourceLoader the ResourceLoader to load application classes from */ public LocalSessionFactoryBuilder(@Nullable DataSource dataSource, ResourceLoader resourceLoader) { this(dataSource, resourceLoader, new MetadataSources( new BootstrapServiceRegistryBuilder().applyClassLoader(resourceLoader.getClassLoader()).build())); }
/** * Determine the Hibernate {@link MetadataSources} to use. * <p>Can also be externally called to initialize and pre-populate a {@link MetadataSources} * instance which is then going to be used for {@link SessionFactory} building. * @return the MetadataSources to use (never {@code null}) * @since 4.3 * @see LocalSessionFactoryBuilder#LocalSessionFactoryBuilder(DataSource, ResourceLoader, MetadataSources) */ public MetadataSources getMetadataSources() { this.metadataSourcesAccessed = true; if (this.metadataSources == null) { BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder(); if (this.resourcePatternResolver != null) { builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader()); } if (this.hibernateIntegrators != null) { for (Integrator integrator : this.hibernateIntegrators) { builder = builder.applyIntegrator(integrator); } } this.metadataSources = new MetadataSources(builder.build()); } return this.metadataSources; }