1
|
package eu.dnetlib.enabling.tools;
|
2
|
|
3
|
import org.springframework.context.ResourceLoaderAware;
|
4
|
import org.springframework.core.io.ResourceLoader;
|
5
|
import org.springframework.core.io.support.ResourcePatternResolver;
|
6
|
import org.springframework.core.io.support.ResourcePatternUtils;
|
7
|
|
8
|
/**
|
9
|
* Some beans aren't directly instantiated (like quartz jobs for instance), so they cannot receive the resource loader
|
10
|
* by implementing the ResourceLoaderAware interface.
|
11
|
* <p>
|
12
|
* This class is a temporary solution to this problem until we find a way to obtain a bean reference to the
|
13
|
* application context (the actual resource loader) itself and inject it directly. It could be done by turning this
|
14
|
* class into a bean factory and expose the resource loader through it.
|
15
|
*
|
16
|
* @author marko
|
17
|
*/
|
18
|
public class ResourceLoaderHelper implements ResourceLoaderAware {
|
19
|
|
20
|
/**
|
21
|
* injected resource loader.
|
22
|
*/
|
23
|
private ResourceLoader resourceLoader;
|
24
|
|
25
|
/**
|
26
|
* obtain a resource pattern resolver for a given resource loader.
|
27
|
*
|
28
|
* @return pattern resolver
|
29
|
*/
|
30
|
public ResourcePatternResolver getResourcePatternResolver() {
|
31
|
return ResourcePatternUtils.getResourcePatternResolver(getResourceLoader());
|
32
|
}
|
33
|
|
34
|
public ResourceLoader getResourceLoader() {
|
35
|
return resourceLoader;
|
36
|
}
|
37
|
|
38
|
@Override
|
39
|
public void setResourceLoader(final ResourceLoader resourceLoader) {
|
40
|
this.resourceLoader = resourceLoader;
|
41
|
}
|
42
|
|
43
|
}
|