1

I have two different ways of declaring a spring integration bean. They both seem to work. I'm using the Spring STS Eclipse based IDE.

This way:

<bean id="int-ftp:request-handler-advice-chain"
        class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
        <property name="trapException" value="true"></property>
        <property name="onFailureExpression" value="#root"></property>
        <property name="failureChannel" ref="errorChannel"></property>
</bean>

or this way:

<int-ftp:request-handler-advice-chain>
    <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
        <property name="trapException" value="true" />
        <property name="onFailureExpression" value="#root" />
        <property name="failureChannel" ref="errorChannel" />
    </bean>
</int-ftp:request-handler-advice-chain>

Which way is better?

Gabriel Fair
  • 4,081
  • 5
  • 33
  • 54

1 Answers1

2

For the target <int-ftp:outbound-gateway> it doesn't matter. Works well, as you noticed already.

Only the difference that the second declaration is nested and the final bean is visible only from the <int-ftp:request-handler-advice-chain> context.

The first definition is top-level global bean, which is visible everywhere and can be reused from other bean as well.

You can find more info about Inner Beans in the Spring Framework.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118