camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hugo <the_damned_an...@voila.fr>
Subject Spring context and camel context in the same time
Date Mon, 16 Apr 2012 14:18:08 GMT
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.

Mime
View raw message