Spring Framework

org.springframework.web.method.support
Class HandlerMethodReturnValueHandlerComposite

java.lang.Object
  extended by org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite
All Implemented Interfaces:
HandlerMethodReturnValueHandler

public class HandlerMethodReturnValueHandlerComposite
extends java.lang.Object
implements HandlerMethodReturnValueHandler

Handles method return values by delegating to a list of registered HandlerMethodReturnValueHandlers. Previously resolved return types are cached for faster lookups.

Since:
3.1
Author:
Rossen Stoyanchev

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
HandlerMethodReturnValueHandlerComposite()
           
 
Method Summary
 HandlerMethodReturnValueHandlerComposite addHandler(HandlerMethodReturnValueHandler returnValuehandler)
          Add the given HandlerMethodReturnValueHandler.
 HandlerMethodReturnValueHandlerComposite addHandlers(java.util.List<? extends HandlerMethodReturnValueHandler> returnValueHandlers)
          Add the given HandlerMethodReturnValueHandlers.
 java.util.List<HandlerMethodReturnValueHandler> getHandlers()
          Return a read-only list with the registered handlers, or an empty list.
 void handleReturnValue(java.lang.Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
          Iterate over registered HandlerMethodReturnValueHandlers and invoke the one that supports it.
 boolean supportsReturnType(MethodParameter returnType)
          Whether the given method return type is supported by any registered HandlerMethodReturnValueHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

HandlerMethodReturnValueHandlerComposite

public HandlerMethodReturnValueHandlerComposite()
Method Detail

getHandlers

public java.util.List<HandlerMethodReturnValueHandler> getHandlers()
Return a read-only list with the registered handlers, or an empty list.


supportsReturnType

public boolean supportsReturnType(MethodParameter returnType)
Whether the given method return type is supported by any registered HandlerMethodReturnValueHandler.

Specified by:
supportsReturnType in interface HandlerMethodReturnValueHandler
Parameters:
returnType - the method return type to check
Returns:
true if this handler supports the supplied return type; false otherwise

handleReturnValue

public void handleReturnValue(java.lang.Object returnValue,
                              MethodParameter returnType,
                              ModelAndViewContainer mavContainer,
                              NativeWebRequest webRequest)
                       throws java.lang.Exception
Iterate over registered HandlerMethodReturnValueHandlers and invoke the one that supports it.

Specified by:
handleReturnValue in interface HandlerMethodReturnValueHandler
Parameters:
returnValue - the value returned from the handler method
returnType - the type of the return value. This type must have previously been passed to HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter) and it must have returned true
mavContainer - the ModelAndViewContainer for the current request
webRequest - the current request
Throws:
java.lang.IllegalStateException - if no suitable HandlerMethodReturnValueHandler is found.
java.lang.Exception - if the return value handling results in an error

addHandler

public HandlerMethodReturnValueHandlerComposite addHandler(HandlerMethodReturnValueHandler returnValuehandler)
Add the given HandlerMethodReturnValueHandler.


addHandlers

public HandlerMethodReturnValueHandlerComposite addHandlers(java.util.List<? extends HandlerMethodReturnValueHandler> returnValueHandlers)
Add the given HandlerMethodReturnValueHandlers.


Spring Framework