KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > config > builders > WebappMuleXmlConfigurationBuilder


1 /*
2  * $Id: WebappMuleXmlConfigurationBuilder.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.config.builders;
12
13 import org.mule.config.ConfigurationException;
14
15 import javax.servlet.ServletContext JavaDoc;
16
17 import java.io.InputStream JavaDoc;
18
19 /**
20  * <code>WebappMuleXmlConfigurationBuilder</code> will first try and load config
21  * resources from the Servlet context. If this fails it fails back to the methods
22  * used by the MuleXmlConfigurationBuilder.
23  *
24  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
25  * @version $Revision: 3798 $
26  * @see org.mule.config.builders.MuleXmlConfigurationBuilder
27  */

28 public class WebappMuleXmlConfigurationBuilder extends MuleXmlConfigurationBuilder
29 {
30     private ServletContext JavaDoc context;
31
32     public WebappMuleXmlConfigurationBuilder(ServletContext JavaDoc context) throws ConfigurationException
33     {
34         super();
35         this.context = context;
36     }
37
38     /**
39      * ConfigResource can be a url, a path on the local file system or a resource
40      * name on the classpath Finds and loads the configuration resource by doing the
41      * following - 1. load it from the servelet context /WEB-INF 2. load it form the
42      * classpath 3. load it from from the local file system 4. load it as a url
43      *
44      * @param configResource a single configuration resource
45      * @return an inputstream to the resource
46      * @throws org.mule.config.ConfigurationException
47      */

48     protected InputStream JavaDoc loadConfig(String JavaDoc configResource) throws ConfigurationException
49     {
50         InputStream JavaDoc is = context.getResourceAsStream(configResource);
51         if (is == null)
52         {
53             is = super.loadConfig(configResource);
54         }
55         return is;
56     }
57 }
58
Popular Tags