You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by yogu13 <yo...@synechron.com> on 2014/12/13 14:43:43 UTC

configuring Camel with XML DSL and Guice in tomcat

Here is my understanding of things that needs to be done if Guice - Camel and
XML DSL have to work together

1. create a ServletContextListener which would do the following
	a. extracts Routes from the XML 
	b. create a JNDI Registry instance (GuiceyFruit implementation)
	c. pass in the routes to create the injector as below
		Injector injector = Guice.createInjector(new
CamelModuleWithRouteTypes(Set<>));
	d. create a CamelContext
		CamelContext camelContext = injector.getInstance(CamelContext.class);
	e. set the context in servletcontext which can be looked up and used later

2. use existing servlet module as an entry point for triggering rest:// and
servlet:// endpoints


Let me know if my understanding is correct here..

Appreciate the help!

Regards,
-Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/configuring-Camel-with-XML-DSL-and-Guice-in-tomcat-tp5760657.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: configuring Camel with XML DSL and Guice in tomcat

Posted by yogu13 <yo...@synechron.com>.
Any thoughts on this?



--
View this message in context: http://camel.465427.n5.nabble.com/configuring-Camel-with-XML-DSL-and-Guice-in-tomcat-tp5760657p5760679.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: configuring Camel with XML DSL and Guice in tomcat

Posted by yogu13 <yo...@synechron.com>.
Hello,

Any suggestions / pointers ?

Regards,
-Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/configuring-Camel-with-XML-DSL-and-Guice-in-tomcat-tp5760657p5760999.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: configuring Camel with XML DSL and Guice in tomcat

Posted by yogu13 <yo...@synechron.com>.
Apologies for the delayed response ... I would like to understand how can
Guice be used in following case : In my sample route below 

<?xml version="1.0" encoding="UTF-8"?> 
  
<routes xmlns="http://camel.apache.org/schema/spring">
 <route>
 <from uri="rest:///get:payment/{paymentType}"/>
 <process ref="myProcessor">
 </process>
 <transform>
   <simple>Hi ${header.paymentType}</simple>
 </transform>
 </route>

</routes>

the myProcessor bean instance was created and set in the SimpleRegistry
using the CamelContextLifecycle. Now I do understand Guice doesnt have
container capabilities like Spring but Guice mandates use of GuicyFruit
Implementation as registry
and i would have couple of more classes injected into my processor by Guice.
so how do i go about dealing in this case ?

Appreciate your help on this.

Regards,
-Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/configuring-Camel-with-XML-DSL-and-Guice-in-tomcat-tp5760657p5760939.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: configuring Camel with XML DSL and Guice in tomcat

Posted by Willem Jiang <wi...@gmail.com>.
I don’t think you need to dependency injection in your XML DSL, as we just look up the instance from the registry. Can you give an example that you need to use Guice to do the DI work?

--  
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 December 13, 2014 at 9:45:32 PM, yogu13 (yogesh.rao@synechron.com) wrote:
> Here is my understanding of things that needs to be done if Guice - Camel and
> XML DSL have to work together
>  
> 1. create a ServletContextListener which would do the following
> a. extracts Routes from the XML
> b. create a JNDI Registry instance (GuiceyFruit implementation)
> c. pass in the routes to create the injector as below
> Injector injector = Guice.createInjector(new
> CamelModuleWithRouteTypes(Set<>));
> d. create a CamelContext
> CamelContext camelContext = injector.getInstance(CamelContext.class);
> e. set the context in servletcontext which can be looked up and used later
>  
> 2. use existing servlet module as an entry point for triggering rest:// and
> servlet:// endpoints
>  
>  
> Let me know if my understanding is correct here..
>  
> Appreciate the help!
>  
> Regards,
> -Yogesh
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/configuring-Camel-with-XML-DSL-and-Guice-in-tomcat-tp5760657.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.
>