Class DaemonConfiguration


  • public final class DaemonConfiguration
    extends java.lang.Object
    Used by jsvc for Daemon configuration.

    Configuration is read from properties file. If no properties file is given the daemon.properties is used from the current directory.

    The properties file can have property values expanded at runtime by using System properties or execution environment. The part of the property value between ${ and } will be used as System property or environment key. If found then the entire ${foo} will be replaced by the value of either system property or environment variable named foo.

    If no variable is found the ${foo} will be passed as is. In case of $${foo} this will be unescaped and resulting value will be ${foo}.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String BTOKEN  
      private java.util.Properties configurationProperties  
      protected static java.lang.String DEFAULT_CONFIG
      Default configuration file name.
      private static java.lang.String ETOKEN  
      protected static java.lang.String PREFIX
      Property prefix
      private java.util.Properties systemProperties  
    • Constructor Summary

      Constructors 
      Constructor Description
      DaemonConfiguration()
      Default constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String expandProperty​(java.lang.String propValue)  
      java.lang.String getProperty​(java.lang.String name)
      Gets the configuration property.
      java.lang.String[] getPropertyArray​(java.lang.String name)
      Gets the configuration property array.
      boolean load​(java.lang.String fileName)
      Loads the configuration properties file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_CONFIG

        protected static final java.lang.String DEFAULT_CONFIG
        Default configuration file name.
        See Also:
        Constant Field Values
      • configurationProperties

        private final java.util.Properties configurationProperties
      • systemProperties

        private final java.util.Properties systemProperties
    • Constructor Detail

      • DaemonConfiguration

        public DaemonConfiguration()
        Default constructor
    • Method Detail

      • load

        public boolean load​(java.lang.String fileName)
        Loads the configuration properties file.
        Parameters:
        fileName - The properties file to load.
        Returns:
        true if the file was loaded.
      • expandProperty

        private java.lang.String expandProperty​(java.lang.String propValue)
                                         throws java.text.ParseException
        Throws:
        java.text.ParseException
      • getProperty

        public java.lang.String getProperty​(java.lang.String name)
                                     throws java.text.ParseException
        Gets the configuration property.
        Parameters:
        name - The name of the property to get.
        Returns:
        Configuration property including any expansion/replacement
        Throws:
        java.text.ParseException - if the property is wrongly formatted.
      • getPropertyArray

        public java.lang.String[] getPropertyArray​(java.lang.String name)
                                            throws java.text.ParseException
        Gets the configuration property array.

        Property array is constructed form the list of properties which end with [index]

         daemon.arg[0] = argument 1
         daemon.arg[1] = argument 2
         daemon.arg[2] = argument 3
         
        Parameters:
        name - The name of the property array to get.
        Returns:
        Configuration property array including any expansion/replacement
        Throws:
        java.text.ParseException - if the property is wrongly formatted.