Package org.sakaiproject.util
Class BasicConfigItem
- java.lang.Object
-
- org.sakaiproject.util.BasicConfigItem
-
- All Implemented Interfaces:
ServerConfigurationService.ConfigItem
public class BasicConfigItem extends Object implements ServerConfigurationService.ConfigItem
Provides an easy way for someone to create aServerConfigurationService.ConfigItemwhich is valid without having to build their own implementation Use the static methods to easily generate theServerConfigurationService.ConfigItemfor use with the methods in theServerConfigurationService- Author:
- Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu)
-
-
Field Summary
Fields Modifier and Type Field Description protected ObjectdefaultValuethe default value for this config (null indicates it is not set)protected Stringdescriptionthe human readable description for this configuration value (null if not set)protected booleandynamicIndicates if this config item is dynamic (true) or static (false).protected Stringnamethe name/key for this configuration valueprotected Stringsourcethe name of the most recent source for this config value (e.g. sakai/sakai.properties)protected Objectvaluethe actual stored value for this config (null indicates it is not set)
-
Constructor Summary
Constructors Modifier Constructor Description protectedBasicConfigItem()Do NOT use this - INTERNAL ONLYBasicConfigItem(String name, Object value, Object defaultValue, String description, String source, boolean dynamic)Constructor for when you know the source, leave defaultValue null if you do not know have one OR if this is a registration for a defaultValue then fill in the defaultValue and leave the value null (either value OR defaultValue MUST be set) Recommend use of the static make methods unless you know what you are doing
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intchanged(Object value, String source)Called whenever this config item is changedServerConfigurationService.ConfigItemcopy()Duplicate this config item This is mostly used to ensure we do not send the internal objects out where they could be changedintgetChanged()ObjectgetDefaultValue()StringgetDescription()ServerConfigurationService.ConfigHistory[]getHistory()StringgetName()intgetRequested()StringgetSource()StringgetType()ObjectgetValue()intgetVersion()booleanisDefaulted()booleanisDynamic()Indicates is this config item is dynamic or static (default is static)booleanisRegistered()booleanisSecured()static ServerConfigurationService.ConfigItemmakeConfigItem(String name, Object value, Object defaultValue, String description, String source, boolean dynamic)Create a complete config item with default value and a description which can be dynamicstatic ServerConfigurationService.ConfigItemmakeConfigItem(String name, Object value, String source)Create a basic config item which stores a valuestatic ServerConfigurationService.ConfigItemmakeConfigItem(String name, Object value, String source, boolean dynamic)Create a basic config item which can be dynamicstatic ServerConfigurationService.ConfigItemmakeConfigItem(String name, Object value, String description, String source, boolean dynamic)Create a basic config item with description which can be dynamicstatic ServerConfigurationService.ConfigItemmakeDefaultedConfigItem(String name, Object defaultValue, String source)Create a config item which stores a default value but does not have an actual valueintrequested()Called whenever this config item is requested
-
-
-
Field Detail
-
name
protected String name
the name/key for this configuration value
-
value
protected Object value
the actual stored value for this config (null indicates it is not set)
-
defaultValue
protected Object defaultValue
the default value for this config (null indicates it is not set)
-
description
protected String description
the human readable description for this configuration value (null if not set)
-
source
protected String source
the name of the most recent source for this config value (e.g. sakai/sakai.properties)
-
dynamic
protected boolean dynamic
Indicates if this config item is dynamic (true) or static (false). Default false, static config items cannot be changed at runtime, dynamic items can be changed at runtime
-
-
Constructor Detail
-
BasicConfigItem
protected BasicConfigItem()
Do NOT use this - INTERNAL ONLY
-
BasicConfigItem
public BasicConfigItem(String name, Object value, Object defaultValue, String description, String source, boolean dynamic)
Constructor for when you know the source, leave defaultValue null if you do not know have one OR if this is a registration for a defaultValue then fill in the defaultValue and leave the value null (either value OR defaultValue MUST be set) Recommend use of the static make methods unless you know what you are doing- Parameters:
name- the config name key (the ID of this configuration setting)value- [OPTIONAL] the config value (this IS the configurations setting)defaultValue- [OPTIONAL] the default value for this configdescription- [OPTIONAL] the human readable description of this config settingsource- [OPTIONAL] the name of the origin for this config setting (defaults to UNKNOWN)dynamic- default false, static config items cannot be changed at runtime, dynamic items can be changed at runtime
-
-
Method Detail
-
requested
public int requested()
Description copied from interface:ServerConfigurationService.ConfigItemCalled whenever this config item is requested- Specified by:
requestedin interfaceServerConfigurationService.ConfigItem- Returns:
- the current number of times requested
-
changed
public int changed(Object value, String source)
Description copied from interface:ServerConfigurationService.ConfigItemCalled whenever this config item is changed- Specified by:
changedin interfaceServerConfigurationService.ConfigItem- Parameters:
value- the new valuesource- the source which is making the change- Returns:
- the current number of times the item was changed
-
copy
public ServerConfigurationService.ConfigItem copy()
Description copied from interface:ServerConfigurationService.ConfigItemDuplicate this config item This is mostly used to ensure we do not send the internal objects out where they could be changed- Specified by:
copyin interfaceServerConfigurationService.ConfigItem- Returns:
- a config item with all the same values
-
getName
public String getName()
- Specified by:
getNamein interfaceServerConfigurationService.ConfigItem- Returns:
- the name/key for this configuration value
-
getValue
public Object getValue()
- Specified by:
getValuein interfaceServerConfigurationService.ConfigItem- Returns:
- the actual stored value for this config (null indicates it is not set)
-
getType
public String getType()
- Specified by:
getTypein interfaceServerConfigurationService.ConfigItem- Returns:
- the type of the value (string, int, boolean, array) - from
ServerConfigurationService.TYPES
-
getDescription
public String getDescription()
- Specified by:
getDescriptionin interfaceServerConfigurationService.ConfigItem- Returns:
- the human readable description of this configuration value
-
getSource
public String getSource()
- Specified by:
getSourcein interfaceServerConfigurationService.ConfigItem- Returns:
- the name of the most recent source for this config value (e.g. sakai/sakai.properties)
-
getDefaultValue
public Object getDefaultValue()
- Specified by:
getDefaultValuein interfaceServerConfigurationService.ConfigItem- Returns:
- the default value for this config (null indicates it is not set)
-
getRequested
public int getRequested()
- Specified by:
getRequestedin interfaceServerConfigurationService.ConfigItem- Returns:
- the number of times the config value was requested (or looked up)
-
getChanged
public int getChanged()
- Specified by:
getChangedin interfaceServerConfigurationService.ConfigItem- Returns:
- the number of times this config value was changed (or updated)
-
getVersion
public int getVersion()
- Specified by:
getVersionin interfaceServerConfigurationService.ConfigItem- Returns:
- the version of this config item (a newly created item is version 1), incremented with each change
-
getHistory
public ServerConfigurationService.ConfigHistory[] getHistory()
- Specified by:
getHistoryin interfaceServerConfigurationService.ConfigItem- Returns:
- the history of the config item over time (empty array if it has never changed)
-
isRegistered
public boolean isRegistered()
- Specified by:
isRegisteredin interfaceServerConfigurationService.ConfigItem- Returns:
- indicates if this config is registered (true) or if it is only requested (false) (requested means someone asked for it but the setting has not been stored in the config service)
-
isDefaulted
public boolean isDefaulted()
- Specified by:
isDefaultedin interfaceServerConfigurationService.ConfigItem- Returns:
- indicates is this config is has a default value defined (this can only be known for items which are requested)
-
isSecured
public boolean isSecured()
- Specified by:
isSecuredin interfaceServerConfigurationService.ConfigItem- Returns:
- indicates is this config value should not be revealed because there are security implications
-
isDynamic
public boolean isDynamic()
Description copied from interface:ServerConfigurationService.ConfigItemIndicates is this config item is dynamic or static (default is static)- Specified by:
isDynamicin interfaceServerConfigurationService.ConfigItem- Returns:
- true is this config can be modified at runtime (dynamic), false if runtime changes are not allowed (static)
-
makeDefaultedConfigItem
public static ServerConfigurationService.ConfigItem makeDefaultedConfigItem(String name, Object defaultValue, String source)
Create a config item which stores a default value but does not have an actual value- Parameters:
name- the config name keydefaultValue- the default value for this configsource- the origin of this config setting- Returns:
- the
ServerConfigurationService.ConfigItemwhich can be registered with theServerConfigurationService
-
makeConfigItem
public static ServerConfigurationService.ConfigItem makeConfigItem(String name, Object value, String source)
Create a basic config item which stores a value- Parameters:
name- the config name keyvalue- the default value for this configsource- the origin of this config setting- Returns:
- the
ServerConfigurationService.ConfigItemwhich can be registered with theServerConfigurationService
-
makeConfigItem
public static ServerConfigurationService.ConfigItem makeConfigItem(String name, Object value, String source, boolean dynamic)
Create a basic config item which can be dynamic- Parameters:
name- the config name keyvalue- the default value for this configsource- the origin of this config settingdynamic- default false, static config items cannot be changed at runtime, dynamic items can be changed at runtime- Returns:
- the
ServerConfigurationService.ConfigItemwhich can be registered with theServerConfigurationService
-
makeConfigItem
public static ServerConfigurationService.ConfigItem makeConfigItem(String name, Object value, String description, String source, boolean dynamic)
Create a basic config item with description which can be dynamic- Parameters:
name- the config name keyvalue- the default value for this configdescription- the human readable description of this configuration valuesource- the origin of this config settingdynamic- default false, static config items cannot be changed at runtime, dynamic items can be changed at runtime- Returns:
- the
ServerConfigurationService.ConfigItemwhich can be registered with theServerConfigurationService
-
makeConfigItem
public static ServerConfigurationService.ConfigItem makeConfigItem(String name, Object value, Object defaultValue, String description, String source, boolean dynamic)
Create a complete config item with default value and a description which can be dynamic- Parameters:
name- the config name keyvalue- the default value for this configdefaultValue- the default value for this configdescription- the human readable description of this configuration valuesource- the origin of this config settingdynamic- default false, static config items cannot be changed at runtime, dynamic items can be changed at runtime- Returns:
- the
ServerConfigurationService.ConfigItemwhich can be registered with theServerConfigurationService
-
-