The Source
interface defines a single method for receiving
Message
objects.
public interface Source<T> { Message<T> receive(); }
Spring Integration also provides a MethodInvokingSource
implementation that serves as an
adapter for invoking any arbitrary method on a plain Object (i.e. there is no need to implement an interface).
To use the MethodInvokingSource
, provide the Object reference and the method name.
MethodInvokingSource source = new MethodInvokingSource(); source.setObject(new SourceObject()); source.setMethod("sourceMethod"); Message<?> result = source.receive();
It is generally more common to configure a MethodInvokingSource
in XML by providing a
bean reference.
<source-adapter id="source" ref="sourceObject" method="sourceMethod"/>