You're already using DS to implement these components, so why don't you just bind to the services you need using <reference> elements?
Is there something extra special that you need to do with the service events besides simply using the service? If not, then you're using an approach which is about 1000 times more complicated than it needs to be. Regards, Neil On Wed, Jun 3, 2009 at 10:48 PM, Guido Spadotto <[email protected]> wrote: > 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 > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

