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.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            @Override
031            public void doFilterFinally(
032                    HttpServletRequest request, HttpServletResponse response,
033                    Object object) {
034    
035                    UnsyncPrintWriterPool.cleanUp();
036            }
037    
038            @Override
039            public Object doFilterTry(
040                    HttpServletRequest request, HttpServletResponse response) {
041    
042                    UnsyncPrintWriterPool.setEnabled(true);
043    
044                    return null;
045            }
046    
047    }