You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by akoufoudakis <ak...@gmail.com> on 2015/08/11 17:54:09 UTC

OSGI Service look up

Dear all!

I know that one can lookup for an OSGi service the following way:
Runnable r = (Runnable) ctx.lookup("osgi:service/java.lang.Runnable");
Can you do anything similar inside your camel route?

Thank you in advance.



--
View this message in context: http://camel.465427.n5.nabble.com/OSGI-Service-look-up-tp5770588.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: OSGI Service look up

Posted by Franz Paul Forsthofer <em...@googlemail.com>.
Hi,

from the camel message you can get the exchange and from the exchange
the camel context

message.getExchange().getContext().

Regards Franz

On Tue, Aug 11, 2015 at 5:54 PM, akoufoudakis <ak...@gmail.com> wrote:
> Dear all!
>
> I know that one can lookup for an OSGi service the following way:
> Runnable r = (Runnable) ctx.lookup("osgi:service/java.lang.Runnable");
> Can you do anything similar inside your camel route?
>
> Thank you in advance.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/OSGI-Service-look-up-tp5770588.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: OSGI Service look up

Posted by Raul Kripalani <ra...@evosent.com>.
Are you using Spring or Blueprint in your Camel application? If yes, you
can use <reference /> elements to get a hold of the OSGi Service.

Otherwise, since you haven't indicated what 'ctx' is in your example, and
judging by your lookup notation, I will assume it is an InitialContext
plumbed against Aries JNDI.

In that case, there are several ways to achieve what you're after depending
on what you have in your Camel registry and how often you want to look up
the service (just once at initialization, with every Exchange, etc.).

If you specify your use case a little more, we'll be able to help you
better.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Tue, Aug 11, 2015 at 4:54 PM, akoufoudakis <ak...@gmail.com>
wrote:

> Dear all!
>
> I know that one can lookup for an OSGi service the following way:
> Runnable r = (Runnable) ctx.lookup("osgi:service/java.lang.Runnable");
> Can you do anything similar inside your camel route?
>
> Thank you in advance.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/OSGI-Service-look-up-tp5770588.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>