1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.util.axis;
16  
17  import javax.servlet.ServletContext;
18  import javax.servlet.http.HttpServlet;
19  import javax.servlet.http.HttpServletRequest;
20  import javax.servlet.http.HttpSession;
21  
22  import org.apache.axis.AxisEngine;
23  import org.apache.axis.MessageContext;
24  import org.apache.axis.transport.http.HTTPConstants;
25  
26  /**
27   * <a href="ServletUtil.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class ServletUtil {
32  
33      public static HttpServletRequest getRequest() {
34          MessageContext messageContext = AxisEngine.getCurrentMessageContext();
35  
36          return (HttpServletRequest)messageContext.getProperty(
37              HTTPConstants.MC_HTTP_SERVLETREQUEST);
38      }
39  
40      public static HttpServlet getServlet() {
41          MessageContext messageContext = AxisEngine.getCurrentMessageContext();
42  
43          return (HttpServlet)messageContext.getProperty(
44              HTTPConstants.MC_HTTP_SERVLET);
45      }
46  
47      public static ServletContext getServletContext() {
48          return getServlet().getServletContext();
49      }
50  
51      public static HttpSession getSession() {
52          HttpServletRequest request = getRequest();
53  
54          return request.getSession();
55      }
56  
57  }