org.springframework.integration.handler.annotation
Class AnnotationMethodMessageMapper

java.lang.Object
  extended by org.springframework.integration.handler.annotation.AnnotationMethodMessageMapper
All Implemented Interfaces:
MessageMapper

public class AnnotationMethodMessageMapper
extends java.lang.Object
implements MessageMapper

A MessageMapper implementation for annotated handler methods. Method parameters are matched against the Message payload as well as its header attributes and properties. If a method parameter is annotated with @HeaderAttribute or @HeaderProperty, the annotation's value will be used as an attribute/property key. If such an annotation contains no value, then the parameter name will be used as long as the information is available in the class file (requires compilation with debug settings for parameter names). If neither annotation is present, then the parameter will typically match the Message payload. However, if a Map or Properties object is expected, and the paylaod is not itself assignable to that type, then the MessageHeader attributes will be passed in the case of a Map-typed parameter, or the MessageHeader properties will be passed in the case of a Properties-typed parameter.

Author:
Mark Fisher

Nested Class Summary
private static class AnnotationMethodMessageMapper.MethodParameterMetadata
           
 
Field Summary
private  java.lang.Object initializationMonitor
           
private  boolean initialized
           
private  java.lang.reflect.Method method
           
private  AnnotationMethodMessageMapper.MethodParameterMetadata[] parameterMetadata
           
private  org.springframework.core.ParameterNameDiscoverer parameterNameDiscoverer
           
 
Constructor Summary
AnnotationMethodMessageMapper(java.lang.reflect.Method method)
           
 
Method Summary
private  java.util.Map<java.lang.String,java.lang.Object> getHeaderAttributes(Message<?> message)
           
private  java.util.Properties getHeaderProperties(Message<?> message)
           
 void initialize()
           
 java.lang.Object[] mapMessage(Message message)
          Map from the given Message to an Object.
private  java.lang.String resolveParameterNameIfNecessary(java.lang.String paramName, org.springframework.core.MethodParameter methodParam)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameterNameDiscoverer

private org.springframework.core.ParameterNameDiscoverer parameterNameDiscoverer

method

private final java.lang.reflect.Method method

parameterMetadata

private AnnotationMethodMessageMapper.MethodParameterMetadata[] parameterMetadata

initialized

private volatile boolean initialized

initializationMonitor

private final java.lang.Object initializationMonitor
Constructor Detail

AnnotationMethodMessageMapper

public AnnotationMethodMessageMapper(java.lang.reflect.Method method)
Method Detail

initialize

public void initialize()

mapMessage

public java.lang.Object[] mapMessage(Message message)
Description copied from interface: MessageMapper
Map from the given Message to an Object.

Specified by:
mapMessage in interface MessageMapper

getHeaderAttributes

private java.util.Map<java.lang.String,java.lang.Object> getHeaderAttributes(Message<?> message)

getHeaderProperties

private java.util.Properties getHeaderProperties(Message<?> message)

resolveParameterNameIfNecessary

private java.lang.String resolveParameterNameIfNecessary(java.lang.String paramName,
                                                         org.springframework.core.MethodParameter methodParam)