1
2
3
4
5
6
7
8
9
10
11 package org.mule.config.builders;
12
13 import org.mule.config.ConfigurationException;
14 import org.mule.util.FileUtils;
15
16 import java.io.InputStream;
17
18 import javax.servlet.ServletContext;
19
20
21
22
23
24
25 public class WebappMuleXmlConfigurationBuilder extends MuleXmlConfigurationBuilder
26 {
27 private ServletContext context;
28
29
30
31
32
33 private String webappClasspath;
34
35 public WebappMuleXmlConfigurationBuilder(ServletContext context, String webappClasspath)
36 throws ConfigurationException
37 {
38 super();
39 this.context = context;
40 this.webappClasspath = webappClasspath;
41 }
42
43
44
45
46 protected InputStream loadResource(String resource) throws ConfigurationException
47 {
48 String resourcePath = FileUtils.newFile(webappClasspath, resource).getPath();
49 logger.debug("Searching for resource " + resourcePath + " in Servlet Context.");
50 InputStream is = context.getResourceAsStream(resourcePath);
51 if (is == null)
52 {
53 logger.debug("Resource " + resourcePath + " not found in Servlet Context, loading from classpath");
54 is = super.loadResource(resource);
55 }
56 return is;
57 }
58 }