Package org.mycore.common.config
Class MCRConfigurationDir
java.lang.Object
org.mycore.common.config.MCRConfigurationDir
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:
- System property
MCR.Home
definedSystem.getProperty("MCR.Home")
{prefix+'-'}{appName}
- Windows:
%LOCALAPPDATA%
- MyCoRe
{prefix+'-'}{appName}
- other systems
$HOME
- .mycore
{prefix+'-'}{appName}
{prefix}
can be defined by setting System property MCR.DataPrefix
.
{appName}
is always lowercase String determined using this
- System property
MCR.AppName
- System property
MCR.NameOfProject
- Servlet Context Init Parameter
appName
- Servlet Context Path (if not root context,
ServletContext.getContextPath()
) - Servlet Context Name (
ServletContext.getServletContextName()
) with space characters removed - base name of jar including this class
- the String
"default"
- Since:
- 2013.12
- Author:
- Thomas Scheffler (yagee)
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic File
getConfigFile
(String relativePath) Returns a File object, ifgetConfigurationDirectory()
does not returnnull
and directory exists.static URL
getConfigResource
(String relativePath) Returns URL of a config resource.static URL
getConfigResource
(String relativePath, ClassLoader classLoader) Returns URL of a config resource.static File
Returns the configuration directory for this MyCoRe instance.
-
Field Details
-
DISABLE_CONFIG_DIR_PROPERTY
- See Also:
-
CONFIGURATION_DIRECTORY_PROPERTY
- See Also:
-
-
Constructor Details
-
MCRConfigurationDir
public MCRConfigurationDir()
-
-
Method Details
-
getConfigurationDirectory
Returns the configuration directory for this MyCoRe instance.- Returns:
- null if System property "MCR.DisableConfigDir" is set.
-
getConfigFile
Returns a File object, ifgetConfigurationDirectory()
does not returnnull
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
Returns URL of a config resource. Same asgetConfigResource(String, ClassLoader)
with second argumentnull
.- Parameters:
relativePath
- as defined ingetConfigFile(String)
-
getConfigResource
Returns URL of a config resource. IfgetConfigFile(String)
returns an existing file for "resources"+{relativePath}, its URL is returned. In any other case this method returns the same asClassLoader.getResource(String)
- Parameters:
relativePath
- as defined ingetConfigFile(String)
classLoader
- a classLoader to resolve the resource (see above), null defaults to this class' class loader
-