Class XXProperties

  • All Implemented Interfaces:
    Serializable, Cloneable, Map<Object,​Object>

    public class XXProperties
    extends XProperties
    This extension of XProperties allows for loading XProperties with template resolution by flag -- use system and JVM properties or by supplying a template file. Each line is read and processed with the template, so you can have expressions line
         ${db.type}_${USER}=${NCSA_DEV_INPUT}/scripts/database.sh -u ${db.logon}
     
    and have the user name used as part of the property name. Note that in this example, the uppercase properties are from the OS, the lower case one is (assumed to be) a Java property passed to the JVM. this might resolve to the property named
         mysql_jeff
     
    with the value
         /home/ncsa/dev/scripts/database.sh -u oa4mp-user42
     

    Created by Jeff Gaynor
    on 8/22/23 at 9:41 AM

    See Also:
    Serialized Form
    • Constructor Detail

      • XXProperties

        public XXProperties()
    • Method Detail

      • load

        public void load​(String fileName,
                         boolean useSystemProperties)
                  throws IOException
        If true, use the system and environment properties for loading.
        Parameters:
        fileName -
        useSystemProperties - use system and environment properties as templates
        Throws:
        IOException
      • load

        public void load​(File file,
                         boolean useSystemProperties)
                  throws IOException
        Parameters:
        file -
        useSystemProperties - use system and environment properties as templates
        Throws:
        IOException
      • load

        public void load​(InputStream inputStream,
                         boolean useSystemProperties)
                  throws IOException
        Parameters:
        inputStream -
        useSystemProperties - use system and environment properties as templates
        Throws:
        IOException
      • load

        public void load​(Reader reader,
                         Map templates)
                  throws IOException
        Actual work method for this entire class
        Parameters:
        reader -
        templates -
        Throws:
        IOException
      • loadResource

        public void loadResource​(String resourceName,
                                 Map templates)
                          throws IOException
        Resolves the name as a resource in the local class loader, rather than as a file on the system.
        Parameters:
        resourceName -
        templates -
        Throws:
        IOException
      • loadResource

        public void loadResource​(String resourceName,
                                 boolean useSystemProperties)
                          throws IOException
        Parameters:
        resourceName -
        useSystemProperties - use system and environment properties as templates
        Throws:
        IOException
      • getAllProperties

        public Map<String,​String> getAllProperties()
        A Map of all the OS and java properties for use resolving configuration testing files. Java properties override OS properties. Typically given to the JVM at startup with a -D prefix, so to set the property named my.prop at startup for the application MyApp you'd write
             java -Dmy.prop="my-value" MyApp
         
        Note that this is pretty expensive so will be done only when called then stored, so you cannot update the properties on the fly. For that consider using getAllProperties(boolean).
        Returns:
      • getAllProperties

        public Map<String,​String> getAllProperties​(boolean reload)
        Force a reload of system properties.
        Parameters:
        reload - if true, properties are reloaded at each call. If false, they are cached.
        Returns:
      • main

        public static void main​(String[] args)