org.eodisp.util
Interface AppModule

All Known Implementing Classes:
AbstractAppModule

public interface AppModule

The interface of the an application module. Several application modules build an application where each application module is responsible for a distinct functionality of the application.

This interface defines the methods which are called during the initialization, startup and shutdown of an application.

Each application module implementation that shall be part of an application must be registered with the RootApp by calling the RootApp.registerAppModule(AppModule) method on it.

The methods are called in the following order:

  1. registerConfiguration(RootApp)
  2. preStartup(RootApp)
  3. startup(RootApp)
  4. shutdown(RootApp)
  5. postShutdown(RootApp)
Note that when preStartup(...) is called, the registerConfiguration(...) has been called on all registered application modules. This is true for all methods, that is, the first method is called on all the registered application modules, then the second method is called on all registered application modules, and so on.

The order of registered application modules is defined by the order of which the registerAppModules(...) is called on the RootApp is called. The shutdown methods are called in reverse order though.

Version:
$Id: AppModule.java 2107 2006-05-15 14:50:12Z ibirrer $
Author:
ibirrer
See Also:
RootApp

Method Summary
 java.lang.String getId()
          Returns the unique id of this application module.
 void postShutdown(RootApp rootApp)
          Called after all application modules were shutdown.
 void preStartup(RootApp rootApp)
          This callback is invoked before the real startup.
 void registerConfiguration(RootApp rootApp)
          Gives the application module a change to register its configuration with the root application.
 void shutdown(RootApp rootApp)
          This callback indicates that this application module shall shutdown.
 void startup(RootApp rootApp)
          This callback indicates that this application module can now start.
 

Method Detail

getId

java.lang.String getId()
Returns the unique id of this application module.

Returns:
the unique id of this application module.

registerConfiguration

void registerConfiguration(RootApp rootApp)
                           throws java.lang.Exception
Gives the application module a change to register its configuration with the root application.

The method RootApp.registerConfiguration(Configuration) must be called on the RootApp class to do this. If the AppModule wants to contribute any command line options, it can use the RootApp.registerConfiguration(Configuration, CommandlineMapper) instead.

The configuration that is being registered through the methods mentioned above, is automatically loaded by the root application, so do not call Configuration.load() here.

Parameters:
rootApp - The root application. This is the instance where the register methods can be invoked.
Throws:
java.lang.Exception - An application module can throw an exception if anything goes wrong during the configuration initialization.
See Also:
RootApp, Configuration

preStartup

void preStartup(RootApp rootApp)
                throws java.lang.Exception
This callback is invoked before the real startup.

Parameters:
rootApp - A reference to the root application
Throws:
java.lang.Exception - Indicates that something went wrong during the application module pre-startup.

startup

void startup(RootApp rootApp)
             throws java.lang.Exception
This callback indicates that this application module can now start.

In practice this means that after this method returns, the application module should be up and running. In the case of a GUI application module this probably means that the GUI is being displayed on the screen and is ready for user inputs.

Parameters:
rootApp - A reference to the root application
Throws:
java.lang.Exception - Indicates that something went wrong during the application module startup.

shutdown

void shutdown(RootApp rootApp)
              throws java.lang.Exception
This callback indicates that this application module shall shutdown.

Parameters:
rootApp - A reference to the root application
Throws:
java.lang.Exception - Indicates that something went wrong during the application shutdown.

postShutdown

void postShutdown(RootApp rootApp)
                  throws java.lang.Exception
Called after all application modules were shutdown.

Parameters:
rootApp - A reference to the root application
Throws:
java.lang.Exception - Indicates that something went wrong during the application shutdown.