001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.util.axis;
016    
017    import javax.servlet.ServletContext;
018    import javax.servlet.http.HttpServlet;
019    import javax.servlet.http.HttpServletRequest;
020    import javax.servlet.http.HttpSession;
021    
022    import org.apache.axis.AxisEngine;
023    import org.apache.axis.MessageContext;
024    import org.apache.axis.transport.http.HTTPConstants;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class ServletUtil {
030    
031            public static HttpServletRequest getRequest() {
032                    MessageContext messageContext = AxisEngine.getCurrentMessageContext();
033    
034                    return (HttpServletRequest)messageContext.getProperty(
035                            HTTPConstants.MC_HTTP_SERVLETREQUEST);
036            }
037    
038            public static HttpServlet getServlet() {
039                    MessageContext messageContext = AxisEngine.getCurrentMessageContext();
040    
041                    return (HttpServlet)messageContext.getProperty(
042                            HTTPConstants.MC_HTTP_SERVLET);
043            }
044    
045            public static ServletContext getServletContext() {
046                    return getServlet().getServletContext();
047            }
048    
049            public static HttpSession getSession() {
050                    HttpServletRequest request = getRequest();
051    
052                    return request.getSession();
053            }
054    
055    }