Callback after startup from org.apache.camel.main.Main afterStart()

Callback after startup from org.apache.camel.main.Main afterStart()

I have a use case, where I require a fast startup time for camel and wish
to avoid classpath scanning.
I use the Main class however it appears that its not possible to obtain a
ProducerTemplate template = getCamelTemplate();
before calling the run method. (it produces an ArrayOutOfBounds exception -
I could file a bug for that if you like)

What I did was to extend Main (see code fragment below) and add a callback
called from the afterStart() method, so that user code can access the
context, and TypeConverterRegistry (as before that it is not initialized).

Is there a better way to do it?

If not and the developers think its a good idea, I would like to contribute
the code for a future release.

Yeah we probably need some API on MainSupport so you can add a custom
EventNotifier, which we then add to the CamelContext before its
started.

Though another option that may be easier is just to have a beforeStart
| beforeStop method which you can implement and do your custom code
there. A bit like what you did, but IMHO should have simpler api's
than a Callable et all.