You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Jacinto, Alex (GE Energy Management)" <al...@ge.com> on 2014/04/22 15:36:56 UTC

ApplicationContextRegistry and JndiRegistry

Is there a way I can make the two work?  What happens is that when I do ApplicationContextRegistry but wants to access through jndi it won’t work, if I do the JndiRegistry, it would not resolve all my routeContextRef.  My camel-context looks like:

	<routeContext id=“template" xmlns="http://camel.apache.org/schema/spring">
		<route>
			<from uri=“vm:from" />
				<bean ref=“java:app/TestJndi"/>
			<to uri=“vm:to" />
		</route>
	</routeContext>


	<camelContext id=“id" xmlns="http://camel.apache.org/schema/spring">
		<routeContextRef ref=“template" />
	</camelContext>

I would like to use camel simply for routing then use my beans for transformation.  Am I going at this the wrong way?  Let me know.  Thanks in advance.

Alex

Re: ApplicationContextRegistry and JndiRegistry

Posted by "Jacinto, Alex (GE Energy Management)" <al...@ge.com>.
Thanks for the suggestion Willem, I’ll look at the link.  With this setup,
I would have one context that uses the JNDI and another context that uses
the spring and uses the context that has the jndi.  I’ll give it a try,
thank you.

On 4/22/14, 10:32 PM, "Willem Jiang" <wi...@gmail.com> wrote:

>Current camel doesn’t share the Spring ApplicationContextRegistry with
>the JndiRegistry.
>But I think you can workaround it by using camel context component[1]
>which can hold a camel context as a new component.
>
>[1]http://camel.apache.org/context.html
>
>--  
>Willem Jiang
>
>Red Hat, Inc.
>Web: http://www.redhat.com
>Blog: http://willemjiang.blogspot.com (English)
>http://jnn.iteye.com (Chinese)
>Twitter: willemjiang
>Weibo: 姜宁willem
>
>
>
>On April 22, 2014 at 9:37:31 PM, Jacinto, Alex (GE Energy Management)
>(alex.jacinto@ge.com) wrote:
>> Is there a way I can make the two work? What happens is that when I do
>>ApplicationContextRegistry
>> but wants to access through jndi it won’t work, if I do the
>>JndiRegistry, it would not resolve
>> all my routeContextRef. My camel-context looks like:
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>> I would like to use camel simply for routing then use my beans for
>>transformation. Am I
>> going at this the wrong way? Let me know. Thanks in advance.
>>  
>> Alex
>


Re: ApplicationContextRegistry and JndiRegistry

Posted by Willem Jiang <wi...@gmail.com>.
Current camel doesn’t share the Spring ApplicationContextRegistry with the JndiRegistry.
But I think you can workaround it by using camel context component[1] which can hold a camel context as a new component.

[1]http://camel.apache.org/context.html

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 22, 2014 at 9:37:31 PM, Jacinto, Alex (GE Energy Management) (alex.jacinto@ge.com) wrote:
> Is there a way I can make the two work? What happens is that when I do ApplicationContextRegistry  
> but wants to access through jndi it won’t work, if I do the JndiRegistry, it would not resolve  
> all my routeContextRef. My camel-context looks like:
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
> I would like to use camel simply for routing then use my beans for transformation. Am I  
> going at this the wrong way? Let me know. Thanks in advance.
>  
> Alex


Re: ApplicationContextRegistry and JndiRegistry

Posted by "Jacinto, Alex (GE Energy Management)" <al...@ge.com>.
Thanks Luke, I'll try this solution.

On 4/23/14, 4:38 AM, "Łukasz Dywicki" <lu...@code-house.org> wrote:

