Class PropertiesManager

java.lang.Object
ch.autumo.commons.generic.PropertiesManager
Direct Known Subclasses:
ConfigurationManager

public abstract class PropertiesManager extends Object
Generic father for all singletons/manager that must be initialized with a configuration.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      Logger.
    • CONFIG_PATH

      public static final String CONFIG_PATH
      Standard configuration path.
      See Also:
    • rootPath

      protected static String rootPath
      ROOT path.
    • isInitialized

      protected static boolean isInitialized
      Initialized?
    • generalProps

      protected Properties generalProps
      The general configuration properties ('cfg/app.cfg').
    • isWithinServlet

      protected boolean isWithinServlet
      Runs within servlet context?
    • isWithinDesktop

      protected boolean isWithinDesktop
      Runs within desktop context?
  • Constructor Details

    • PropertiesManager

      protected PropertiesManager()
      Default constructor.
  • Method Details

    • getFullConfigBasePath

      public String getFullConfigBasePath()
      Returns the full base path, where the base configuration is.
      Returns:
      base path
    • getConfigFileName

      public String getConfigFileName()
      Returns the file name of the base configuration.
      Returns:
      file name
    • getProperties

      public Properties getProperties()
      Get internal properties.
      Returns:
      internal properties
    • updateProperty

      public String updateProperty(String key, String value)
      Update or add a value to the internal properties.
      Parameters:
      key - key
      value - vane
      Returns:
      old value if any or null
    • getRootPath

      public String getRootPath()
      Get app root path.
      Returns:
      root path
    • isInitialized

      public static boolean isInitialized()
      Is inizialized?
      Returns:
      true if initialized
    • initialize

      public void initialize(String configFile) throws Exception
      Initialize with standard config path 'ROOTPATH/cfg'.
      Parameters:
      configFile - configuration file name ('app.cfg')
      Throws:
      Exception - if configuration file initialization fails
    • initializeRelative

      public void initializeRelative(String relativePath) throws Exception
      Initialize with path 'ROOTPATH/given-path-and-file.cfg'.
      Parameters:
      relativePath - relative path
      Throws:
      Exception - if configuration file initialization fails
    • initializeWithFullPath

      public void initializeWithFullPath(String configFilePath) throws Exception
      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

      public void initializeWithFullPath(String configFilePath, boolean isWithinServlet) throws Exception
      Customized initialization with full configuration file path.
      Parameters:
      configFilePath - full path to full configuration file path
      isWithinServlet - indicate if this initialization is made in a servlet context or not
      Throws:
      Exception - if configuration file initialization fails
    • initializeWithProperties

      public void initializeWithProperties(Properties properties) throws Exception
      Customized initialization with already loaded properties. Can be called more than once.
      Parameters:
      properties - configuration properties
      Throws:
      Exception - if initilization fails
    • initializeDesktop

      public void initializeDesktop(String desktopCfgFile, String appName) throws Exception
      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

      public abstract void initializeManager(Properties config) throws Exception
      Customized initialization with configuration properties.
      Parameters:
      config - configuration properties
      Throws:
      Exception - if manager cannot be initialized