Package apps

Class AppsBase

Direct Known Subclasses:
Apps3, JmriFaceless

public abstract class AppsBase
extends Object
Base class for the core of JMRI applications.

This provides a non-GUI base for applications. Below this is the Apps3 subclass which provides basic Swing GUI support.

There are a series of steps in the configuration:

Initialize log4j, invoked from the main()
  • Field Details

  • Constructor Details

    • AppsBase

      public AppsBase​(String applicationName, String configFileDef, String[] args)
      Create and initialize the application object.
      applicationName - user-visible name of application
      configFileDef - default config filename
      args - arguments passed to application at launch
  • Method Details

    • preInit

      public static void preInit​(String applicationName)
      Initial actions before frame is created, invoked in the applications main() routine.
      • Initialize logging
      • Set application name
      applicationName - The application name as presented to the user
    • configureProfile

      protected void configureProfile()
      Configure the Profile to use for this application.

      Note that GUI-based applications must override this method, since this method does not provide user feedback.

    • installConfigurationManager

      protected void installConfigurationManager()
    • installManagers

      protected void installManagers()
    • setAndLoadPreferenceFile

      protected void setAndLoadPreferenceFile()
      Invoked to load the preferences information, and in the process configure the system. The high-level steps are:
      • Locate the preferences file based through FileUtil.getFile(String)
      • See if the preferences file exists, and handle it if it doesn't
      • Obtain a ConfigureManager from the InstanceManager
      • Ask that ConfigureManager to load the file, in the process loading information into existing and new managers.
      • Do any deferred loads that are needed
      • If needed, migrate older formats
      (There's additional handling for shared configurations)
    • installShutDownManager

      for removal since 4.17.2 without replacement
    • start

      protected void start()
      Final actions before releasing control of the application to the user, invoked explicitly after object has been constructed in main().
    • setConfigFilename

      protected static void setConfigFilename​(String def, String[] args)
      Set up the configuration file name at startup.

      The Configuration File name variable holds the name used to load the configuration file during later startup processing. Applications invoke this method to handle the usual startup hierarchy:

      • If an absolute filename was provided on the command line, use it
      • If a filename was provided that's not absolute, consider it to be in the preferences directory
      • If no filename provided, use a default name (that's application specific)
      This name will be used for reading and writing the preferences. It need not exist when the program first starts up. This name may be proceeded with config=.
      def - Default value if no other is provided
      args - Argument array from the main routine
    • getConfigFileName

      public static String getConfigFileName()
    • setJmriSystemProperty

      protected static void setJmriSystemProperty​(String key, String value)
    • handleQuit

      public static boolean handleQuit()
      The application decided to quit, handle that.
      true if successfully ran all shutdown tasks and can quit; false otherwise
    • handleRestart

      public static boolean handleRestart()
      The application decided to restart, handle that.
      true if successfully ran all shutdown tasks and can quit; false otherwise