001/*
002 * Copyright 2002-2012 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.web.context.request;
018
019/**
020 * Request-backed {@link org.springframework.beans.factory.config.Scope}
021 * implementation.
022 *
023 * <p>Relies on a thread-bound {@link RequestAttributes} instance, which
024 * can be exported through {@link RequestContextListener},
025 * {@link org.springframework.web.filter.RequestContextFilter} or
026 * {@link org.springframework.web.servlet.DispatcherServlet}.
027 *
028 * <p>This {@code Scope} will also work for Portlet environments,
029 * through an alternate {@code RequestAttributes} implementation
030 * (as exposed out-of-the-box by Spring's
031 * {@link org.springframework.web.portlet.DispatcherPortlet}.
032 *
033 * @author Rod Johnson
034 * @author Juergen Hoeller
035 * @author Rob Harrop
036 * @since 2.0
037 * @see RequestContextHolder#currentRequestAttributes()
038 * @see RequestAttributes#SCOPE_REQUEST
039 * @see RequestContextListener
040 * @see org.springframework.web.filter.RequestContextFilter
041 * @see org.springframework.web.servlet.DispatcherServlet
042 * @see org.springframework.web.portlet.DispatcherPortlet
043 */
044public class RequestScope extends AbstractRequestAttributesScope {
045
046        @Override
047        protected int getScope() {
048                return RequestAttributes.SCOPE_REQUEST;
049        }
050
051        /**
052         * There is no conversation id concept for a request, so this method
053         * returns {@code null}.
054         */
055        @Override
056        public String getConversationId() {
057                return null;
058        }
059
060}