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 way 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 description
          the human readable description for this configuration value (null if not set)
protected  boolean dynamic
          Indicates if this config item is dynamic (true) or static (false).
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 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
 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()
           
 String getDescription()
           
 ServerConfigurationService.ConfigHistory[] getHistory()
           
 String getName()
           
 int getRequested()
           
 String getSource()
           
 String getType()
           
 Object getValue()
           
 int getVersion()
           
 boolean isDefaulted()
           
 boolean isDynamic()
          Indicates is this config item is dynamic or static (default is static)
 boolean isRegistered()
           
 boolean isSecured()
           
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
static ServerConfigurationService.ConfigItem makeConfigItem(String name, Object value, String source)
          Create a basic config item which stores a value
static ServerConfigurationService.ConfigItem makeConfigItem(String name, Object value, String source, boolean dynamic)
          Create a basic config item which can be dynamic
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
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)


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 config
description - [OPTIONAL] the human readable description of this config setting
source - [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.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) - from ServerConfigurationService.TYPES

getDescription

public String getDescription()
Specified by:
getDescription in interface ServerConfigurationService.ConfigItem
Returns:
the human readable description of this configuration value

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 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:
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

isDynamic

public boolean isDynamic()
Description copied from interface: ServerConfigurationService.ConfigItem
Indicates is this config item is dynamic or static (default is static)

Specified by:
isDynamic in interface ServerConfigurationService.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 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 basic config item which stores a value

Parameters:
name - the config name key
value - 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,
                                                                   boolean dynamic)
Create a basic config item which can be dynamic

Parameters:
name - the config name key
value - the default value for this config
source - the origin of this config setting
dynamic - default false, static config items cannot be changed at runtime, dynamic items can be changed at runtime
Returns:
the ServerConfigurationService.ConfigItem which can be registered with the ServerConfigurationService

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 key
value - the default value for this config
description - the human readable description of this configuration value
source - the origin of this config setting
dynamic - default false, static config items cannot be changed at runtime, dynamic items can be changed at runtime
Returns:
the ServerConfigurationService.ConfigItem which can be registered with the ServerConfigurationService

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 key
value - the default value for this config
defaultValue - the default value for this config
description - the human readable description of this configuration value
source - the origin of this config setting
dynamic - default false, static config items cannot be changed at runtime, dynamic items can be changed at runtime
Returns:
the ServerConfigurationService.ConfigItem which can be registered with the ServerConfigurationService


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