Martin Kouba, your understanding is correct, Camel provides what's called MainSupport which is capable of bootstrapping Camel in Spring, Guice, CDI and whatever container in standalone or Maven plugin invocation. And it happens that the Weld SE shutdown hook gets called before so that CDI contexts are not active anymore when it tries to stop the Camel contexts.
Camel MainSupport for CDI is delegating to DeltaSpike container control the management of the container. So indeed, I was thinking about updating the DeltaSpike container control adapter for Weld by providing that option programmatically to the Weld SE container and using that newer version of the container control adapter. Indeed, the DeltaSpike CdiContainer.boot API can be provided with a map of container specific options, so I was thinking about passing something like org.jboss.weld.se.useShutdownHook to false. At that level, that kind of defeats the purpose of implementation agnostic bootstrap, still that works. An other option would be to deactivate systematically the shutdown hook in the Weld container control adapter.
To cover more use cases, as you propose, a corresponding system property could take precedence on top of the programmatic option.
|