diff --git a/docs/src/reference/docbook/transformer.xml b/docs/src/reference/docbook/transformer.xml index 844ea85ce9..f18c449ab2 100644 --- a/docs/src/reference/docbook/transformer.xml +++ b/docs/src/reference/docbook/transformer.xml @@ -74,15 +74,15 @@ - Just like Routers, Aggregators and other components, since Spring Integration 2.0 Transformers can also benefit from SpEL - http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html + Just like Routers, Aggregators and other components, as of Spring Integration 2.0 Transformers can also benefit from SpEL support + (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html) whenever transformation logic is relatively simple. ]]> - In the above configuration we are achieving a simple transformation of the payload with a simple SpEL + In the above configuration we are achieving a simple transformation of the payload with a simple SpEL expression and without writing a custom transformer. Our payload (assuming String) will be upper-cased and concatenated with the current timestamp with some simple formatting. @@ -91,11 +91,13 @@ Common Transformers - There are a also a few Transformer implementations available out of the box. Because, it is fairly common + There are also a few Transformer implementations available out of the box. Because, it is fairly common to use the toString() representation of an Object, Spring Integration provides an ObjectToStringTransformer whose output is a Message with a String payload. That String - is the result of invoking the toString operation on the inbound Message's payload. + is the result of invoking the toString() operation on the inbound Message's payload. + ]]> + A potential example for this would be sending some arbitrary object to the 'outbound-channel-adapter' in the file namespace. Whereas that Channel Adapter only supports String, byte-array, or java.io.File payloads by default, adding this transformer immediately before the @@ -109,7 +111,10 @@ If you need to serialize an Object to a byte array or deserialize a byte array back into an Object, - Spring Integration provides symmetrical serialization transformers. + Spring Integration provides symmetrical serialization transformers. These will use standard Java serialization + by default, but you can provide an implementation of Spring 3.0's Serializer or Deserializer strategies via the + 'serializer' and 'deserializer' attributes, respectively. + ]]> @@ -118,10 +123,10 @@ Object-to-Map Transformer - As added convenience, Spring Integration also provides Object-to-Map and Map-to-Object transformers which - utilize Spring Expression Language (SpEL) to serialize and de-serialize the object graphs. Object hierarchy is introspected - to the most primitive types (e.g., String, int etc.). The path to this type is described via SpEL, which becomes the keykey in the - transformed Map with primitive type being the value. + Spring Integration also provides Object-to-Map and Map-to-Object transformers which + utilize the Spring Expression Language (SpEL) to serialize and de-serialize the object graphs. The object hierarchy is introspected + to the most primitive types (String, int, etc.). The path to this type is described via SpEL, which becomes the key in the + transformed Map. The primitive type becomes the value. For example: @@ -140,19 +145,19 @@ public class Child{ {person.name=George, person.child.name=Jenna, person.child.nickNames[0]=Bimbo . . . etc} - SpEL-based Map allows you to describe the object structure without sharing the actual types allowing + The SpEL-based Map allows you to describe the object structure without sharing the actual types allowing you to restore/rebuild the object graph into a differently typed Object graph as long as you maintain the structure. For example: - The above structure could be easily restored back to the following Object graph via Map-to-Object transformer: - nickNames;    // setters and getters are omitted @@ -175,14 +180,14 @@ public class Kid{ - NOTE: 'ref' and 'type' attributes are mutually exclusive. You can only use either one. - Also, if using 'ref' attribute you must point to a 'prototype' scoped bean, otherwise - BeanCreationException will be thrown.  + NOTE: 'ref' and 'type' attributes are mutually exclusive. You can only use one. + Also, if using the 'ref' attribute, you must point to a 'prototype' scoped bean, otherwise + a BeanCreationException will be thrown. 
- Configuring Transformer with Annotations + Configuring a Transformer with Annotations The @Transformer annotation can also be added to methods that expect either the Message type or the message payload type. The return value will be handled in the @@ -202,24 +207,23 @@ Order generateOrder(String productId, @Header("customerName") String customer) {
-
Header Filter - Some time your transformation use case might be as simple as removing a few headers. - For this type of use cases Spring Integration provides Header Filter which allows you to specify which header should be - removed from the output Message. - Basically Header Filter is the opposite of Header Enricher - that is discussed in + Some times your transformation use case might be as simple as removing a few headers. + For such a use case, Spring Integration provides a Header Filter which allows you to specify certain header names + that should be removed from the output Message (e.g. for security reasons or a value that was only needed temporarily). + Basically the Header Filter is the opposite of the Header Enricher. + The latter is discussed in ]]> - As you can see, configuration of Header Filter is quite simple. It is a typical endpoint with input/output channels - and header-names attribute which allows you to specify the names of the headers (delimited by coma if multiple) - that need to be removed. So, in the above example headers with the name 'lastName' and 'state' will be removed. + As you can see, configuration of a Header Filter is quite simple. It is a typical endpoint with input/output channels + and a header-names attribute. That attribute accepts the names of the header(s) (delimited by commas if there are multiple) + that need to be removed. So, in the above example the headers named 'lastName' and 'state' will not be present on the outbound Message.