Class DeploymentConfiguration


  • public final class DeploymentConfiguration
    extends java.lang.Object
    Manages the various properties and configuration related to deployment. See: http://download.oracle.com/javase/1.5.0/docs/guide/deployment/deployment-guide/properties.html
    • Field Detail

      • LOG

        private static final Logger LOG
      • LOCAL_DEPLOYMENT_PROPERTIES_FILE_PATH

        public static final java.lang.String LOCAL_DEPLOYMENT_PROPERTIES_FILE_PATH
        See Also:
        Constant Field Values
      • USER_HOME_DIR_TOKEN

        public static final java.lang.String USER_HOME_DIR_TOKEN
        See Also:
        Constant Field Values
      • userComments

        private java.lang.String userComments
      • loadingException

        private javax.naming.ConfigurationException loadingException
      • systemPropertiesMandatory

        private boolean systemPropertiesMandatory
        is it mandatory to load the system properties?
      • systemPropertiesFile

        private java.net.URL systemPropertiesFile
        The system's subdirResult deployment.config file
      • userDeploymentFileDescriptor

        private final InfrastructureFileDescriptor userDeploymentFileDescriptor
        Source of always right and only path to file (even if underlying path changes)
      • userPropertiesFile

        private java.io.File userPropertiesFile
        The user's subdirResult deployment.config file
      • currentConfiguration

        private final java.util.Map<java.lang.String,​Setting> currentConfiguration
        the current deployment properties
      • unchangeableConfiguration

        private final java.util.Map<java.lang.String,​Setting> unchangeableConfiguration
        the deployment properties that cannot be changed
      • pattern

        private static final java.text.SimpleDateFormat pattern
    • Constructor Detail

      • DeploymentConfiguration

        public DeploymentConfiguration()
    • Method Detail

      • getSetting

        private java.util.Optional<Setting> getSetting​(java.lang.String key)
      • isLocked

        public boolean isLocked​(java.lang.String key)
      • lock

        public void lock​(java.lang.String key)
      • unlock

        public void unlock​(java.lang.String key)
      • setLoadingException

        public void setLoadingException​(javax.naming.ConfigurationException ex)
      • getLoadingException

        public javax.naming.ConfigurationException getLoadingException()
      • resetToDefaults

        public void resetToDefaults()
      • checkUrl

        static boolean checkUrl​(java.net.URL file)
      • load

        public void load()
                  throws javax.naming.ConfigurationException
        Initialize this deployment configuration by reading configuration files. Generally, it will try to continue and ignore errors it finds (such as file not found).
        Throws:
        javax.naming.ConfigurationException - if it encounters a fatal error.
      • load

        public void load​(boolean fixIssues)
                  throws javax.naming.ConfigurationException,
                         java.net.MalformedURLException
        Initialize this deployment configuration by reading configuration files. Generally, it will try to continue and ignore errors it finds (such as file not found).
        Parameters:
        fixIssues - If true, fix issues that are discovered when reading configuration by resorting to the default values
        Throws:
        javax.naming.ConfigurationException - if it encounters a fatal error.
        java.net.MalformedURLException
      • copyTo

        public void copyTo​(java.util.Properties target)
        Copies the current configuration into the target
        Parameters:
        target - properties where to copy actual ones
      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        Get the value for the given key
        Parameters:
        key - the property key
        Returns:
        the value for the key, or null if it can not be found
      • getPropertyAsList

        public java.util.List<java.lang.String> getPropertyAsList​(java.lang.String key)
      • getAllPropertyNames

        public java.util.Set<java.lang.String> getAllPropertyNames()
        Returns:
        a Set containing all the property names
      • getRaw

        public java.util.Map<java.lang.String,​Setting> getRaw()
        Returns:
        a map containing property names and the corresponding settings
      • setProperty

        public void setProperty​(java.lang.String key,
                                java.lang.String value)
        Sets the value of corresponding to the key. If the value has been marked as locked, it is not changed
        Parameters:
        key - the key
        value - the value to be associated with the key
      • checkAndFixConfiguration

        private void checkAndFixConfiguration​(java.util.Map<java.lang.String,​Setting> initial)
        Check that the configuration is valid. If there are invalid values,set those values to the default values. This is done by using check() method of the ValueChecker for each setting on the actual value. Fixes are made in-place.
        Parameters:
        initial - a map representing the initial configuration
      • processPropertiesWithHomeDirToken

        private void processPropertiesWithHomeDirToken​(java.util.Map<java.lang.String,​Setting> properties)
      • findSystemConfigFile

        private java.net.URL findSystemConfigFile()
                                           throws java.net.MalformedURLException
        Looks in the following locations:
         Unix:
           - /etc/.java/deployment.config
           - ${JAVA_HOME}/lib/deployment.config
        
         Windows:
           - ${WINDIR}\Sun\Java\deployment.config
           - ${JAVA_HOME}/lib/deployment.config
         
        Returns:
        the location of system-level deployment.config file, or null if none can be found
        Throws:
        java.net.MalformedURLException
      • loadSystemConfiguration

        private boolean loadSystemConfiguration​(java.net.URL configFile)
                                         throws javax.naming.ConfigurationException
        Reads the system configuration file and sets the relevant system-properties related variables
        Throws:
        javax.naming.ConfigurationException
      • loadProperties

        static java.util.Map<java.lang.String,​Setting> loadProperties​(DeploymentConfiguration.ConfigType type,
                                                                            java.net.URL file,
                                                                            boolean mandatory)
                                                                     throws javax.naming.ConfigurationException
        Loads the properties from the given file into a map of Settings. If the given properties file does not exist or the URL is invalid and not mandatory, an empty Map is returned. If the file is considered to be mandatory but does not exist, a ConfigurationException is thrown.
        Parameters:
        type - the ConfigType to load
        file - the File to load Properties from
        mandatory - indicates if reading this file is mandatory
        Throws:
        javax.naming.ConfigurationException - if the file is mandatory but does not exist or cannot be read properly
      • save

        public void save()
                  throws java.io.IOException
        Saves all properties that are not part of default or system properties
        Throws:
        java.io.IOException - if unable to save the file
        java.lang.IllegalStateException - if save() is called before load()
      • parsePropertiesFile

        private static java.util.Map<java.lang.String,​Setting> parsePropertiesFile​(java.net.URL propertiesFile)
                                                                                  throws java.io.IOException
        Reads a properties file and returns a map representing the properties
        Parameters:
        propertiesFile - the file to read Properties from
        Throws:
        java.io.IOException - if an IO problem occurs
      • mergeMaps

        private void mergeMaps​(java.util.Map<java.lang.String,​Setting> finalMap,
                               java.util.Map<java.lang.String,​Setting> srcMap)
        Merges two maps while respecting whether the values have been locked or not. All values from srcMap are put into finalMap, replacing values in finalMap if necessary, unless the value is present and marked as locked in finalMap
        Parameters:
        finalMap - the destination for putting values
        srcMap - the source for reading key value pairs
      • dumpConfiguration

        private static void dumpConfiguration​(java.util.Map<java.lang.String,​Setting> config,
                                              java.io.PrintStream out)
        Dumps the configuration to the PrintStream
        Parameters:
        config - a map of key,value pairs representing the configuration to dump
        out - the PrintStream to write data to
      • loadComments

        private static java.lang.String loadComments​(java.net.URL path)
      • VVPossibleBrowserValues

        public static java.lang.String VVPossibleBrowserValues()
        convenient method to show VVPossibleBrowserValues with all four params
        Returns:
        translation of VVPossibleBrowserValues with all params in