>Temporary workaround for you would be usage of spring-jee namespace. With
>code shown below you just set ref="testJNDI" and you don't need any extra
>Java code.
>
><jee:jndi-lookup id="testJNDI"
>   jndi-name="app/TestJNDI"
>   expected-type="com.ge.camel.jndi.TestJNDI" />
>Kind regards,
>Łukasz Dywicki
>--
>luke@code-house.org
>Twitter: ldywicki
>Blog: http://dywicki.pl
>Code-House - http://code-house.org
>
>Wiadomość napisana przez Claus Ibsen <cl...@gmail.com> w dniu 23
>kwi 2014, o godz. 09:32:
>
>> Hi
>> 
>> Camel's registry is a facade for an actual registry such as
>> - jndi
>> - spring's app context
>> - osgi service registry
>> 
>> So the spring stuff is only registered in spring's own app context (eg
>> that is how spring works). So you cannot use jndi to lookup stuff that
>> are in spring's app context.
>> 
>> But you can create a composite registry in Camel that lookup in jndi
>> and then spring afterwards.
>> But to do that you would need to write some java code to setup that,
>> etc. Not as easy and clean to do.
>> 
>> 
>> On Tue, Apr 22, 2014 at 3:36 PM, Jacinto, Alex (GE Energy Management)
>> <al...@ge.com> wrote:
>>> Is there a way I can make the two work?  What happens is that when I
>>>do ApplicationContextRegistry but wants to access through jndi it won't
>>>work, if I do the JndiRegistry, it would not resolve all my
>>>routeContextRef.  My camel-context looks like:
>>> 
>>>        <routeContext id="template"
>>>xmlns="http://camel.apache.org/schema/spring">
>>>                <route>
>>>                        <from uri="vm:from" />
>>>                                <bean ref="java:app/TestJndi"/>
>>>                        <to uri="vm:to" />
>>>                </route>
>>>        </routeContext>
>>> 
>>> 
>>>        <camelContext id="id"
>>>xmlns="http://camel.apache.org/schema/spring">
>>>                <routeContextRef ref="template" />
>>>        </camelContext>
>>> 
>>> I would like to use camel simply for routing then use my beans for
>>>transformation.  Am I going at this the wrong way?  Let me know.
>>>Thanks in advance.
>>> 
>>> Alex
>> 
>> 
>> 
>> -- 
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>> hawtio: http://hawt.io/
>> fabric8: http://fabric8.io/
>


Re: ApplicationContextRegistry and JndiRegistry

Posted by Łukasz Dywicki <lu...@code-house.org>.
Temporary workaround for you would be usage of spring-jee namespace. With code shown below you just set ref="testJNDI" and you don't need any extra Java code.

<jee:jndi-lookup id="testJNDI"
   jndi-name="app/TestJNDI"
   expected-type="com.ge.camel.jndi.TestJNDI" />
Kind regards,
Łukasz Dywicki
--
luke@code-house.org
Twitter: ldywicki
Blog: http://dywicki.pl
Code-House - http://code-house.org

Wiadomość napisana przez Claus Ibsen <cl...@gmail.com> w dniu 23 kwi 2014, o godz. 09:32:

> Hi
> 
> Camel's registry is a facade for an actual registry such as
> - jndi
> - spring's app context
> - osgi service registry
> 
> So the spring stuff is only registered in spring's own app context (eg
> that is how spring works). So you cannot use jndi to lookup stuff that
> are in spring's app context.
> 
> But you can create a composite registry in Camel that lookup in jndi
> and then spring afterwards.
> But to do that you would need to write some java code to setup that,
> etc. Not as easy and clean to do.
> 
> 
> On Tue, Apr 22, 2014 at 3:36 PM, Jacinto, Alex (GE Energy Management)
> <al...@ge.com> wrote:
>> Is there a way I can make the two work?  What happens is that when I do ApplicationContextRegistry but wants to access through jndi it won’t work, if I do the JndiRegistry, it would not resolve all my routeContextRef.  My camel-context looks like:
>> 
>>        <routeContext id=“template" xmlns="http://camel.apache.org/schema/spring">
>>                <route>
>>                        <from uri=“vm:from" />
>>                                <bean ref=“java:app/TestJndi"/>
>>                        <to uri=“vm:to" />
>>                </route>
>>        </routeContext>
>> 
>> 
>>        <camelContext id=“id" xmlns="http://camel.apache.org/schema/spring">
>>                <routeContextRef ref=“template" />
>>        </camelContext>
>> 
>> I would like to use camel simply for routing then use my beans for transformation.  Am I going at this the wrong way?  Let me know.  Thanks in advance.
>> 
>> Alex
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/


Re: ApplicationContextRegistry and JndiRegistry

