Title: Soluta Signature
Agemo Cui wrote:

[snip]
The right way for you to solve your problem is to write a class to implement the interface ServiceListener.
And then add the its instance to BundleContext as follows:

bundleContext.addServiceListener(yourServiceListener);

If you want to filter the event by the service type, then create a filter String filter = "(" + org.osgi.framework.Constants.OBJECTCLASS + "=xxx.xxx.xxx.interfacename)"; and add it to the BundleContext along with your ServiceListener as follows:

bundleContext.addServiceListener(yourServiceListener, filter);

Thanks Agemo for your quick answer.
I'm going to try writing a component that implemets the ServiceListener interface, and that
registers itself as a ServiceListener in its own BundleContext (I don't know if this is "sane",
but I'm going to try it anyway) using this method:
/** This method is called when the component is activated */
    protected void activate(ComponentContext context) {
        context.getBundleContext().addServiceListener(this);
    }

I also have to check if the filter selects also classes that implement
sub-interfaces/sub-classes of the one specified in the filter.
The quickest way of doing this is to try it ;)

Thanks again.
--
Guido Spadotto
Soluta.net, Italy
http://www.soluta.net


Reply via email to