Java Code Examples for org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver()

The following examples show how to use org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalSessionFactoryBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 * @param metadataSources the Hibernate MetadataSources service to use (e.g. reusing an existing one)
 * @since 4.3
 */
public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader, MetadataSources metadataSources) {
	super(metadataSources);

	getProperties().put(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
	if (dataSource != null) {
		getProperties().put(AvailableSettings.DATASOURCE, dataSource);
	}

	// Hibernate 5.1/5.2: manually enforce connection release mode ON_CLOSE (the former default)
	try {
		// Try Hibernate 5.2
		AvailableSettings.class.getField("CONNECTION_HANDLING");
		getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_HOLD");
	}
	catch (NoSuchFieldException ex) {
		// Try Hibernate 5.1
		try {
			AvailableSettings.class.getField("ACQUIRE_CONNECTIONS");
			getProperties().put("hibernate.connection.release_mode", "ON_CLOSE");
		}
		catch (NoSuchFieldException ex2) {
			// on Hibernate 5.0.x or lower - no need to change the default there
		}
	}

	getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader()));
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 2
Source File: LocalSessionFactoryBuilder.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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(DataSource dataSource, ResourceLoader resourceLoader) {
	getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
	if (dataSource != null) {
		getProperties().put(Environment.DATASOURCE, dataSource);
	}
	getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader()));
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 3
Source File: LocalSessionFactoryBuilder.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 */
@SuppressWarnings("deprecation")  // to be able to build against Hibernate 4.3
public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader) {
	getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
	if (dataSource != null) {
		getProperties().put(Environment.DATASOURCE, dataSource);
	}
	// APP_CLASSLOADER is deprecated as of Hibernate 4.3 but we need to remain compatible with 4.0+
	getProperties().put(AvailableSettings.APP_CLASSLOADER, resourceLoader.getClassLoader());
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 4
Source File: LocalSessionFactoryBuilder.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * 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
 * @param metadataSources the Hibernate MetadataSources service to use (e.g. reusing an existing one)
 * @since 4.3
 */
public LocalSessionFactoryBuilder(
		@Nullable DataSource dataSource, ResourceLoader resourceLoader, MetadataSources metadataSources) {

	super(metadataSources);

	getProperties().put(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
	if (dataSource != null) {
		getProperties().put(AvailableSettings.DATASOURCE, dataSource);
	}

	// Hibernate 5.1/5.2: manually enforce connection release mode ON_CLOSE (the former default)
	try {
		// Try Hibernate 5.2
		AvailableSettings.class.getField("CONNECTION_HANDLING");
		getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_HOLD");
	}
	catch (NoSuchFieldException ex) {
		// Try Hibernate 5.1
		try {
			AvailableSettings.class.getField("ACQUIRE_CONNECTIONS");
			getProperties().put("hibernate.connection.release_mode", "ON_CLOSE");
		}
		catch (NoSuchFieldException ex2) {
			// on Hibernate 5.0.x or lower - no need to change the default there
		}
	}

	getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader()));
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 5
Source File: SortedResourcesFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 6
Source File: SortedResourcesFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public SortedResourcesFactoryBean(ResourceLoader resourceLoader, List<String> locations) {
	this.locations = locations;
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 7
Source File: LocalSessionFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 8
Source File: LocalSessionFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 9
Source File: SortedResourcesFactoryBean.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 10
Source File: LocalSessionFactoryBean.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Specify a Spring {@link ResourceLoader} to use for Hibernate metadata.
 * @param resourceLoader the ResourceLoader to use (never {@code null})
 */
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 11
Source File: DefaultPersistenceUnitManager.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
	this.componentsIndex = CandidateComponentsIndexLoader.loadIndex(resourceLoader.getClassLoader());
}
 
Example 12
Source File: LocalSessionFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 13
Source File: SortedResourcesFactoryBean.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 14
Source File: SortedResourcesFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public SortedResourcesFactoryBean(ResourceLoader resourceLoader, List<String> locations) {
	this.locations = locations;
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 15
Source File: LocalSessionFactoryBean.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Specify a Spring {@link ResourceLoader} to use for Hibernate metadata.
 * @param resourceLoader the ResourceLoader to use (never {@code null})
 */
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
Example 16
Source File: DefaultPersistenceUnitManager.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
	this.componentsIndex = CandidateComponentsIndexLoader.loadIndex(resourceLoader.getClassLoader());
}
 
Example 17
Source File: ClassPathScanningCandidateComponentProvider.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * 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());
}
 
Example 18
Source File: ClassPathScanningCandidateComponentProvider.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * 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());
}
 
Example 19
Source File: ClassPathScanningCandidateComponentProvider.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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(ResourceLoader resourceLoader) {
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
	this.metadataReaderFactory = new CachingMetadataReaderFactory(resourceLoader);
}
 
Example 20
Source File: ClassPathScanningCandidateComponentProvider.java    From thinking-in-spring-boot-samples with Apache License 2.0 2 votes vote down vote up
/**
 * Set the ResourceLoader to use for resource locations.
 * This will typically be a ResourcePatternResolver implementation.
 * <p>Default is PathMatchingResourcePatternResolver, also capable of
 * resource pattern resolving through the ResourcePatternResolver interface.
 * @see org.springframework.core.io.support.ResourcePatternResolver
 * @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
 */
public void setResourceLoader(ResourceLoader resourceLoader) {
    this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
    this.metadataReaderFactory = new CachingMetadataReaderFactory(resourceLoader);
}