org.sakaiproject.util
Class BasicConfigItem

java.lang.Object
  extended by org.sakaiproject.util.BasicConfigItem
All Implemented Interfaces:
ServerConfigurationService.ConfigItem

public class BasicConfigItem
extends Object
implements ServerConfigurationService.ConfigItem

Provides an easy for someone to create a ServerConfigurationService.ConfigItem which is valid without having to build their own implementation Use the static methods to easily generate the ServerConfigurationService.ConfigItem for use with the methods in the ServerConfigurationService

Author:
Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu)

Field Summary
protected  Object defaultValue
          the default value for this config (null indicates it is not set)
protected  String name
          the name/key for this configuration value
protected  String source
          the name of the most recent source for this config value (e.g.
protected  Object value
          the actual stored value for this config (null indicates it is not set)
 
Constructor Summary
protected BasicConfigItem()
          Do NOT use this - INTERNAL ONLY
  BasicConfigItem(String name, Object value, Object defaultValue, String source)
          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)
 
Method Summary
 int changed(Object value, String source)
          Called whenever this config item is changed
 ServerConfigurationService.ConfigItem copy()
          Duplicate this config item This is mostly used to ensure we do not send the internal objects out where they could be changed
 int getChanged()
           
 Object getDefaultValue()
           
 ServerConfigurationService.ConfigHistory[] getHistory()
           
 String getName()
           
 int getRequested()
           
 String getSource()
           
 String getType()
           
 Object getValue()
           
 int getVersion()
           
 boolean isDefaulted()
           
 boolean isRegistered()
           
 boolean isSecured()
           
static ServerConfigurationService.ConfigItem makeConfigItem(String name, Object value, String source)
          Create a config item which stores a default value but does not have an actual value
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
 int requested()
          Called whenever this config item is requested
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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)


source

protected String source
the name of the most recent source for this config value (e.g. sakai/sakai.properties)

Constructor Detail

BasicConfigItem

protected BasicConfigItem()
Do NOT use this - INTERNAL ONLY


BasicConfigItem

public BasicConfigItem(String name,
                       Object value,
                       Object defaultValue,
                       String source)
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)

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 config
source - [OPTIONAL] the name of the origin for this config setting (defaults to UNKNOWN)
Method Detail

requested

public int requested()
Description copied from interface: ServerConfigurationService.ConfigItem
Called whenever this config item is requested

Specified by:
requested in interface ServerConfigurationService.ConfigItem
Returns:
the current number of times requested

changed

public int changed(Object value,
                   String source)
Description copied from interface: ServerConfigurationService.ConfigItem
Called whenever this config item is changed

Specified by:
changed in interface ServerConfigurationService.ConfigItem
Parameters:
value - the new value
source - 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.ConfigItem
Duplicate this config item This is mostly used to ensure we do not send the internal objects out where they could be changed

Specified by:
copy in interface ServerConfigurationService.ConfigItem
Returns:
a config item with all the same values

getName

public String getName()
Specified by:
getName in interface ServerConfigurationService.ConfigItem
Returns:
the name/key for this configuration value

getValue

public Object getValue()
Specified by:
getValue in interface ServerConfigurationService.ConfigItem
Returns:
the actual stored value for this config (null indicates it is not set)

getType

public String getType()
Specified by:
getType in interface ServerConfigurationService.ConfigItem
Returns:
the type of the value (string, int, boolean, array)

getSource

public String getSource()
Specified by:
getSource in interface ServerConfigurationService.ConfigItem
Returns:
the name of the most recent source for this config value (e.g. sakai/sakai.properties)

getDefaultValue

public Object getDefaultValue()
Specified by:
getDefaultValue in interface ServerConfigurationService.ConfigItem
Returns:
the default value for this config (null indicates it is not set)

getRequested

public int getRequested()
Specified by:
getRequested in interface ServerConfigurationService.ConfigItem
Returns:
the number of times the config value was requested (or looked up)

getChanged

public int getChanged()
Specified by:
getChanged in interface ServerConfigurationService.ConfigItem
Returns:
the number of times this config value was changed (or updated)

getVersion

public int getVersion()
Specified by:
getVersion in interface ServerConfigurationService.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:
getHistory in interface ServerConfigurationService.ConfigItem
Returns:
the history of the config item over time (empty array if it has never changed)

isRegistered

public boolean isRegistered()
Specified by:
isRegistered in interface ServerConfigurationService.ConfigItem
Returns:
indicates is 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:
isDefaulted in interface ServerConfigurationService.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:
isSecured in interface ServerConfigurationService.ConfigItem
Returns:
indicates is this config value should not be revealed because there are security implications

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 key
defaultValue - the default value for this config
source - the origin of this config setting
Returns:
the ServerConfigurationService.ConfigItem which can be registered with the ServerConfigurationService

makeConfigItem

public static ServerConfigurationService.ConfigItem makeConfigItem(String name,
                                                                   Object value,
                                                                   String source)
Create a config item which stores a default value but does not have an actual value

Parameters:
name - the config name key
defaultValue - the default value for this config
source - the origin of this config setting
Returns:
the ServerConfigurationService.ConfigItem which can be registered with the ServerConfigurationService


Copyright © 2003-2012 The Sakai Foundation. All Rights Reserved.