And a minimal version of this could be a static boolean field be set at the end of the previous block of code (only in DesktopApplicationContext, but ok for the moment), and a getter ...
It's easy enough to add such a flag. I'm just not convinced that it is the right way to go about it.
