View Javadoc

1   /*
2    * $Id: MuleXmlBuilderContextServlet.java 19391 2010-09-07 14:24:40Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
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 java.io.IOException;
14  
15  import javax.servlet.ServletException;
16  import javax.servlet.http.HttpServlet;
17  import javax.servlet.http.HttpServletRequest;
18  import javax.servlet.http.HttpServletResponse;
19  
20  public class MuleXmlBuilderContextServlet extends HttpServlet
21  {
22      /**
23       * Serial version
24       */
25      private static final long serialVersionUID = -2446689032349402434L;
26  
27      private MuleXmlBuilderContextListener contextListener;
28  
29      @Override
30      public void init() throws ServletException
31      {
32          if (contextListener != null)
33          {
34              contextListener.destroy();
35              contextListener = null;
36          }
37          contextListener = new MuleXmlBuilderContextListener();
38          contextListener.initialize(getServletContext());
39      }
40  
41      @Override
42      protected void service(HttpServletRequest request, HttpServletResponse response)
43          throws ServletException, IOException
44      {
45          getServletContext().log(
46              "("
47              + request.getRequestURI()
48              + ")"
49              + "MuleXmlBuilderContextServlet.service(HttpServletRequest request, HttpServletResponse response) call ignored.");
50          response.sendError(HttpServletResponse.SC_BAD_REQUEST);
51      }
52  
53      @Override
54      public void destroy()
55      {
56          if (contextListener != null)
57          {
58              contextListener.destroy();
59          }
60      }
61  }