View Javadoc

1   /*
2    * $Id: JettyReceiverServlet.java 8427 2007-09-15 02:08:04Z 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 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.providers.http.jetty;
12  
13  import org.mule.providers.http.i18n.HttpMessages;
14  import org.mule.providers.http.servlet.MuleReceiverServlet;
15  import org.mule.umo.endpoint.EndpointException;
16  import org.mule.umo.provider.UMOMessageReceiver;
17  
18  import javax.servlet.ServletConfig;
19  import javax.servlet.ServletContext;
20  import javax.servlet.ServletException;
21  import javax.servlet.http.HttpServletRequest;
22  
23  public class JettyReceiverServlet extends MuleReceiverServlet
24  {
25      /**
26       * Serial version
27       */
28      private static final long serialVersionUID = 238326861089137293L;
29  
30      private UMOMessageReceiver receiver;
31  
32      //@Override
33      protected void doInit(ServletConfig servletConfig) throws ServletException
34      {
35          final ServletContext servletContext = servletConfig.getServletContext();
36          synchronized (servletContext)
37          {
38              receiver = (UMOMessageReceiver) servletContext.getAttribute("messageReceiver");
39          }
40          if (receiver == null)
41          {
42              throw new ServletException(HttpMessages.receiverPropertyNotSet().toString());
43          }
44      }
45  
46      //@Override
47      protected UMOMessageReceiver getReceiverForURI(HttpServletRequest httpServletRequest)
48          throws EndpointException
49      {
50          return receiver;
51      }
52  }