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.portal.servlet.filters.unsyncprintwriterpool;
016    
017    import com.liferay.portal.kernel.servlet.TryFinallyFilter;
018    import com.liferay.portal.kernel.util.UnsyncPrintWriterPool;
019    import com.liferay.portal.servlet.filters.BasePortalFilter;
020    
021    import javax.servlet.http.HttpServletRequest;
022    import javax.servlet.http.HttpServletResponse;
023    
024    /**
025     * @author Shuyang Zhou
026     */
027    public class UnsyncPrintWriterPoolFilter
028            extends BasePortalFilter implements TryFinallyFilter {
029    
030            public void doFilterFinally(
031                    HttpServletRequest request, HttpServletResponse response,
032                    Object object) {
033    
034                    UnsyncPrintWriterPool.cleanUp();
035            }
036    
037            public Object doFilterTry(
038                    HttpServletRequest request, HttpServletResponse response) {
039    
040                    UnsyncPrintWriterPool.setEnabled(true);
041    
042                    return null;
043            }
044    
045    }