001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }