2

I have a system declaring services "the old way", using activator methods.

Now I'm writing a new bundle using Declarative Services. Is it possible to reference a service that is not published using the Declarative Services technique in my new bundle?

  • 1
    Have you tried it? I don't see why that should be a problem. – Björn Pollex Apr 16 '12 at 08:34
  • Yes I tried it. I saw the services in the Service Registry, but I didn't get any calls to my bind/unbind-methods. When I implemented an activator I worked instantly. I didn't have time to dig in to this too much now, but I guess it's just a stupid error. Now I at least know it SHOULD work. – Mathias Larsson Apr 18 '12 at 07:16
  • Could you provide your Declarative Services descriptor? It could contain an error in references definition. – Dmytro Pishchukhin Apr 18 '12 at 16:53
  • 1
    No, unfortunately I can't, but when I look at it now I see a very probable error in the Implementation Class field. :-) – Mathias Larsson Apr 19 '12 at 07:32

2 Answers2

3

There is no "the old way" to publish you services into OSGi Service Registry. There is only one way with BundleContext.registerService(). You can do it manually from you activator, or Declarative Services / Blueprint engines can do it for you.

In your DS descriptor you just define references to services that are available in Service Registry.

Dmytro Pishchukhin
  • 2,369
  • 1
  • 14
  • 19
3

Yes, it is possible. When you reference a service from a DS component, you don't need to worry about that service's internal implementation.

The other service may be another DS component, or it may be a Spring-DM component, or it may be published with explicit calls to the OSGi APIs. You don't care. It's just a service.

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77