For GERONIMO-657, Running configurations not saved on shutdown
(http://issues.apache.org/jira/browse/GERONIMO-657), I have a potential
solution I'd like to run by those interested.
The shutdown hook for FileConfigurationList doesn't run because it gets
unregistered during the kernel shutdown process. The
ConfigurationManagerImpl shutdown hook gets run first, knocking the feet
out from under any other shutdown hook registered by another GBean. This
hook tells all loaded configurations to stop. Thus, when the
FileConfigurationList gets the doStop(), it dutifully unregisters it
shutdown hook to save the active configurations. The
FileConfigurationList hook never runs.
One way to solve this problem is to ensure the ConfigurationManagerImpl
shutdown hook runs last. To do this, we could define a shutdown hook
ordering, such as adding a "priority" parameter to the Kernel's
registerShutdownHook method. Something like:
/**
* Registers a runnable to execute when the kernel is shutdown
* @param hook a runnable to execute when the kernel is shutdown
*/
void registerShutdownHook(Runnable hook, int priority);
Using an int would be a quick way, and we could define two priorities,
LOW and HIGH and ensure the ConfigurationManagerImpl uses LOW. Or we
could use an enumerated priority object type. Either way isn't terribly
clean because a GBean registering a shutdown hook has to have a good
idea of what order its hook should run, and really we only need to
assure that stopping all configurations is performed last rather than
needing the other shutdown hooks to run first.
Perhaps a better solution would be to add a boolean "runLast" parameter
instead of a priority parameter. A true param would mean add the hook to
the end of the shutdown hook list, while those with false would be added
to the front.
I'd be happy to implement a solution like this if folks think it's a
good idea.
-Tom