INT-3365: Add SmartLifecycle for Annotations

JIRA: https://jira.spring.io/browse/INT-3365

INT-3365 Polishing
This commit is contained in:
Artem Bilan
2014-04-10 15:08:42 +03:00
committed by Gary Russell
parent 55c4e26619
commit 3f40c40641
11 changed files with 131 additions and 16 deletions

View File

@@ -317,13 +317,28 @@ public class FooService {
be added: <programlisting language="xml"><![CDATA[<int:annotation-config/>]]></programlisting>
</para>
<para>
The processing of these annotations creates the same beans (<classname>EventDrivenConsumer</classname>s and
<interfacename>MessageHandler</interfacename>s) as with similar xml components. The bean names are generated
with this pattern:
<code>[componentName].[methodName].[annotationClassShortName]</code> for the <classname>EventDrivenConsumer</classname>
endpoint and the same name with an additional <code>.handler</code> suffix for
the <interfacename>MessageHandler</interfacename> bean. The
<interfacename>MessageHandler</interfacename>s are also eligible to be tracked by <xref linkend="message-history"/>.
The processing of these annotations creates the same beans (<classname>AbstractEndpoint</classname>s and
<interfacename>MessageHandler</interfacename>s (or <interfacename>MessageSource</interfacename>s for the
inbound channel adapter - see below) as with
similar xml components. The bean names are generated with this pattern:
<code>[componentName].[methodName].[decapitalizedAnnotationClassShortName]</code> for the
<classname>AbstractEndpoint</classname> and the same name with an additional <code>.handler</code>
(<code>.source</code>) suffix for the <interfacename>MessageHandler</interfacename>
(<interfacename>MessageSource</interfacename>) bean. The <interfacename>MessageHandler</interfacename>s
(<interfacename>MessageSource</interfacename>s) are also eligible to be tracked by
<xref linkend="message-history"/>.
</para>
<para>
Starting with <emphasis>version 4.0</emphasis>, all Messaging Annotations provide
<interfacename>SmartLifecycle</interfacename> options - <code>autoStartup</code> and <code>phase</code> to
allow endpoint lifecycle control on application context initialization.
They default to <code>true</code> and <code>0</code> respectively.
To change the state of an endpoint (e.g
<code>start()/stop()</code>) obtain a reference to the endpoint bean using the
<interfacename>BeanFactory</interfacename> (or autowiring) and invoke the method(s),
or send a <emphasis>command message</emphasis> to the
<code>Control Bus</code> (<xref linkend="control-bus"/>). For these purposes you should use the
<code>beanName</code> mentioned above.
</para>
<para>
<emphasis role="bold">@Poller</emphasis>

View File

@@ -155,10 +155,11 @@
</para>
</section>
<section id="4.0-inbound-channel-adapter-annotation">
<title>@InboundChannelAdapter</title>
<title>@InboundChannelAdapter and SmartLifecycle for Annotated Endpoints</title>
<para>
The <interfacename>@InboundChannelAdapter</interfacename> method annotation is now available.
It is an analogue of the <code>&lt;int:inbound-channel-adapter&gt;</code> XML component.
In addition, all Messaging Annotations now provide <interfacename>SmartLifecycle</interfacename> options.
For more information, see <xref linkend="annotations"/>.
</para>
</section>