001    /**
002     * Copyright (c) 2000-2013 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.bridges.jsf.myfaces;
016    
017    import javax.faces.context.ResponseWriter;
018    
019    import javax.portlet.PortletContext;
020    import javax.portlet.PortletRequest;
021    import javax.portlet.PortletResponse;
022    
023    import org.apache.myfaces.context.ReleaseableExternalContext;
024    import org.apache.myfaces.context.servlet.ServletFacesContextImpl;
025    
026    /**
027     * @author Brian Myunghun Kim
028     */
029    public class MyFacesContextImpl extends ServletFacesContextImpl {
030    
031            public MyFacesContextImpl(
032                    PortletContext portletContext, PortletRequest portletRequest,
033                    PortletResponse portletResponse) {
034    
035                    super(portletContext, portletRequest, portletResponse);
036            }
037    
038            @Override
039            public ResponseWriter getResponseWriter() {
040                    return _responseWriter;
041            }
042    
043            @Override
044            public void release() {
045                    super.release();
046    
047                    _responseWriter = null;
048            }
049    
050            @Override
051            public void setExternalContext(ReleaseableExternalContext extContext) {
052                    _responseWriter = null;
053    
054                    super.setExternalContext(extContext);
055            }
056    
057            @Override
058            public void setResponseWriter(ResponseWriter responseWriter) {
059                    if (responseWriter == null) {
060                            throw new NullPointerException("responseWriter");
061                    }
062    
063                    _responseWriter = responseWriter;
064            }
065    
066            private ResponseWriter _responseWriter = null;
067    
068    }