1 10 11 package org.mule.config.builders; 12 13 import org.mule.MuleManager; 14 import org.mule.config.ConfigurationException; 15 import org.mule.umo.manager.UMOManager; 16 17 import javax.servlet.ServletContext ; 18 import javax.servlet.ServletContextEvent ; 19 import javax.servlet.ServletContextListener ; 20 21 36 37 public class MuleXmlBuilderContextListener implements ServletContextListener 38 { 39 public static final String CONFIG_INIT_PARAMETER = "org.mule.config"; 40 41 public void contextInitialized(ServletContextEvent event) 42 { 43 String config = event.getServletContext().getInitParameter(CONFIG_INIT_PARAMETER); 44 if (config == null) 45 { 46 config = getDefaultConfigResource(); 47 } 48 try 49 { 50 createManager(config, event.getServletContext()); 51 } 52 catch (ConfigurationException e) 53 { 54 event.getServletContext().log(e.getMessage(), e); 55 } 56 catch (Error error) 57 { 58 event.getServletContext().log(error.getMessage(), error); 60 throw error; 61 } 62 63 } 64 65 72 protected UMOManager createManager(String configResource, ServletContext context) 73 throws ConfigurationException 74 { 75 WebappMuleXmlConfigurationBuilder builder = new WebappMuleXmlConfigurationBuilder(context); 76 return builder.configure(configResource, null); 77 } 78 79 85 protected String getDefaultConfigResource() 86 { 87 return "/WEB-INF/mule-config.xml"; 88 } 89 90 public void contextDestroyed(ServletContextEvent event) 91 { 92 MuleManager.getInstance().dispose(); 93 } 94 } 95 | Popular Tags |