1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.extras.spring.config; |
12 | |
|
13 | |
import org.apache.commons.logging.Log; |
14 | |
import org.apache.commons.logging.LogFactory; |
15 | |
import org.springframework.core.io.ClassPathResource; |
16 | |
import org.springframework.core.io.DefaultResourceLoader; |
17 | |
import org.springframework.core.io.FileSystemResource; |
18 | |
import org.springframework.core.io.Resource; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | 0 | public class MuleResourceLoader extends DefaultResourceLoader |
25 | |
{ |
26 | 0 | protected transient Log logger = LogFactory.getLog(MuleResourceLoader.class); |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
protected Resource getResourceByPath(String path) |
34 | |
{ |
35 | 0 | Resource r = new FileSystemResource(path); |
36 | 0 | if (logger.isDebugEnabled()) |
37 | |
{ |
38 | 0 | logger.debug("Attempting to load resource from file system: " + ((FileSystemResource) r).getFile().getAbsolutePath()); |
39 | |
} |
40 | 0 | if (r.exists()) |
41 | |
{ |
42 | 0 | return r; |
43 | |
} |
44 | |
else |
45 | |
{ |
46 | 0 | logger.debug("Resource does not exist on file system, loading from classpath."); |
47 | 0 | r = new ClassPathResource(path, getClassLoader()); |
48 | 0 | return r; |
49 | |
} |
50 | |
} |
51 | |
} |