Is there a way to configure Spring to invoke the "init-method" methods after the entire context has been processed. I'm running into a case where a service is started and fires events before all its listeners have been added. The listeners are added like so:
Code:
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="MyService"/>
<property name="targetMethod" value="addListener"/>
<property name="arguments">
<bean class="mypackage.MyListener"/>
</property>
</bean>
I could add them to the service via constructor or setter injection, but that would make them dependencies of my service, which doesn't seem right. Although the system depends on them being listeners of the service, the service itself doesn't depend on them.
I solved this by manually starting my service after I construct the context. It's actually more complicated than that, as there are several running services that could cause MyService to fire events. I have to ensure they are all started manually after context construction.