Reputation: 2183
Is possible add a Listener to know when a Bean Service with a particular Interface is created. And when the bean with the same interface is destroyed???
What is the best way to do it? reading the list of injecting services
<reference-list
id="javoraiConceptProcessList"
interface="com.api.MyTask"
availability="optional"
></reference-list>
What is the way to know when the list values is changed?
I am using Gemini Blueprint(Spring)
Upvotes: 0
Views: 1174
Reputation: 19606
See the blueprint documentation at IBM.
This is how to do it (below). So you specify bind and unbind methods on a bean that will be called.
public class ReferenceListener {
public void bind(ServiceReference reference) {
...
}
public void bind(Serializable service) {
...
}
public void unbind(ServiceReference reference) {
...
}
}
<reference-list id=”serviceReferenceListTwo” interface=”java.io.Serializable”
availability=”optional”>
<reference-listener
bind-method=”bind” unbind-method=”unbind”>
<bean class=“org.apache.geronimo.osgi.ReferenceListener”/>
</reference-listener>
</reference-list>
Upvotes: 1