Одна вещь, о которой необходимо знать, когда размышляющий над членами парламента, не занимающими официального поста то, что, если приложение работает в среднем доверии (как, например, при работе общей среды хостинга), она не найдет их - BindingFlags. Опция NonPublic будет просто проигнорирована.
The best way of prioritizing OSGi services to use SERVICE_RANKING service property. This property may be supplied in the properties
object passed to the
BundleContext.registerService() method.
According to the documentation of the BundleContext.getServiceReference() method:
If multiple such services exist, the service with the highest ranking (as specified in its Constants.SERVICE_RANKING property) is returned.
If there is a tie in ranking, the service with the lowest service ID (as specified in its Constants.SERVICE_ID property); that is, the service that was registered first is returned.
В org.osgi.framework.BundleContext.registerService (String [], Object, Dictionary)
вы можете указать произвольные свойства в Dictionary
. Чтобы найти службу, вы можете указать фильтр в org.osgi.framework.BundleContext.getServiceReferences (String, String)
. А если этого недостаточно, вы можете проверить org.osgi.framework.ServiceReference.getProperty (String)
, например, на предмет значения приоритета.