org.springframework.richclient.application.config
Class ApplicationLifecycleAdvisor

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.application.config.ApplicationLifecycleAdvisor
All Implemented Interfaces:
InitializingBean
Direct Known Subclasses:
DefaultApplicationLifecycleAdvisor

public abstract class ApplicationLifecycleAdvisor
extends Object
implements InitializingBean

Advisor for the Application. This class provides the startingPageId, an exceptionHandler for uncaught exceptions, application wide window structures(menu/toolbar/statusbar) and a number of hook methods that are called in the startup/closing process.

The sequence in which the hooks are called is as follows:

 Application Creation
                setApplication(Application)
                onPreInitialize(Application)

 Application Start
                onPreStartup()

                ApplicationWindow Creation
                        setOpeningWindow(ApplicationWindow)
                        onPreWindowOpen(ApplicationWindowConfigurer)
                        createWindowCommandManager()
                        getMenuBarCommandGroup()
                        getToolBarCommandGroup()
                        getStatusBar()
                        onCommandsCreated(ApplicationWindow)

                ApplicationWindow Creating the JFrame
                        onWindowCreated(ApplicationWindow)
                        ApplicationWindow Shows JFrame (setVisible(true))
                        onWindowOpened(ApplicationWindow)

                onPostStartup()
 

The remaining hook is called when the ApplicationWindow is closed: onPreWindowClose(ApplicationWindow).

Author:
Keith Donald, Jim Moore

Constructor Summary
ApplicationLifecycleAdvisor()
           
 
Method Summary
 void afterPropertiesSet()
          After properties are set, register the exceptionHandler.
 ApplicationWindowCommandManager createWindowCommandManager()
          Create a ApplicationWindowCommandManager for the application.
protected  Application getApplication()
           
protected  ApplicationServices getApplicationServices()
           
 ApplicationSessionInitializer getApplicationSessionInitializer()
           
 CommandGroup getMenuBarCommandGroup()
          Create the menuBar for the application.
protected  ApplicationWindow getOpeningWindow()
           
 RegisterableExceptionHandler getRegisterableExceptionHandler()
           
 String getStartingPageId()
           
 StatusBar getStatusBar()
          Create the statusBar for the application.
 CommandGroup getToolBarCommandGroup()
          Create the toolBar for the application.
 void onCommandsCreated(ApplicationWindow window)
          Hook called right after commands are initialized.
 void onPostStartup()
          Hook called right after the applicationWindow is created.
 void onPreInitialize(Application application)
          Hook called right after the application has been created.
 void onPreStartup()
          Hook called right before the applicationWindow is created.
 boolean onPreWindowClose(ApplicationWindow window)
          Check if the ApplicationWindow can close.
 void onPreWindowOpen(ApplicationWindowConfigurer configurer)
          Hook called right before the application opens a window.
 void onShutdown()
          Hook called right afther the application is closed.
 void onWindowCreated(ApplicationWindow window)
          Hook called right after the window (JFrame) of the application is created.
 void onWindowOpened(ApplicationWindow window)
          Hook called right after the window (JFrame) of the application is shown (setVisible(true)).
 void setApplication(Application application)
           
 void setApplicationSessionInitializer(ApplicationSessionInitializer applicationSessionInitializer)
           
 void setOpeningWindow(ApplicationWindow window)
           
 void setRegisterableExceptionHandler(RegisterableExceptionHandler registerableExceptionHandler)
          Sets the exception handler which will be registered upon initialization to handle uncaught throwables.
 void setStartingPageId(String pageDescriptorId)
          This is used to allow the ViewDescriptor to be lazily created when the ApplicationWindow is opened.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationLifecycleAdvisor

public ApplicationLifecycleAdvisor()
Method Detail

setStartingPageId

public void setStartingPageId(String pageDescriptorId)
This is used to allow the ViewDescriptor to be lazily created when the ApplicationWindow is opened. Useful when the ApplicationAdvisor needs to do things before ViewDescriptor should be created, such as setting up a security context.

Parameters:
pageDescriptorId - id of the pageDescriptor bean to show on startup.
See Also:
getStartingPageId()

setRegisterableExceptionHandler

public void setRegisterableExceptionHandler(RegisterableExceptionHandler registerableExceptionHandler)
Sets the exception handler which will be registered upon initialization to handle uncaught throwables. By default this is a DefaultRegisterableExceptionHandler, which is inferior to a well configured DelegatingExceptionHandler (java 1.5 only).

Parameters:
registerableExceptionHandler - the exception handler which will handle uncaught throwables

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
After properties are set, register the exceptionHandler.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

getStartingPageId

public String getStartingPageId()
Returns:
the id of the starting Page.

getApplication

protected Application getApplication()
Returns:
Application.

getApplicationServices

protected ApplicationServices getApplicationServices()
Returns:
ApplicationServices.

onPreInitialize

public void onPreInitialize(Application application)
Hook called right after the application has been created.

Parameters:
application - the application.

onPreStartup

public void onPreStartup()
Hook called right before the applicationWindow is created.


onPostStartup

public void onPostStartup()
Hook called right after the applicationWindow is created.


onShutdown

public void onShutdown()
Hook called right afther the application is closed.


setOpeningWindow

public void setOpeningWindow(ApplicationWindow window)
Parameters:
window - the openingWindow.

onPreWindowOpen

public void onPreWindowOpen(ApplicationWindowConfigurer configurer)
Hook called right before the application opens a window.

Parameters:
configurer -

getOpeningWindow

protected final ApplicationWindow getOpeningWindow()
Returns:
the openingWindow.

createWindowCommandManager

public ApplicationWindowCommandManager createWindowCommandManager()
Create a ApplicationWindowCommandManager for the application.

Returns:
applicationWindowCommandManager.

getMenuBarCommandGroup

public CommandGroup getMenuBarCommandGroup()
Create the menuBar for the application.

Returns:
a CommandGroup.

getToolBarCommandGroup

public CommandGroup getToolBarCommandGroup()
Create the toolBar for the application.

Returns:
a CommandGroup.

getStatusBar

public StatusBar getStatusBar()
Create the statusBar for the application.

Returns:
a statusBar.

onCommandsCreated

public void onCommandsCreated(ApplicationWindow window)
Hook called right after commands are initialized. Typically the next step after the get*CommandGroup() methods are called.

Parameters:
window - applicationWindow.

onWindowCreated

public void onWindowCreated(ApplicationWindow window)
Hook called right after the window (JFrame) of the application is created.

Parameters:
window - applicationWindow.

onWindowOpened

public void onWindowOpened(ApplicationWindow window)
Hook called right after the window (JFrame) of the application is shown (setVisible(true)).

Parameters:
window - applicationWindow.

onPreWindowClose

public boolean onPreWindowClose(ApplicationWindow window)
Check if the ApplicationWindow can close.

Parameters:
window - the applicationWindow that should be closed.
Returns:
true if the window may close.

getRegisterableExceptionHandler

public RegisterableExceptionHandler getRegisterableExceptionHandler()
Returns:
the ExceptionHandler to be registered as uncaughtExceptionHandler.

setApplication

public void setApplication(Application application)
Parameters:
application - set the current application.

getApplicationSessionInitializer

public ApplicationSessionInitializer getApplicationSessionInitializer()

setApplicationSessionInitializer

public void setApplicationSessionInitializer(ApplicationSessionInitializer applicationSessionInitializer)


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.