To answer my own question… It looks like it may be easier to just use a ServiceTracker, which gets instantiated in the @Activate method. That way there are no timing issues.
Cheers, =David > On Jul 18, 2018, at 9:33, David Leangen <[email protected]> wrote: > > > Hi Clément, > > Thanks for your reply. > > The problem here is that the Items are dynamic, which means that they can > come and go at any time, even before the MyExecutor. :-( > This happens regardless of the order, and that is exactly my problem. > > > Cheers, > =David > > > >> On Jul 18, 2018, at 7:59, Clément Delgrange via osgi-dev >> <[email protected] <mailto:[email protected]>> wrote: >> >> Hi David, >> >> From the spec I read: >> >> > 112.5.10 Binding Services >> > >> > When binding services, the references are processed in the order in which >> > they are specified in the component description. That is, target services >> > from the first specified reference are bound before services from the next >> > specified reference. >> >> So, I understand that if your executor comes before yours items reference in >> the component declaration you have the garantee that the executor will be >> bounded before your items. >> >> Cheers, >> Clément. >> >> >> >> >> -------- Message d'origine -------- >> On 18 juil. 2018 à 00:16, David Leangen via osgi-dev < >> [email protected] <mailto:[email protected]> > a écrit : >> >> >> Hi! >> >> I have a component that acts a bit like a whiteboard provider. It looks >> something like this: >> >> public class MyWhiteboard >> { >> boolean isActive; >> >> @Reference MyExecutor executor; // Required service to execute on an Item >> >> @Reference(multiple/dynamic) >> void bindItem( Item item ) >> { >> if (isActivated) >> // add the Item >> else >> // Store the item to be added once this component is activated >> } >> >> void unbindItem( Item item ) >> { >> // Remove the item >> } >> >> @Activate >> void activate() >> { >> // execute non-processed Items >> isActivate = true; >> } >> } >> >> The MyExecutor must be present before an Item can be processed, but there is >> no guarantee as to the binding order. All I can think of doing is ensuring >> that the Component is Activated before processing. >> >> My question is: is there a more elegant / simpler / less error prone way of >> accomplishing this? >> >> >> Thanks! >> =David >> >> >> _______________________________________________ >> OSGi Developer Mail List >> [email protected] <mailto:[email protected]> >> https://mail.osgi.org/mailman/listinfo/osgi-dev >> <https://mail.osgi.org/mailman/listinfo/osgi-dev> >> _______________________________________________ >> OSGi Developer Mail List >> [email protected] >> https://mail.osgi.org/mailman/listinfo/osgi-dev >
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
