Package ch.autumo.commons.generic
Class PropertiesManager
java.lang.Object
ch.autumo.commons.generic.PropertiesManager
- Direct Known Subclasses:
ConfigurationManager
Generic father for all singletons/manager that must be
initialized with a configuration.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringStandard configuration path.protected PropertiesThe general configuration properties ('cfg/app.cfg').protected static booleanInitialized?protected booleanRuns within desktop context?protected booleanRuns within servlet context?protected static final org.slf4j.LoggerLogger.protected static StringROOT path. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the file name of the base configuration.Returns the full base path, where the base configuration is.Get internal properties.Get app root path.voidinitialize(String configFile) Initialize with standard config path 'ROOTPATH/cfg'.voidinitializeDesktop(String desktopCfgFile, String appName) Initialize with desktop configuration which must have been created beforehand by the desktop application!abstract voidinitializeManager(Properties config) Customized initialization with configuration properties.voidinitializeRelative(String relativePath) Initialize with path 'ROOTPATH/given-path-and-file.cfg'.voidinitializeWithFullPath(String configFilePath) Customized initialization with full configuration file path.voidinitializeWithFullPath(String configFilePath, boolean isWithinServlet) Customized initialization with full configuration file path.voidinitializeWithProperties(Properties properties) Customized initialization with already loaded properties.static booleanIs inizialized?booleanisRemote()Returns true if it doesn't run server-side.booleanReturn true, if this configuration manager runs within a desktop otherwise false.booleanReturn true, if this configuration manager runs within a servlet otherwise false.updateProperty(String key, String value) Update or add a value to the internal properties.
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOGLogger. -
CONFIG_PATH
Standard configuration path.- See Also:
-
rootPath
ROOT path. -
isInitialized
protected static boolean isInitializedInitialized? -
generalProps
The general configuration properties ('cfg/app.cfg'). -
isWithinServlet
protected boolean isWithinServletRuns within servlet context? -
isWithinDesktop
protected boolean isWithinDesktopRuns within desktop context?
-
-
Constructor Details
-
PropertiesManager
protected PropertiesManager()Default constructor.
-
-
Method Details
-
getFullConfigBasePath
Returns the full base path, where the base configuration is.- Returns:
- base path
-
getConfigFileName
Returns the file name of the base configuration.- Returns:
- file name
-
getProperties
Get internal properties.- Returns:
- internal properties
-
updateProperty
Update or add a value to the internal properties.- Parameters:
key- keyvalue- vane- Returns:
- old value if any or null
-
getRootPath
Get app root path.- Returns:
- root path
-
isInitialized
public static boolean isInitialized()Is inizialized?- Returns:
- true if initialized
-
initialize
Initialize with standard config path 'ROOTPATH/cfg'.- Parameters:
configFile- configuration file name ('app.cfg')- Throws:
Exception- if configuration file initialization fails
-
initializeRelative
Initialize with path 'ROOTPATH/given-path-and-file.cfg'.- Parameters:
relativePath- relative path- Throws:
Exception- if configuration file initialization fails
-
initializeWithFullPath
Customized initialization with full configuration file path. No servlet context!- Parameters:
configFilePath- full path to full configuration file path- Throws:
Exception- if configuration file initialization fails
-
initializeWithFullPath
Customized initialization with full configuration file path.- Parameters:
configFilePath- full path to full configuration file pathisWithinServlet- indicate if this initialization is made in a servlet context or not- Throws:
Exception- if configuration file initialization fails
-
initializeWithProperties
Customized initialization with already loaded properties. Can be called more than once.- Parameters:
properties- configuration properties- Throws:
Exception- if initilization fails
-
initializeDesktop
Initialize with desktop configuration which must have been created beforehand by the desktop application!- Parameters:
desktopCfgFile- only the file name without path, e.g. 'myapp.cfg'appName- application name- Throws:
Exception- if configuration file initilization fails
-
runsWithinServletContext
public boolean runsWithinServletContext()Return true, if this configuration manager runs within a servlet otherwise false.- Returns:
- true is is within servlet context
-
runsWithinDesktopContext
public boolean runsWithinDesktopContext()Return true, if this configuration manager runs within a desktop otherwise false.- Returns:
- true is is within desktop context
-
isRemote
public boolean isRemote()Returns true if it doesn't run server-side.- Returns:
- false if server-side
-
initializeManager
Customized initialization with configuration properties.- Parameters:
config- configuration properties- Throws:
Exception- if manager cannot be initialized
-