1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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  }