This all sounds horrible - why do you have a whiteboard that is making reflective calls on remote service objects? If you *really* want to make this work then your best option would be to have the whiteboard implementation listen for remote service discovery events and to create a local bundle on the fly to consume each remote service. You can set the package imports correctly for each bundle, and have it expose the service object through another service inside the bundle.
It’s all pretty hacky though. Does your whiteboard really need the service instance (rather than just the service properties)? If the answer is yes then you really shouldn’t be using reflection to call it. Tim > On 12 Nov 2018, at 14:34, Jürgen Albert via osgi-dev <osgi-dev@mail.osgi.org> > wrote: > > I needed to load the class first, because I only know its name, package and > version. The RSA would load the class and it would ask my bundlecontext, to > do it for him... Dynamic-ImportPackage did the trick here. I would prefere to > establish a new bundle wiring on the fly, because I would know what package > in what version I would need. > > Am 12/11/2018 um 14:46 schrieb Thomas Watson: >> Can you explain why you need to know the exporter in this case? It sounds >> like you have to be using reflection to call the service, in which case I >> would not think the wiring mattered. If you need to know exactly the >> exporting bundle of the API then one approach would be to get the service >> object and interrogate its class/interface hierarchy until you find the API >> class name you are looking for and then use FrameworkUtil.getBundle(Class) >> method. >> >> Tom >> >> >> >> ----- Original message ----- >> From: "Jürgen Albert via osgi-dev" <osgi-dev@mail.osgi.org> >> <mailto:osgi-dev@mail.osgi.org> >> Sent by: osgi-dev-boun...@mail.osgi.org >> <mailto:osgi-dev-boun...@mail.osgi.org> >> To: osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org> >> Cc: >> Subject: [osgi-dev] Get Bundle for package and version >> Date: Mon, Nov 12, 2018 6:58 AM >> >> Hi, >> >> I have a whiteboard, that needs to consume a remote service. Neither the >> RSA that registers the service proxy nor my whiteboard that needs to >> work with the interface has a wiring to the API Bundle. What the RSA >> does tell me, is the packages and the versions of the API Interfaces. >> Now I'm looking for a way to ge the appropriate bundle wiring. I know, I >> can iterate over all available Bundles, and look if one exports the >> package in the given version, but AFAIK I can't be sure if this is the >> right package, in case it was offered by multiple bundles. >> >> What would be the right approach here? >> >> Thx, >> >> Jürgen. >> >> -- >> Jürgen Albert >> Geschäftsführer >> >> Data In Motion Consulting GmbH >> >> Kahlaische Str. 4 >> 07745 Jena >> >> Mobil: 0157-72521634 >> E-Mail: j.alb...@datainmotion.de <mailto:j.alb...@datainmotion.de> >> Web: www.datainmotion.de <http://www.datainmotion.de/> >> >> XING: https://www.xing.com/profile/Juergen_Albert5 >> <https://www.xing.com/profile/Juergen_Albert5> >> >> Rechtliches >> >> Jena HBR 513025 >> >> _______________________________________________ >> OSGi Developer Mail List >> osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org> >> https://mail.osgi.org/mailman/listinfo/osgi-dev >> <https://mail.osgi.org/mailman/listinfo/osgi-dev> >> >> > > -- > Jürgen Albert > Geschäftsführer > > Data In Motion Consulting GmbH > > Kahlaische Str. 4 > 07745 Jena > > Mobil: 0157-72521634 > E-Mail: j.alb...@datainmotion.de <mailto:j.alb...@datainmotion.de> > Web: www.datainmotion.de <http://www.datainmotion.de/> > > XING: https://www.xing.com/profile/Juergen_Albert5 > <https://www.xing.com/profile/Juergen_Albert5> > > Rechtliches > > Jena HBR 513025 > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev