001/*
002 * Copyright 2002-2015 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.servlet.mvc.annotation;
018
019import java.lang.reflect.Method;
020
021import org.springframework.lang.Nullable;
022import org.springframework.ui.ExtendedModelMap;
023import org.springframework.web.context.request.NativeWebRequest;
024import org.springframework.web.servlet.ModelAndView;
025
026/**
027 * SPI for resolving custom return values from a specific handler method.
028 * Typically implemented to detect special return types, resolving
029 * well-known result values for them.
030 *
031 * <p>A typical implementation could look like as follows:
032 *
033 * <pre class="code">
034 * public class MyModelAndViewResolver implements ModelAndViewResolver {
035 *
036 *     public ModelAndView resolveModelAndView(Method handlerMethod, Class handlerType,
037 *             Object returnValue, ExtendedModelMap implicitModel, NativeWebRequest webRequest) {
038 *         if (returnValue instanceof MySpecialRetVal.class)) {
039 *             return new MySpecialRetVal(returnValue);
040 *         }
041 *         return UNRESOLVED;
042 *     }
043 * }</pre>
044 *
045 * @author Arjen Poutsma
046 * @since 3.0
047 */
048public interface ModelAndViewResolver {
049
050        /**
051         * Marker to be returned when the resolver does not know how to handle the given method parameter.
052         */
053        ModelAndView UNRESOLVED = new ModelAndView();
054
055
056        ModelAndView resolveModelAndView(Method handlerMethod, Class<?> handlerType,
057                        @Nullable Object returnValue, ExtendedModelMap implicitModel, NativeWebRequest webRequest);
058
059}