From 67f8ea1336629fe66b7d3288cef786a2071a7cd3 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 28 Apr 2014 21:46:48 +0300 Subject: [PATCH] INT-3375: Docs for Messaging Annotations JIRA: https://jira.spring.io/browse/INT-3375 INT-3375 Doc Polishing --- src/reference/docbook/configuration.xml | 143 ++++++++++++++++++++++-- src/reference/docbook/whats-new.xml | 29 +++++ 2 files changed, 164 insertions(+), 8 deletions(-) diff --git a/src/reference/docbook/configuration.xml b/src/reference/docbook/configuration.xml index 081641b2f7..9cc9a234c1 100644 --- a/src/reference/docbook/configuration.xml +++ b/src/reference/docbook/configuration.xml @@ -231,6 +231,8 @@ public class FooService { @Splitter @Transformer @InboundChannelAdapter + @BridgeFrom + @BridgeTo The behavior of each is described in its own chapter or section within @@ -310,11 +312,6 @@ public class FooService { } } - That provides a pure annotation-driven alternative to the XML configuration. However, it is generally recommended - to use XML for the endpoints, since it is easier to keep track of the overall configuration in a single, external - location (and besides the namespace-based XML configuration is not very verbose). If you do prefer to provide - channels with the annotations however, you just need to enable a SI Annotations BeanPostProcessor. The following element should - be added: ]]> The processing of these annotations creates the same beans (AbstractEndpoints and @@ -432,9 +429,139 @@ public String foo() { The first example requires that the default poller has been declared elsewhere in the application context. - - Also see . - +
+ Messaging Meta-Annotations + + Starting with version 4.0, all Messaging Annotations can be configured as + meta-annotations and all user-defined Messaging Annotations can define the same attributes + to override their default values. In addition, meta-annotations can be configured hierarchically: + + This allows users to set defaults for various attributes and enables isolation of + framework Java dependencies to user annotations, avoiding their use in user classes. + If the framework finds a method with a user annotation that has a framework meta-annotation, + it is treated as if the method was annotated directly with the framework annotation. + +
+
+ Annotations on @Beans + + Starting with version 4.0, Messaging Annotations can be configured on + @Bean method definitions in @Configuration classes, + to produce Message Endpoints based on the beans, not methods. It is useful when @Bean + definitions are "out of the box" + MessageHandlers (AggregatingMessageHandler, + DefaultMessageSplitter etc.), Transformers + (JsonToObjectTransformer, ClaimCheckOutTransformer etc.), + MessageSources (FileReadingMessageSource, + RedisStoreMessageSource etc.): + consoleSource() { + return CharacterStreamReadingMessageSource.stdin(); + } + + @Bean + @Transformer(inputChannel = "inputChannel", outputChannel = "httpChannel") + public ObjectToMapTransformer toMapTransformer() { + return new ObjectToMapTransformer(); + } + + @Bean + @ServiceActivator(inputChannel = "httpChannel") + public MessageHandler httpHandler() { + HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://foo/service"); + handler.setExpectedResponseType(String.class); + handler.setOutputChannelName("outputChannel"); + return handler; + } + + @Bean + @ServiceActivator(inputChannel = "outputChannel") + public LoggingHandler loggingHandler() { + return new LoggingHandler("info"); + } + +}]]> + The meta-annotation rules work on @Bean methods as well + (@MyServiceActivator above can be applied to a @Bean definition). + + When using these annotations on consumer @Bean definitions, if the bean definition + returns an appropriate MessageHandler (depending on the + annotation type), attributes such as outputChannel, requiresReply etc, must + be set on the @Bean itself. The only annotation + attributes used are adviceChain, autoStartup, inputChannel, phase, poller, all + other attributes are for the handler. + + + When using these annotations on @Bean definitions, the inputChannel + must reference a declared bean; channels are not automatically declared in this case. + + +
+
+ Creating a Bridge with Annotations + + Starting with version 4.0, the Messaging Annotation and Java configuration provides + @BridgeFrom and @BridgeTo @Bean method + annotations to mark MessageChannel beans in + @Configuration classes. This is just for completeness, providing + a convenient mechanism to declare a + BridgeHandler and its Message Endpoint configuration: + + These annotations can be used as meta-annotations as well. + +
+
+ Advising Annotated Endpoints + + See . + +
diff --git a/src/reference/docbook/whats-new.xml b/src/reference/docbook/whats-new.xml index 349ace4e79..521c2f1249 100644 --- a/src/reference/docbook/whats-new.xml +++ b/src/reference/docbook/whats-new.xml @@ -193,6 +193,26 @@ .
+
+ @BridgeFrom and @BridgeTo Annotations + + Annotation and Java configuration has introduced @BridgeFrom and + @BridgeTo @Bean method annotations to mark + MessageChannel beans in + @Configuration classes. + For more information, see . + +
+
+ Meta Messaging Annotations + + Messaging Annotations (@ServiceActivator, @Router, + @MessagingGateway etc.) can now be configured as meta-annotations for user-defined + Messaging Annotations. In addition the user-defined annotations can have the same attributes + (inputChannel, @Poller, autoStartup etc.). + For more information, see . + +
@@ -350,5 +370,14 @@ See for more information.
+
+ Messaging Annotations on @Bean Definitions + + Messaging Annotations (@ServiceActivator, @Router, + @InboundChannelAdapter etc.) can now be configured on @Bean + definitions in @Configuration classes. + For more information, see . + +