Results 1 to 3 of 3

Thread: Clean Shutdown due to exception...

  1. #1
    Join Date
    Aug 2005
    Location
    London (the English one!)
    Posts
    378

    Default Clean Shutdown due to exception...

    Hi *,

    I have the JDK5 special exceptionHandler which forces a shutdown when a given exception is thrown:
    Code:
    <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" />
    		</bean>
    	</property>
    </bean>
    I also have implemented a method in DefaultApplicationLifecycleAdvisor to ask the user if they are sure that they want to close the window...
    Code:
        @Override
        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

    Benoit.

  2. #2
    Join Date
    Mar 2007
    Location
    Oudenaarde
    Posts
    294

    Default

    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.
    MSN: PM me please
    Skype: doclo_lieven

    Spring Rich Client Project Lead

  3. #3
    Join Date
    Aug 2005
    Location
    London (the English one!)
    Posts
    378

    Default Yep

    Hi

    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...

    Code:
        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
                    System.exit(2);
                }
    }
    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?

    Thanks

    Benoit

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •