Class MCRConfigurationDir

java.lang.Object
org.mycore.common.config.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:
    1. %LOCALAPPDATA%
    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"
Since:
2013.12
Author:
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.
      Returns:
      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.
      Parameters:
      relativePath - relative path to file or directory with configuration directory as base.
      Returns:
      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.
      Parameters:
      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)
      Parameters:
      relativePath - as defined in getConfigFile(String)
      classLoader - a classLoader to resolve the resource (see above), null defaults to this class' class loader