INT-1516 added docs for service-activator and SpEL

This commit is contained in:
Oleg Zhurakousky
2010-11-12 10:01:44 -05:00
parent 0dd3184f24
commit f48624f603

View File

@@ -66,6 +66,35 @@
configuration is not allowed, as it creates an ambiguous condition and will result in an Exception being thrown.
</para>
</note>
<para>
<emphasis>Service Activators and Spring Expression Language (SpEL)</emphasis>
</para>
<para>
Since Spring Integration 2.0 Service Activators can also benefit from SpEL ()http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html
in several ways.
</para>
<para>
First, you may now invoke any bean method without pointing to this bean via <code>ref</code> attribute or including it as an
inner definition. For example:
<programlisting language="xml"><![CDATA[<int:service-activator input-channel="in" output-channel="out"
expression="@accountService.processAccount(payload)"/>
<bean id="accountService" class="foo.bar.Account"/>]]></programlisting>
In the above configuration instead of injecting 'accountService' using <code>ref</code> or as inner bean we are simply using <code>@beanId</code>
notation and invoking a method which takes the type compatible with Message payload.
For simple scenarios your <emphasis>Service Activators</emphasis> do not even have to reference a bean if all logic can be encapsulated
by such expression.
<programlisting language="xml"><![CDATA[<int:service-activator input-channel="in" output-channel="out" expression="payload * 2"/>]]></programlisting>
In the above configuration our service logic is to simply multiply the payload value by 2 and SpEL lets us handle it relatively easy.
</para>
</section>
</section>