/** * Build the Hibernate {@code SessionFactory} through background bootstrapping, * using the given executor for a parallel initialization phase * (e.g. a {@link org.springframework.core.task.SimpleAsyncTaskExecutor}). * <p>{@code SessionFactory} initialization will then switch into background * bootstrap mode, with a {@code SessionFactory} proxy immediately returned for * injection purposes instead of waiting for Hibernate's bootstrapping to complete. * However, note that the first actual call to a {@code SessionFactory} method will * then block until Hibernate's bootstrapping completed, if not ready by then. * For maximum benefit, make sure to avoid early {@code SessionFactory} calls * in init methods of related beans, even for metadata introspection purposes. * @since 4.3 * @see #buildSessionFactory() */ public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) { Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null"); return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(), new Class<?>[] {SessionFactoryImplementor.class, InfrastructureProxy.class}, new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor)); }
/** * Set the {@link ResourceLoader} to use for resource locations. * This will typically be a {@link ResourcePatternResolver} implementation. * <p>Default is a {@code PathMatchingResourcePatternResolver}, also capable of * resource pattern resolving through the {@code ResourcePatternResolver} interface. * @see org.springframework.core.io.support.ResourcePatternResolver * @see org.springframework.core.io.support.PathMatchingResourcePatternResolver */ @Override public void setResourceLoader(@Nullable ResourceLoader resourceLoader) { this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); this.metadataReaderFactory = new CachingMetadataReaderFactory(resourceLoader); this.componentsIndex = CandidateComponentsIndexLoader.loadIndex(this.resourcePatternResolver.getClassLoader()); }
@Override public void afterPropertiesSet() { if (this.loadTimeWeaver == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) { this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(this.resourcePatternResolver.getClassLoader()); } preparePersistenceUnitInfos(); }
/** * Build the Hibernate {@code SessionFactory} through background bootstrapping, * using the given executor for a parallel initialization phase * (e.g. a {@link org.springframework.core.task.SimpleAsyncTaskExecutor}). * <p>{@code SessionFactory} initialization will then switch into background * bootstrap mode, with a {@code SessionFactory} proxy immediately returned for * injection purposes instead of waiting for Hibernate's bootstrapping to complete. * However, note that the first actual call to a {@code SessionFactory} method will * then block until Hibernate's bootstrapping completed, if not ready by then. * For maximum benefit, make sure to avoid early {@code SessionFactory} calls * in init methods of related beans, even for metadata introspection purposes. * @since 4.3 * @see #buildSessionFactory() */ public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) { Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null"); return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(), new Class<?>[] {SessionFactoryImplementor.class, InfrastructureProxy.class}, new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor)); }
/** * Set the {@link ResourceLoader} to use for resource locations. * This will typically be a {@link ResourcePatternResolver} implementation. * <p>Default is a {@code PathMatchingResourcePatternResolver}, also capable of * resource pattern resolving through the {@code ResourcePatternResolver} interface. * @see org.springframework.core.io.support.ResourcePatternResolver * @see org.springframework.core.io.support.PathMatchingResourcePatternResolver */ @Override public void setResourceLoader(@Nullable ResourceLoader resourceLoader) { this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); this.metadataReaderFactory = new CachingMetadataReaderFactory(resourceLoader); this.componentsIndex = CandidateComponentsIndexLoader.loadIndex(this.resourcePatternResolver.getClassLoader()); }
ClassLoader cl = this.resourcePatternResolver.getClassLoader(); for (String className : entityClassNames) { addAnnotatedClass(ClassUtils.forName(className, cl));
@Override public void afterPropertiesSet() { if (this.loadTimeWeaver == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) { this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(this.resourcePatternResolver.getClassLoader()); } preparePersistenceUnitInfos(); }
pui.init(this.resourcePatternResolver.getClassLoader());
String className = metadataReader.getClassMetadata().getClassName(); Class<?> jaxb2AnnotatedClass = ClassUtils.forName(className, this.resourcePatternResolver.getClassLoader()); jaxb2Classes.add(jaxb2AnnotatedClass);
/** * 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; }
ClassLoader cl = this.resourcePatternResolver.getClassLoader(); for (String className : entityClassNames) { addAnnotatedClass(ClassUtils.forName(className, cl));
pui.init(this.resourcePatternResolver.getClassLoader());
/** * 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; }
public ClassLoader getClassLoader() { return defaultResolver.getClassLoader(); }
public ClassLoader getClassLoader() { return defaultResolver.getClassLoader(); }
public ClassLoader getClassLoader() { return defaultResolver.getClassLoader(); }
public ClassLoader getClassLoader() { return defaultResolver.getClassLoader(); }
@Override public ClassLoader getClassLoader() { return resolver.getClassLoader(); }
@Override public ClassLoader getClassLoader() { return this.patternResolverDelegate.getClassLoader(); }
public ClassLoader getClassLoader() { return defaultResolver.getClassLoader(); }