Posted by "Jacinto, Alex (GE Energy Management)" <al...@ge.com>.
Hi Claus, thanks for the response.  I was not trying to lookup spring
stuff through jndi, I was trying to have access both worlds - spring beans
and my container beans (jndi).  I might be mixing both worlds but I really
just want the spring DSL plus the camel routing.  To further explain, what
our plan is to put placeholders on uri routes including where the jndis
should go.  This way, we don¹t touch our xml file, we simply create our
transformation and put it in our properties files and off it goes.

I did look at creating what you mentioned, it looks like it easy enough to
say: hey, your look up starts with ³java:² then it would be JNDI.  But I
couldn¹t figure out where the spring applicationcontext would be injected,
is that available through the spring dsl?  I was looking for something
like:


	
		
		
	
	
		
			
				
					<bean id="registry" class="org.apache.camel.impl.JndiRegistry²>

	<constructor-arg Š./>
</bean>

Your book rocks btw, really helpful.  Thank you again.


On 4/23/14, 3:32 AM, "Claus Ibsen" <cl...@gmail.com> wrote:

>Hi
>
>Camel's registry is a facade for an actual registry such as
>- jndi
>- spring's app context
>- osgi service registry
>
>So the spring stuff is only registered in spring's own app context (eg
>that is how spring works). So you cannot use jndi to lookup stuff that
>are in spring's app context.
>
>But you can create a composite registry in Camel that lookup in jndi
>and then spring afterwards.
>But to do that you would need to write some java code to setup that,
>etc. Not as easy and clean to do.
>
>
>On Tue, Apr 22, 2014 at 3:36 PM, Jacinto, Alex (GE Energy Management)
><al...@ge.com> wrote:
>> Is there a way I can make the two work?  What happens is that when I do
>>ApplicationContextRegistry but wants to access through jndi it won¹t
>>work, if I do the JndiRegistry, it would not resolve all my
>>routeContextRef.  My camel-context looks like:
>>
>>         <routeContext id=³template"
>>xmlns="http://camel.apache.org/schema/spring">
>>                 <route>
>>                         <from uri=³vm:from" />
>>                                 <bean ref=³java:app/TestJndi"/>
>>                         <to uri=³vm:to" />
>>                 </route>
>>         </routeContext>
>>
>>
>>         <camelContext id=³id"
>>xmlns="http://camel.apache.org/schema/spring">
>>                 <routeContextRef ref=³template" />
>>         </camelContext>
>>
>> I would like to use camel simply for routing then use my beans for
>>transformation.  Am I going at this the wrong way?  Let me know.  Thanks
>>in advance.
>>
>> Alex
>
>
>
>-- 
>Claus Ibsen
>-----------------
>Red Hat, Inc.
>Email: cibsen@redhat.com
>Twitter: davsclaus
>Blog: http://davsclaus.com
>Author of Camel in Action: http://www.manning.com/ibsen
>hawtio: http://hawt.io/
>fabric8: http://fabric8.io/


Re: ApplicationContextRegistry and JndiRegistry

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Camel's registry is a facade for an actual registry such as
- jndi
- spring's app context
- osgi service registry

So the spring stuff is only registered in spring's own app context (eg
that is how spring works). So you cannot use jndi to lookup stuff that
are in spring's app context.

But you can create a composite registry in Camel that lookup in jndi
and then spring afterwards.
But to do that you would need to write some java code to setup that,
etc. Not as easy and clean to do.


On Tue, Apr 22, 2014 at 3:36 PM, Jacinto, Alex (GE Energy Management)
<al...@ge.com> wrote:
> Is there a way I can make the two work?  What happens is that when I do ApplicationContextRegistry but wants to access through jndi it won’t work, if I do the JndiRegistry, it would not resolve all my routeContextRef.  My camel-context looks like:
>
>         <routeContext id=“template" xmlns="http://camel.apache.org/schema/spring">
>                 <route>
>                         <from uri=“vm:from" />
>                                 <bean ref=“java:app/TestJndi"/>
>                         <to uri=“vm:to" />
>                 </route>
>         </routeContext>
>
>
>         <camelContext id=“id" xmlns="http://camel.apache.org/schema/spring">
>                 <routeContextRef ref=“template" />
>         </camelContext>
>
> I would like to use camel simply for routing then use my beans for transformation.  Am I going at this the wrong way?  Let me know.  Thanks in advance.
>
> Alex



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/