4

I have an OSGi service that references other services via declarative service injecting them. I would like to be notified when referenced service's properties update. I don't want my main service to stop every time a configuration changes in a referenced service so I've set the policy to "dynamic".

oconnor0
  • 3,154
  • 6
  • 34
  • 52

1 Answers1

4

There is a new feature coming in DS 1.2.

An updated attribute on the reference element is added to name a method to receive services updates for bound references.

This will be part of the forthcoming Compendium 4.3 spec. It is already implemented in the DS implementation at Equinox (version 1.4.0 of the DS bundle). You must use the http://www.osgi.org/xmlns/scr/v1.2.0 namespace in your component description to use the updated attribute. updated methods use the same method signatures as bind and unbind methods.

BJ Hargrave
  • 9,324
  • 1
  • 19
  • 27
  • Wonderful. It'll be interesting to see how PDE's Component Definition editor clobbers `updated` attributes. I'll check this out tomorrow. Thanks. – oconnor0 Feb 24 '12 at 05:33
  • Unfortunately, it would appear that Equinox DS 1.4.0 is not present in Indigo. – oconnor0 Feb 24 '12 at 17:42
  • @oconnor0 Eclipse releases are just once a year... why not just use the higher version of DS? – Neil Bartlett Feb 27 '12 at 00:51
  • @Neil Bartlett 1.) Because I have no idea how to upgrade just DS. 2.) I have even less of an idea how to do it in Tycho. 3.) This is kind of a low priority; I'd already written a workaround. But, if you know how to and/or have links on upgrading DS, I am interested. – oconnor0 Feb 28 '12 at 00:11