srivaradhan
srivaradhan

Reputation: 165

Java-based container configuration for Spring Integration definition

I have previously used XML based configuration for my Spring app.

Now, I want to use ONLY Java-based container configuration using @Bean, @Configuration etc.

How do I convert these two pieces of XML configurations to Java based config?

<outbound-channel-adapter channel="emailChannel" ref="messageHandler">
    <poller>
            <interval-trigger interval="60000"/>
    </poller>
</outbound-channel-adapter>

 <tx:annotation-driven transaction-manager="transactionManager"/>

Upvotes: 5

Views: 2477

Answers (1)

Gary Russell
Gary Russell

Reputation: 174719

Unlike the simple <bean/> syntax for Spring Beans, which can easily be replaced by @Bean java configuration, the Spring Integration XML DSL provides a rich abstraction over Spring Integration components.

In order to replace the

<outbound-channel-adapter/> 

above, you would need to dig into the NamespaceHandlers, and XML parsers, to define the equivalent set of beans needed to define the equivalent @Beans. The context drives which beans are generated (for example, whether emailChannel is a subscribable, or pollable channel).

For the <tx:annotation-driven/>, the new Spring 3.1 @Enable... annotations can be used...

http://blog.springsource.org/2011/06/10/spring-3-1-m2-configuration-enhancements/

http://static.springsource.org/spring/docs/3.1.1.RELEASE/spring-framework-reference/html/new-in-3.1.html

Upvotes: 4

Related Questions