You can by having using the event strategy for your reference, i.e. having (suitably annotated) bind/unbind methods. I don’t think there’s any way to predict whether the field is updated before or after the bind/unbind method is called, so I would not have an annotated field but use the event method to update the field yourself. The modified method is called when the configuration for a component is changed, and an updated method is called when the configuration for the reference is changed; I do t think you’ve mentioned any of your comments using configuration.
David Jencks Sent from my iPhone > On Mar 7, 2019, at 4:31 PM, Xtra Coder <[email protected]> wrote: > > Thanks very much, I was able to make first step with your hints. > > Second step is - How to get notification about change in the set of > provisioned references? > > I've crafted test project from Karaf examples here ... > https://github.com/xtracoder/karaf-experimental/blob/master/examples/karaf-scr-example/karaf-scr-example-client/src/main/java/org/apache/karaf/examples/scr/client/ConsoleClient.java#L38 > > When i stop/start one of the MyApi-implementation bundles, 'implementations' > field do being updated as traced by background thread, but none of the > `implementationsUpdated()` or `modified()` gets called. > > Can I somehow get that notification from the OSGI framework about change of > the 'implementations' field? > > Sample code: > - - - - - - > > @Reference(service = MyApi.class > , cardinality = ReferenceCardinality.MULTIPLE > , policy = ReferencePolicy.DYNAMIC > , policyOption = GREEDY > , fieldOption = FieldOption.UPDATE > , updated = "implementationsModified" > ) > private List<MyApi> implementations; > > > public void implementationsUpdated() throws Exception { > > System.out.println("-------------------------------------------------------------------- > updat = " + instanceId + ": " + implementations); > running = false; > } > > @Modified > public void modified() throws Exception { > > System.out.println("-------------------------------------------------------------------- > modif = " + instanceId + ": " + implementations); > running = false; > } > > > > > > > -- > Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
