Results 1 to 4 of 4

Thread: Using transformer element to create a standalone transformer bean instead of endpoit

Threaded View

  1. #1
    Join Date
    Nov 2010
    Location
    St-Petersburg, Russia
    Posts
    33

    Question Using transformer element to create a standalone transformer bean instead of endpoit

    Hello.

    Is there any way to use "transformer" element to create a standalone transformer bean but not an end point connected to channels?

    Consider I'd like to replace character 'A' with 'B' in string payload. When I'm in <chain> i can do it like this:
    Code:
    <int:chain input-channel="..." output-channel="...">
        ...
        <int:transformer expression="payload.replace('A', 'B')" />
        ...
    </int:chain>
    But if I want to reuse that transformer in several chains, I have to create manually transformer and SpEL expression instance! It looks awful :
    Code:
    <bean id="spelParser" class="org.springframework.expression.spel.standard.SpelExpressionParser" />
    <bean id="replaceABtransformer" class="org.springframework.integration.transformer.ExpressionEvaluatingTransformer">
        <constructor-arg name="expression">
            <bean factory-bean="spelParser" factory-method="parseExpression">
                <constructor-arg name="expressionString" value="payload.replace('A', 'B')" />
            </bean>
        </constructor-arg>
    </bean>
    
    <int:chain input-channel="..." output-channel="...">
        ...
        <int:transformer ref="replaceABtransformer" />
        ...
    </int:chain>
    Regards,
    -- Alexey
    Last edited by Alexey Pomelov; Jan 11th, 2013 at 07:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •