1
votes

I'm a newbie with Spring MVC but now i've been moved to a new project which uses Spring Integration to turn in channel some service. Example in the context.xml

<int:channel id="example-channel" />
    <int:service-activator input-channel="example-channel" ref="exampleServiceFacade" />

For every servicefacade i have to bind the service to a channel.

I was wandering, what if I could map the classes to be turned into channels as i could map the beans with component-scan?

<context:component-scan base-package="com.package" />

so i ended up with this tutorial which speaks about some annotation:

@IntegrationComponentScan

But i cannot understand how it's related to the xml tag service activator and channel.. So i'm quite confused. Does anyone with more experience have an idea if what i'm trying to do can be done?

I just want to scan con the classes which defines channels in integration without having to declare every class.

Thanks.

1

1 Answers

2
votes

Your question is a bit unclear. Any Spring Integration custom XML tag is parsed by infrastructure and registered as beans in the application context. Like you'd do that via raw <bean>.

@ComponentScan, @Configuration, @Bean and so on are marker annotations to say application context which classes treat as beans.

So, using both techniques for application context configuration you don't lose anything and can continue to mark you class with @Service and use its bean name from <service-activator ref="">.

From other side now you can fully build Spring Integration without any XML! Please, read the mentioned doc in its entirety.