@Processor
public Object myMethod(@Payload Object payload, @InvocationHeaders("*") Map<?, ?> headers) {
Injecting the Payload
Used on components, this annotation marks the method parameter that will be used to pass in the message payload. Note that they parameter type will be used to do any auto conversions using the transformer available inside the Mule container. Mule has a number of standard transformers for dealing with common, Java types such as XML documents, streams, byte array, strings, etc. It is also very easy for users to define their own Transformations.
Restrictions
A method annotate with @Processor
can have at most one parameter annotated with @Payload
, @InboundHeaders
, @InvocationHeader
or @OutboundHeaders
.
For example this is not possible:
Examples
Inject the payload without specifying the type:
@Processor
public Object myMethod(@Payload Object payload) {
// code here
return payload;
}
Inject the payload which is of type byte []
and return a java.lang.String
@Processor
public String myMethod(@Payload byte[] payload) {
// code here
return new String(payload);
}