View Javadoc
1   /*
2    * Copyright 2002-2015 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.messaging.handler.invocation;
18  
19  import org.springframework.core.MethodParameter;
20  import org.springframework.messaging.Message;
21  
22  /**
23   * Strategy interface for resolving method parameters into argument values
24   * in the context of a given {@link Message}.
25   *
26   * @author Rossen Stoyanchev
27   * @since 4.0
28   */
29  public interface HandlerMethodArgumentResolver {
30  
31  	/**
32  	 * Whether the given {@linkplain MethodParameter method parameter} is
33  	 * supported by this resolver.
34  	 * @param parameter the method parameter to check
35  	 * @return {@code true} if this resolver supports the supplied parameter;
36  	 * {@code false} otherwise
37  	 */
38  	boolean supportsParameter(MethodParameter parameter);
39  
40  	/**
41  	 * Resolves a method parameter into an argument value from a given message.
42  	 * @param parameter the method parameter to resolve.
43  	 * This parameter must have previously been passed to
44  	 * {@link #supportsParameter(org.springframework.core.MethodParameter)}
45  	 * which must have returned {@code true}.
46  	 * @param message the currently processed message
47  	 * @return the resolved argument value, or {@code null}
48  	 * @throws Exception in case of errors with the preparation of argument values
49  	 */
50  	Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception;
51  
52  }