...
Starting Camel automatically
Our current deployment model is as a war and we have the web.xml
to help start things. Well in fact we will leverage Spring to start the world
. We use it's ContextListener
Code Block |
---|
|
<!-- the listener that kick-starts Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
|
Then we need a standard Spring XML file so we create a new file in src/main/resources
and name it camel-config.xml. Before we start editing this XML file we need to link to it from the web.xml file. So we add this snippet to the web.xml:
Code Block |
---|
|
<!-- location of spring xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:camel-config.xml</param-value>
</context-param>
|
Now we are ready to edit the camel-config.xml file that is a standard Spring XML bean file. So you can add standard spring beans and whatnot you like to do and can do with Spring.
Code Block |
---|
|
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
</beans>
|
Now we are nearly there, we just need to add Camel to the Spring XML file, so Spring knows Camel exists and can start it.