de.esprit.appsuite.launch

## Class AbstractApplicationLaunch<G extends ApplicationConfig,C extends ApplicationContext>

- java.lang.Object
- - de.esprit.appsuite.launch.AbstractApplicationLaunch<G,C>

- Direct Known Subclasses:
    AbstractClientLaunch, AbstractServerLaunch, EspritAppStarterLaunch, EspritDBCreateLaunch, EspritDemoLaunch, TableEditLaunch

      public abstract class AbstractApplicationLaunch<G extends ApplicationConfig,C extends ApplicationContext>
      extends java.lang.Object

  This class implements a robust launching procedure for starting up GUI or non-GUI applications. A non-GUI application is executed within the main thread, whereas a GUI application launches within the EventDispatcher Thread (ET). The following steps are performed:
  - the command line parser is created
  - the `ApplicationConfig` object is created from the command line parser
  - the `ApplicationContext` object is created from the `ApplicationConfig`
  - the main application is invoked with passing the context
  - on failure an error is issued and the VM is terminated
  Author:
    Rainer Buesch

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DO_NOT_EXIT`
    `static int` | `EXIT_CODE_CLP_ERROR`
    `static int` | `EXIT_CODE_LAUNCH_ERROR`
    `protected static boolean` | `isTestMode`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractApplicationLaunch(boolean hasGui, G cfg)`
    `AbstractApplicationLaunch(boolean hasGui, java.lang.String[] args)`
    `AbstractApplicationLaunch(G cfg)`
    `AbstractApplicationLaunch(java.lang.String[] args)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract ApplicationCommandLineParser` | `createCommandLineParser(java.lang.String[] args)` Creates the CommandLineParser instance for launching the application.
    `protected abstract C` | `createContext(G cfg)` Creates the application context from the Config object.
    `protected IconKey` | `createSplashIcon()` If an icon is provided it is being used for a splash screen while launching a GUI application.
    `protected void` | `doOnContextCreated(C launchedCtx)`
    `protected void` | `doOnMainFrameCreated(C launchedCtx, ZFrame frame)`
    `java.lang.Exception` | `getError()`
    `C` | `getLaunchedContext()` Makes the launched `ApplicationContext` available to the outside world.
    `ZFrame` | `getLaunchedMainFrame()` Makes the launched main-frame available to the outside world.
    `protected void` | `handleCommandLineError(ApplicationCommandLineParser clp, java.lang.Exception e)` Calling this method terminates the VM.
    `protected void` | `handleLaunchError(C ctx, java.lang.Exception error)` Calling this method terminates the VM.
    `boolean` | `hasError()`
    `boolean` | `hasGui()` This method decides which type of application is launched.
    `void` | `launch()`
    `protected void` | `launchApplication(C ctx)` Must be implemented for running a non-GUI application
    `protected ZFrame` | `launchMainFrame(C ctx)` Must be implemented for running a GUI application.
    `static void` | `setTestMode(boolean isTest)` This method prevents the FatalErrorFrame to be popped up.
    `static void` | `showFatalError(NlsKey title, java.lang.Exception error, int exitCode)`
    `static void` | `showFatalError(NlsKey title, java.lang.String errorMsg, int exitCode)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DO_NOT_EXIT

          public static final int DO_NOT_EXIT

      See Also:
        Constant Field Values

    - #### EXIT_CODE_CLP_ERROR

          public static final int EXIT_CODE_CLP_ERROR

      See Also:
        Constant Field Values

    - #### EXIT_CODE_LAUNCH_ERROR

          public static final int EXIT_CODE_LAUNCH_ERROR

      See Also:
        Constant Field Values

    - #### isTestMode

          protected static boolean isTestMode

  - ### Constructor Detail

    - #### AbstractApplicationLaunch

          public AbstractApplicationLaunch(G cfg)

    - #### AbstractApplicationLaunch

          public AbstractApplicationLaunch(boolean hasGui,
                                   G cfg)

    - #### AbstractApplicationLaunch

          public AbstractApplicationLaunch(java.lang.String[] args)

    - #### AbstractApplicationLaunch

          public AbstractApplicationLaunch(boolean hasGui,
                                   java.lang.String[] args)

  - ### Method Detail

    - #### launch

          public final void launch()

    - #### doOnContextCreated

          protected void doOnContextCreated(C launchedCtx)

    - #### doOnMainFrameCreated

          protected void doOnMainFrameCreated(C launchedCtx,
                                  ZFrame frame)
                                       throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### getLaunchedContext

          public C getLaunchedContext()

      Makes the launched `ApplicationContext` available to the outside world.

    - #### getLaunchedMainFrame

          public ZFrame getLaunchedMainFrame()

      Makes the launched main-frame available to the outside world.

    - #### launchApplication

          protected void launchApplication(C ctx)
                                    throws java.lang.Exception

      Must be implemented for running a non-GUI application
      Throws:
        `java.lang.Exception`

    - #### launchMainFrame

          protected ZFrame launchMainFrame(C ctx)
                                    throws java.lang.Exception

      Must be implemented for running a GUI application. Note that this method is executed within the ET Thread.
      Throws:
        `java.lang.Exception`

    - #### handleCommandLineError

          protected void handleCommandLineError(ApplicationCommandLineParser clp,
                                    java.lang.Exception e)

      Calling this method terminates the VM.

    - #### handleLaunchError

          protected void handleLaunchError(C ctx,
                               java.lang.Exception error)

      Calling this method terminates the VM.

    - #### showFatalError

          public static void showFatalError(NlsKey title,
                            java.lang.String errorMsg,
                            int exitCode)

    - #### showFatalError

          public static void showFatalError(NlsKey title,
                            java.lang.Exception error,
                            int exitCode)

    - #### setTestMode

          public static void setTestMode(boolean isTest)

      This method prevents the FatalErrorFrame to be popped up. WARNING: Do not use this method in production code. It's for testing only.

    - #### getError

          public java.lang.Exception getError()

    - #### hasError

          public boolean hasError()

    - #### hasGui

          public final boolean hasGui()

      This method decides which type of application is launched.
      See Also:
        `is called for a non-GUI application`, `is called for a GUI application`

    - #### createSplashIcon

          protected IconKey createSplashIcon()

      If an icon is provided it is being used for a splash screen while launching a GUI application.

    - #### createContext

          protected abstract C createContext(G cfg)
                                                                 throws java.lang.Exception

      Creates the application context from the Config object.
      Throws:
        `java.lang.Exception`

    - #### createCommandLineParser

          protected abstract ApplicationCommandLineParser createCommandLineParser(java.lang.String[] args)

      Creates the CommandLineParser instance for launching the application.

Copyright © 2014 EsprIT-Systems. All Rights Reserved.