PDA

View Full Version : injection with ServiceActivator



waki41
Dec 23rd, 2009, 06:03 AM
Hi,
I'm new to Spring Integration.
I'm just wondering if I could inject something to the pojo which has @ServiceActivator.

If I understand correctoly, It looks like @ServiceActivator method is called by reflection, which means the pojo is not spring-managed.

Let me know If I'm wrong.

By the way, I just want to do like this



@MessageEndPoint
public class SomeBean {

@Autowired
private SomeDao someDao;

@ServiceActivator
private void someMethod(SomeBean bean) {
// do something
someDao.insert(bean);
}
}


Thanks in advance

Shige

chudak
Dec 23rd, 2009, 09:08 AM
Yes, your example will work. I have a service activator that looks very similar to that.

You just need to make sure that you have added both the generic spring annotation post processor as well as the SI annotation post processors to your spring config and the component scanner:




<context:component-scan base-package="com.yourpackage."/>
<context:annotation-config/>
<integration:annotation-config/>

waki41
Dec 23rd, 2009, 09:34 AM
Hi, chudak

Thanks, I'll try it :)

Shige