Announcement Announcement Module
No announcement yet.
Clean Shutdown due to exception... Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Clean Shutdown due to exception...

    Hi *,

    I have the JDK5 special exceptionHandler which forces a shutdown when a given exception is thrown:
    <bean class="org.springframework.richclient.exceptionhandling.delegation.SimpleExceptionHandlerDelegate">
    	<property name="throwableClass" value="java.lang.Throwable" />
    	<property name="exceptionHandler">
    		<bean class="net.objectlab.safemargin.gui.SafeMarginExceptionHandler">
    			<property name="logLevel" value="ERROR" />
    			<property name="shutdownPolicy" value="ASK" />
    			<property name="issueReporter" ref="issueReporter" />
    I also have implemented a method in DefaultApplicationLifecycleAdvisor to ask the user if they are sure that they want to close the window...
        public boolean onPreWindowClose(final ApplicationWindow window) {
    When an unexpected exception is thrown, the following happen:
    1/ The user is notified by the exceptionHandler that the application is going to close (OK!)
    2/ The onPreWindowClose is then called and the user is asked whether they want to shutdown... a) they should not have the choice and b) the choice is ignored anyway.

    How could I know in my onPreWindowClose that the application is in a forced shutdown mode? and hence not ask the question...

    Many thanks


  • #2
    Hmmm... I guess you'll have to set some global property and check it in your preWindowClose...

    I checked the code, and it's AbstractApplicationWindow that calls the method (through the WindowManager which closes all the windows). It does not know why it's being closed. So you'll have to save the "why" somewhere and use it in your onPreWindowClose to check whether you want to how a dialog or not.


    • #3


      That is my feeling too but it would not be easy to set that global flag without changing the SpringRC code since the AbstractDialogExceptionHandler that knows it should close the windows or not...

          public void notifyUserAboutException(Thread thread, Throwable throwable) {
                  try {
                      Application.instance().close(true, 1);
                  } finally {
                      // In case the instance() method throws an exception and an exit didn't occur
      If that code could simply call a protected method "beforeForcingClose()" before calling the instance().close(...); a sub-class could then keep a flag... that would make it more flexible.

      Is it something that you could change?