001    /**
002     * Copyright (c) 2000-2011 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.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(PortletContext portletContext,
032                                                              PortletRequest portletRequest,
033                                                              PortletResponse portletResponse) {
034    
035                    super(portletContext, portletRequest, portletResponse);
036            }
037    
038            @Override
039            public void setResponseWriter(ResponseWriter responseWriter) {
040                    if (responseWriter == null) {
041                            throw new NullPointerException("responseWriter");
042                    }
043    
044                    _responseWriter = responseWriter;
045            }
046    
047            @Override
048            public ResponseWriter getResponseWriter() {
049                    return _responseWriter;
050            }
051    
052            @Override
053            public void release() {
054                    super.release();
055    
056                    _responseWriter = null;
057            }
058    
059            @Override
060            public void setExternalContext(ReleaseableExternalContext extContext) {
061                    _responseWriter = null;
062    
063                    super.setExternalContext(extContext);
064            }
065    
066            private ResponseWriter _responseWriter = null;
067    
068    }