Class DeploymentConfiguration

java.lang.Object
net.sourceforge.jnlp.config.DeploymentConfiguration

public final class DeploymentConfiguration extends 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 Details

    • LOG

      private static final Logger LOG
    • LOCKED_POSTFIX

      public static final String LOCKED_POSTFIX
      See Also:
    • LOCAL_DEPLOYMENT_PROPERTIES_FILE_PATH

      public static final String LOCAL_DEPLOYMENT_PROPERTIES_FILE_PATH
      See Also:
    • USER_HOME_DIR_TOKEN

      public static final String USER_HOME_DIR_TOKEN
      See Also:
    • userComments

      private String userComments
    • loadingException

      private ConfigurationException loadingException
    • systemPropertiesMandatory

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

      private 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 File userPropertiesFile
      The user's subdirResult deployment.config file
    • currentConfiguration

      private final Map<String,Setting> currentConfiguration
      the current deployment properties
    • unchangeableConfiguration

      private final Map<String,Setting> unchangeableConfiguration
      the deployment properties that cannot be changed
    • pattern

      private static final SimpleDateFormat pattern
  • Constructor Details

    • DeploymentConfiguration

      public DeploymentConfiguration()
    • DeploymentConfiguration

      DeploymentConfiguration(InfrastructureFileDescriptor configFile)
  • Method Details

    • getSetting

      private Optional<Setting> getSetting(String key)
    • isLocked

      public boolean isLocked(String key)
    • lock

      public void lock(String key)
    • unlock

      public void unlock(String key)
    • setLoadingException

      public void setLoadingException(ConfigurationException ex)
    • getLoadingException

      public ConfigurationException getLoadingException()
    • resetToDefaults

      public void resetToDefaults()
    • checkUrl

      static boolean checkUrl(URL file)
    • load

      public void load() throws 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:
      ConfigurationException - if it encounters a fatal error.
    • load

      public void load(boolean fixIssues) throws ConfigurationException, 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:
      ConfigurationException - if it encounters a fatal error.
      MalformedURLException
    • loadSystemProperties

      private Map<String,Setting> loadSystemProperties() throws MalformedURLException, ConfigurationException
      First loads the deployment.config file to determine the URL of the system properties. The deployment config file must contain a property with the key ConfigurationConstants.KEY_SYSTEM_CONFIG. Optionally it can require the system properties to exist with the kye ConfigurationConstants.KEY_SYSTEM_CONFIG_MANDATORY.
      Returns:
      the system properties
      Throws:
      MalformedURLException
      ConfigurationException
      See Also:
    • copyTo

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

      public String getProperty(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 List<String> getPropertyAsList(String key)
    • getAllPropertyNames

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

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

      public void setProperty(String key, 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(Map<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(Map<String,Setting> properties)
    • findSystemConfigFile

      private URL findSystemConfigFile() throws 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:
      MalformedURLException
    • loadSystemConfiguration

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

      static Map<String,Setting> loadProperties(DeploymentConfiguration.ConfigType type, URL file, boolean mandatory) throws 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:
      ConfigurationException - if the file is mandatory but does not exist or cannot be read properly
    • save

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

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

      private void mergeMaps(Map<String,Setting> finalMap, Map<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(Map<String,Setting> config, 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 String loadComments(URL path)
    • VVPossibleBrowserValues

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