Class MainConfig

java.lang.Object
edu.wisc.game.util.MainConfig

public class MainConfig
extends Object
Accessing the main configuration file of the Game Server, which can be used by the site administrator to override some defaults. It is located outside of the WAR file, so that adjustments can be made without rebuilding the WAR file.

In particular, the main config file (usually located in /opt/w2020/w2020.conf) may override the user name and password for accessing the MySQL database password specified in META-INF/persistence.xml (packaged into the WAR file). Thus changing the database password, or asking the server to work with a different database, can be accommodated without having to rebuild the WAR file.

The MainConfig object is used in sql.Main

  • Constructor Details

    • MainConfig

      public MainConfig​(String _path)
      Parameters:
      _path - The location of the master config file (or an alternative config file) from which this structure will be initialized
  • Method Details

    • getMainConfig

      public static MainConfig getMainConfig()
      Gets the default instance.
    • setPath

      public static void setPath​(String _path)
      This method is used by analysis tools who work with different databases than the default one. It is also used by the Captive Server, with null argument, to disable the attempts to look for the master config file (which CGS users likely won't have).
    • adjustPath

      public static String adjustPath​(String path)
      Tries to figure if we're running on a DoIT shared hosting host, and the path such as /opt/w2020/something has to be understood with respect to the root of the chrooted directory (such as "/var/www/vhosts/wwwtest.rulegame.wisc.edu"), rather than with respect to the root of the file system.
      Parameters:
      path - Something like "/opt/foo"
      Returns:
      Either the original path, or something like "/var/www/vhosts/wwwtest.rulegame.wisc.edu/opt/foo"
    • getString

      public static String getString​(String name, String defVal)
    • doGetString

      public String doGetString​(String name, String defVal)
    • getFile

      public static File getFile​(String name, String defVal)
      Looks up the path, adjusts it if necessary (when on a DoIT shared hosting host), and converts it to a File object
    • doGetFile

      public File doGetFile​(String name, String defVal)
    • getGuiClientUrl

      public static String getGuiClientUrl​(boolean dev)
      The URL string for the Rule Game GUI Client.
      Parameters:
      dev - True for the dev version, false for prod
      Returns:
      The URL string, or the default (a URL on same server and port)
    • doGetGuiClientUrl

      public String doGetGuiClientUrl​(boolean dev)
    • toString

      public String toString()
      Overrides:
      toString in class Object