View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config.builders;
8   
9   import java.io.IOException;
10  
11  import javax.servlet.ServletException;
12  import javax.servlet.http.HttpServlet;
13  import javax.servlet.http.HttpServletRequest;
14  import javax.servlet.http.HttpServletResponse;
15  
16  public class MuleXmlBuilderContextServlet extends HttpServlet
17  {
18      /**
19       * Serial version
20       */
21      private static final long serialVersionUID = -2446689032349402434L;
22  
23      private MuleXmlBuilderContextListener contextListener;
24  
25      @Override
26      public void init() throws ServletException
27      {
28          if (contextListener != null)
29          {
30              contextListener.destroy();
31              contextListener = null;
32          }
33          contextListener = new MuleXmlBuilderContextListener();
34          contextListener.initialize(getServletContext());
35      }
36  
37      @Override
38      protected void service(HttpServletRequest request, HttpServletResponse response)
39          throws ServletException, IOException
40      {
41          getServletContext().log(
42              "("
43              + request.getRequestURI()
44              + ")"
45              + "MuleXmlBuilderContextServlet.service(HttpServletRequest request, HttpServletResponse response) call ignored.");
46          response.sendError(HttpServletResponse.SC_BAD_REQUEST);
47      }
48  
49      @Override
50      public void destroy()
51      {
52          if (contextListener != null)
53          {
54              contextListener.destroy();
55          }
56      }
57  }