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.kernel.servlet;
016    
017    import java.util.Collections;
018    import java.util.HashSet;
019    import java.util.Set;
020    
021    import javax.servlet.http.HttpServletRequest;
022    import javax.servlet.http.HttpServletRequestWrapper;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class TrackedServletRequest extends HttpServletRequestWrapper {
028    
029            public TrackedServletRequest(HttpServletRequest request) {
030                    super(request);
031            }
032    
033            public Set<String> getSetAttributes() {
034                    if (_setAttributes == null) {
035                            return Collections.emptySet();
036                    }
037                    else {
038                            return _setAttributes;
039                    }
040            }
041    
042            @Override
043            public void setAttribute(String name, Object obj) {
044                    if (_setAttributes == null) {
045                            _setAttributes = new HashSet<String>();
046                    }
047    
048                    _setAttributes.add(name);
049    
050                    super.setAttribute(name, obj);
051            }
052    
053            private Set<String> _setAttributes;
054    
055    }