Reputation: 9159
Suppose I have this class:
public class MyClass {
public String myMethod() {
//...
}
}
What I want is when my application starts, to send the result that myMethod()
returns to a certain channel in Spring Integration. What I have tried:
<bean id="myClass" class="myPackage.MyClass"/>
<int:inbound-channel-adapter channel="channelINeedToSendTo" ref="myClass" method="myMethod">
<int:poller cron=""/> <!-- poller configuration -->
</int:inbound-channel-adapter>
Now what can I configure in poller is to call myMethod()
at a certain time, on regularly on a certain scheduling, but I wanted to be run exactly after the application started (something like @PostConstruct
). Is there a simple way achieving this, without complicated AOP techniques?
Upvotes: 1
Views: 2868
Reputation: 174779
You can add an Event Inbound Channel Adapter to capture the ContextRefreshedEvent
Application Event; then wire that adapter to a <service-activator/>
that invokes myMethod()
; the result will be on the output-channel
.
Upvotes: 2