Hi

what do you mean by "your bundle" ? You mean the one containing the route ?

If your bundle just contains the blueprint xml, the most secure way is
to get the bundle list, filter by your name to get the version.

Regards
JB

On Fri, Jul 8, 2022 at 10:45 AM Ephemeris Lappis
<ephemeris.lap...@gmail.com> wrote:
>
> Hello again !
>
> I've tested it, but I'm afraid the solution #2 doesn't work as is.
>
> With the following code, the retrieved bundle seems to be the system's
> bundle that creates the exchange, not mine :
>
> // e is the current Exchange
> final Bundle bundle = FrameworkUtil.getBundle(e.getClass());
> return bundle != null ? bundle.getVersion().toString() : "no.version";
>
> The returned version is "2.17.0.redhat-630377", that matches the Fuse
> environment I'm working on, and not my own bundle that manages the
> Camel Context...
>
> What other class could be used to retrieve my bundle ?
>
> Thanks again.
>
> Regards.
>
>
> Le ven. 8 juil. 2022 à 06:49, Jean-Baptiste Onofré <j...@nanthrax.net> a 
> écrit :
> >
> > Hi,
> >
> > You have two ways to do that:
> > 1. in your blueprint XML, you can inject blueprintBundleContext
> > (implicit bean) in your camel route/processor.
> > 2. you can do FrameworkUtil.getBundle(Exchange.class).getBundleContext()
> >
> > Regards
> > JB
> >
> > On Thu, Jul 7, 2022 at 4:33 PM Ephemeris Lappis
> > <ephemeris.lap...@gmail.com> wrote:
> > >
> > > Hello.
> > >
> > > I'd like to know if there's some way to retrieve the bundle version
> > > from either the CamelContext or the CamelMessage objects.
> > >
> > > The code should be executed in a service that is provided from another
> > > bundle. I suppose I could get the BundleContext using the
> > > FrameworkUtil.getBundleContext(someClass), but I don't know how I
> > > could get the given "someClass" that would match the origin Camel
> > > Exchange scope.
> > >
> > > All our Camel contexts are executed from OSGi blueprints packaged as
> > > bundles, and they share the services that need to get the
> > > corresponding bundles versions.
> > >
> > > Any idea ?
> > >
> > > Thanks for your help.
> > >
> > > Regards.

Reply via email to