1 10 11 package org.mule.config.builders; 12 13 import javax.servlet.ServletContext ; 14 import javax.servlet.ServletException ; 15 import javax.servlet.http.HttpServlet ; 16 import javax.servlet.http.HttpServletRequest ; 17 import javax.servlet.http.HttpServletResponse ; 18 19 import java.io.IOException ; 20 21 import org.mule.MuleManager; 22 import org.mule.config.ConfigurationException; 23 import org.mule.umo.manager.UMOManager; 24 25 28 public class MuleXmlBuilderContextServlet extends HttpServlet 29 { 30 33 private static final long serialVersionUID = -2446689032349402434L; 34 35 public static final String CONFIG_INIT_PARAMETER = "org.mule.config"; 36 37 public void init() throws ServletException 38 { 39 try 40 { 41 String config = getServletContext().getInitParameter(CONFIG_INIT_PARAMETER); 42 if (config == null) 43 { 44 config = getDefaultConfigResource(); 45 } 46 47 createManager(config, getServletContext()); 48 } 49 catch (ConfigurationException e) 50 { 51 getServletContext().log(e.getMessage(), e); 52 } 53 catch (Error error) 54 { 55 getServletContext().log(error.getMessage(), error); 57 throw error; 58 } 59 } 60 61 68 protected UMOManager createManager(String configResource, ServletContext context) 69 throws ConfigurationException 70 { 71 WebappMuleXmlConfigurationBuilder builder = new WebappMuleXmlConfigurationBuilder(context); 72 return builder.configure(configResource, null); 73 } 74 75 81 protected String getDefaultConfigResource() 82 { 83 return "/WEB-INF/mule-config.xml"; 84 } 85 86 protected void service(HttpServletRequest request, HttpServletResponse response) 87 throws ServletException , IOException 88 { 89 getServletContext().log( 90 "(" 91 + request.getRequestURI() 92 + ")" 93 + "MuleXmlBuilderContextServlet.service(HttpServletRequest request, HttpServletResponse response) call ignored."); 94 response.sendError(HttpServletResponse.SC_BAD_REQUEST); 95 } 96 97 public void destroy() 98 { 99 MuleManager.getInstance().dispose(); 100 } 101 } 102 | Popular Tags |