camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Spring context and camel context in the same time
Date Wed, 18 Apr 2012 06:33:41 GMT
The XML file is just a standard Spring XML file.
So whatever Spring supports to use both its annotation and to load
beans from a XML file, that is your answer.

You can also create a SpringCamelContext yourself from Java code, to
get Camel. Then you may not need the XML file.


On Mon, Apr 16, 2012 at 4:18 PM, Hugo <the_damned_angel@voila.fr> wrote:
> Hello everyone,
>
> Is it possible to use a camel context and a spring context (more precisely
> an AnnotationConfigApplicationContext) in a same application ?
>
> I explained myself : I'm trying to do 2 "simple" things.
> - get beans (created by spring through the annotation @Named) file from a
> java class (without injection)
> - scan packages to create beans from annotation (@Named)
>
> I am not achieving do that neither using <context:component-scan base.../>
> neither creating a new spring context...
>
> I would like to create something like that (in addition of the existing
> camelcontext defined in the xml file camel-context.xml) :
>
> public MyClass {
>  AnnotationConfigApplicationContext currentApplicationContext = new
> AnnotationConfigApplicationContext();
>  currentApplicationContext.register(BeanSpring.class);
>  currentApplicationContext.refresh();
> }
>
> and my config file :
>
> @Configuration
> @ComponentScan("com.francetelecom.prototyperoutes")
> public class BeanSpring {
>
>        String MANDATORY_PROFILE = "test";
>
>        String getProp() {
>                return MANDATORY_PROFILE;
>        }
> }
>
> In my xml, I've just got :
>
>  <bean id="prototypeRoutes"
> class="com.francetelecom.prototyperoutes.PrototypeRoutes"/>
>
>  <camel:camelContext id="camel">
>    <camel:routeBuilder ref="prototypeRoutes"/>
>  </camel:camelContext>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Spring-context-and-camel-context-in-the-same-time-tp5643943p5643943.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message