The problem is that if we are using a ServletContextListener (jndi or
simple) the lifecycle methods get called after the routes have been built.
This prevents the routes from being able to use object in the registry. In
specific, I register some configuration information there. To work around
this, I subclassed JndiCamelServletContextListener and overrode
createRegistry and used my subclass in the web.xml. However I shouldnt have
to do this. What I propose is a code change to the
CamelServletContextListener.

There should be the following new methods:

beforeAddRoutes(ServletCamelContext context, R registry)
afterAddRoutes(ServletCamelContext context, R registry)

They would be triggered in CamelServletContextListener in the appropriate
places. By then, the registry is already up and able to take registrations
so it shoulnt be a big deal. As I understand it Spring gets around this
problem by reading the xml configuration before the routes are built.
However spring is off the table of discussion for me.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*

Reply via email to