Class MCRConfigurationDir


public class MCRConfigurationDir extends Object
This helper class determines in which directory to look for addition configuration files. The configuration directory can be set with the system property or environment variable MCR.ConfigDir. The directory path is build this way:
  1. System property MCR.Home defined
    1. System.getProperty("MCR.Home")
    2. {prefix+'-'}{appName}
  2. Windows:
    2. MyCoRe
    3. {prefix+'-'}{appName}
  3. other systems
    1. $HOME
    2. .mycore
    3. {prefix+'-'}{appName}
{prefix} can be defined by setting System property MCR.DataPrefix. {appName} is always lowercase String determined using this
  1. System property MCR.AppName
  2. System property MCR.NameOfProject
  3. Servlet Context Init Parameter appName
  4. Servlet Context Path (if not root context, ServletContext.getContextPath())
  5. Servlet Context Name (ServletContext.getServletContextName()) with space characters removed
  6. base name of jar including this class
  7. the String "default"
Thomas Scheffler (yagee)
See Also:
  • Field Details

  • Constructor Details

    • MCRConfigurationDir

      public MCRConfigurationDir()
  • Method Details

    • getConfigurationDirectory

      public static File getConfigurationDirectory()
      Returns the configuration directory for this MyCoRe instance.
      null if System property "MCR.DisableConfigDir" is set.
    • getConfigFile

      public static File getConfigFile(String relativePath)
      Returns a File object, if getConfigurationDirectory() does not return null and directory exists.
      relativePath - relative path to file or directory with configuration directory as base.
      null if configuration directory does not exist or is disabled.
    • getConfigResource

      public static URL getConfigResource(String relativePath)
      Returns URL of a config resource. Same as getConfigResource(String, ClassLoader) with second argument null.
      relativePath - as defined in getConfigFile(String)
    • getConfigResource

      public static URL getConfigResource(String relativePath, ClassLoader classLoader)
      Returns URL of a config resource. If getConfigFile(String) returns an existing file for "resources"+{relativePath}, its URL is returned. In any other case this method returns the same as ClassLoader.getResource(String)
      relativePath - as defined in getConfigFile(String)
      classLoader - a classLoader to resolve the resource (see above), null defaults to this class' class loader