org.rhq.enterprise.communications.util.prefs
Class PreferencesUpgrade

java.lang.Object
  extended by org.rhq.enterprise.communications.util.prefs.PreferencesUpgrade
Direct Known Subclasses:
ServiceContainerConfigurationUpgrade

public abstract class PreferencesUpgrade
extends Object

Performs an upgrade of a set of preferences from one configuration schema version to another (where a set of preferences is tagged by what is called a "configuration schema version" or simply a "configuration version").

Subclasses need only implement getConfigurationSchemaVersionPreference() to indicate the name of the preference key that contains the configuration schema version number for the preferences to be upgraded and to ensure they override the constructor PreferencesUpgrade(List) passing in the appropriate upgrade steps. Calling upgrade(Preferences, int) on instances of a subclass will use those installed upgrade steps to perform the actual upgrade.

Author:
John Mazzitelli

Constructor Summary
PreferencesUpgrade(List<PreferencesUpgradeStep> upgrade_steps)
          Constructor for PreferencesUpgrade given a set of upgrade step instructions for each known, supported configuration schema version.
 
Method Summary
 int getConfigurationSchemaVersion(Preferences preferences)
          Given a set of preferences, this will ask for its configuration schema version.
abstract  String getConfigurationSchemaVersionPreference()
          Returns the name of the preference whose value is the configuration schema version of the entire set of preferences.
 void setConfigurationSchemaVersion(Preferences preferences, int version)
          Given a set of preferences, this will set its configuration schema version to the given version number.
 void upgrade(Preferences preferences, int upgrade_to_version)
          This will upgrade the given set of preferences to the given configuration schema version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreferencesUpgrade

public PreferencesUpgrade(List<PreferencesUpgradeStep> upgrade_steps)
Constructor for PreferencesUpgrade given a set of upgrade step instructions for each known, supported configuration schema version. The given list must be ordered from the lowest supported configuration version to the latest supported version.

Parameters:
upgrade_steps - the list of upgrade steps that are used to perform the upgrades from one version to another
Method Detail

upgrade

public void upgrade(Preferences preferences,
                    int upgrade_to_version)
This will upgrade the given set of preferences to the given configuration schema version. If the preferences are at that version or higher, this method does nothing.

Parameters:
preferences - the set of preferences to upgrade
upgrade_to_version - the configuration version to upgrade the preferences to

getConfigurationSchemaVersion

public int getConfigurationSchemaVersion(Preferences preferences)
Given a set of preferences, this will ask for its configuration schema version. If the version could not be determined, 0 is returned.

Parameters:
preferences - the set of preferences whose version is to be returned
Returns:
the version that the given set of preferences conforms to or 0 if unknown

setConfigurationSchemaVersion

public void setConfigurationSchemaVersion(Preferences preferences,
                                          int version)
Given a set of preferences, this will set its configuration schema version to the given version number.

Parameters:
preferences - the set of preferences whose version is to be set
version - the new version of the preferences

getConfigurationSchemaVersionPreference

public abstract String getConfigurationSchemaVersionPreference()
Returns the name of the preference whose value is the configuration schema version of the entire set of preferences.

Returns:
the name of the preference whose value is the configuration version integer


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.