org.sakaiproject.component.api
Interface ServerConfigurationService


public interface ServerConfigurationService

ServerConfigurationService provides information about how the server is configured.


Nested Class Summary
static interface ServerConfigurationService.ConfigData
          Defines the config data holding class
static interface ServerConfigurationService.ConfigHistory
          Defines the config item history class
static interface ServerConfigurationService.ConfigItem
          Defines the config item holding class
static interface ServerConfigurationService.ConfigurationListener
          Allows a service to be notified when configuration settings are changed NOTE: this does NOT include any changes which happen during the initial properties file loading
static interface ServerConfigurationService.ConfigurationProvider
          Allows registration of configuration settings (config items) from outside the Server Configuration Service and the standard set of properties files which will be loaded early on the configuration cycle NOTE: the implemented ConfigurationProvider MUST be a Spring singleton and it MUST be registered in the main Sakai application context from a component (from a webapp will not work), it also must be set explicitly to not lazy initialize (lazy-init="false"), it is always possible to update the configuration later using #registerConfigItems(ConfigData) so this is mainly for loading configurations very early in the system startup
 
Field Summary
static String CURRENT_PORTAL_PATH
          Key in the ThreadLocalManager for the path based on the current request.
static String CURRENT_SERVER_URL
          Key in the ThreadLocalManager for the serverUrl based on the current request.
static String SERVICE_NAME
          This string can be used to find the service in the service manager.
static String TYPE_ARRAY
           
static String TYPE_BOOLEAN
           
static String TYPE_INT
           
static String TYPE_STRING
           
static String UNKNOWN
           
 
Method Summary
 String getAccessPath()
          Access the path to the access service on the server relative to the base URL for the server.
 String getAccessUrl()
          Access the URL to the access service on the server - append any additional path to the end.
 boolean getBoolean(String name, boolean dflt)
          Access some named configuration value as a boolean.
<T> T
getConfig(String name, T defaultValue)
          Retrieves config values from the configuration service
 ServerConfigurationService.ConfigData getConfigData()
          Returns data about all the configuration values which are known to the system at the time and some stats which are useful
 ServerConfigurationService.ConfigItem getConfigItem(String name)
          Retrieve the internally stored the config item, this is not really for general use, if you want the value of a configuration variable then you should use getConfig(String, Object)
 List<String> getDefaultTools(String category)
          Access the list of tool ids that are selected by default for this category.
 String getGatewaySiteId()
          Access the site id for the gateway (public) site.
 String getHelpUrl(String helpContext)
          Access the URL to the help service on the server - append in the path the tool well known id for context sensitive help.
 int getInt(String name, int dflt)
          Access some named configuration value as an int.
 String getLoggedOutUrl()
          Access the URL to use as a redirect when the user has logged out.
 String getPortalUrl()
          Access the URL to the portal service on the server - append any additional path to the end.
 String getRawProperty(String name)
          Access the undereferenced value of the given property.
 String getSakaiHomePath()
          Access the file path to the "sakai home" on the app server.
 String getServerId()
          Access the unique (to the cluster) id of the server.
 String getServerIdInstance()
          Access the combined server / instance id.
 String getServerInstance()
          Access the unique (to the cluster) instance id of the server.
 String getServerName()
          Access the server DNS name.
 String getServerUrl()
          Access the URL to the root of the server - append any additional path to the end.
 String getString(String name)
          Access some named configuration value as a string.
 String getString(String name, String dflt)
          Access some named configuration value as a string.
 String[] getStrings(String name)
          Access some named configuration values as an array of strings.
 List<String> getToolCategories(String category)
          access the list of tool categories for the given site type
 Map<String,List<String>> getToolCategoriesAsMap(String category)
          access the map of tool categories to tool ids for this site type
 List<String> getToolOrder(String category)
          Access the list of tool ids in order for this category, to impose on the displays of many tools
 List<String> getToolsRequired(String category)
          Access the list of tool ids that are required for this category.
 Map<String,String> getToolToCategoryMap(String category)
          access a map of tool id to tool category id for this site type
 String getToolUrl()
          Access the URL to the tool dispatcher service on the server - append any additional path to the end.
 String getUserHomeUrl()
          Access the URL to the user's "home" (My Workspace) in the service.
 ServerConfigurationService.ConfigItem registerConfigItem(ServerConfigurationService.ConfigItem configItem)
          Register a configuration item (or override an existing config), this should be called when changing or creating a configuration setting
 void registerListener(ServerConfigurationService.ConfigurationListener configurationListener)
          Register a listener which will be notified whenever there is a configuration setting change, there is no need to unregister a listener as all listener references will be held weakly (if there are no more variables which reference the listener then it will be GCed and removed from the list of listeners) Registering the same ServerConfigurationService.ConfigurationListener object multiple times has no effect
 

Field Detail

SERVICE_NAME

static final String SERVICE_NAME
This string can be used to find the service in the service manager.


CURRENT_SERVER_URL

static final String CURRENT_SERVER_URL
Key in the ThreadLocalManager for the serverUrl based on the current request.

See Also:
Constant Field Values

CURRENT_PORTAL_PATH

static final String CURRENT_PORTAL_PATH
Key in the ThreadLocalManager for the path based on the current request.

See Also:
Constant Field Values

UNKNOWN

static final String UNKNOWN
See Also:
Constant Field Values

TYPE_BOOLEAN

static final String TYPE_BOOLEAN
See Also:
Constant Field Values

TYPE_INT

static final String TYPE_INT
See Also:
Constant Field Values

TYPE_ARRAY

static final String TYPE_ARRAY
See Also:
Constant Field Values

TYPE_STRING

static final String TYPE_STRING
See Also:
Constant Field Values
Method Detail

getServerId

String getServerId()
Access the unique (to the cluster) id of the server.

Returns:
The unique (to the cluster) id of the server.

getServerInstance

String getServerInstance()
Access the unique (to the cluster) instance id of the server.

Returns:
The unique (to the cluster) instance id of the server.

getServerIdInstance

String getServerIdInstance()
Access the combined server / instance id.

Returns:
The combined server / instance id.

getServerName

String getServerName()
Access the server DNS name.

Returns:
The server DNS name.

getServerUrl

String getServerUrl()
Access the URL to the root of the server - append any additional path to the end.

Returns:
The URL to the root of the server.

getHelpUrl

String getHelpUrl(String helpContext)
Access the URL to the help service on the server - append in the path the tool well known id for context sensitive help.

Parameters:
helpContext - The context string.
Returns:
The URL to the help service on the server.

getAccessUrl

String getAccessUrl()
Access the URL to the access service on the server - append any additional path to the end.

Returns:
The URL to the access service on the server.

getAccessPath

String getAccessPath()
Access the path to the access service on the server relative to the base URL for the server.

Returns:
The path to the access service on the server.

getPortalUrl

String getPortalUrl()
Access the URL to the portal service on the server - append any additional path to the end.

Returns:
The URL to the portal service on the server.

getToolUrl

String getToolUrl()
Access the URL to the tool dispatcher service on the server - append any additional path to the end.

Returns:
The URL to the tool dispatcher service on the server.

getGatewaySiteId

String getGatewaySiteId()
Access the site id for the gateway (public) site.

Returns:
The site id for the gateway (public) site.

getLoggedOutUrl

String getLoggedOutUrl()
Access the URL to use as a redirect when the user has logged out.

Returns:
The URL to use as a redirect when the user has logged out.

getUserHomeUrl

String getUserHomeUrl()
Access the URL to the user's "home" (My Workspace) in the service.

Returns:
The URL to the user's "home" (My Workspace) in the service.

getSakaiHomePath

String getSakaiHomePath()
Access the file path to the "sakai home" on the app server.

Returns:
The file path to the "sakai home" on the app server.

getString

String getString(String name)
Access some named configuration value as a string.

Parameters:
name - The configuration value name.
Returns:
The configuration value with this name, or "" if not found.

getString

String getString(String name,
                 String dflt)
Access some named configuration value as a string.

Parameters:
name - The configuration value name.
dflt - The value to return if not found.
Returns:
The configuration value with this name, or the default value if not found.

getStrings

String[] getStrings(String name)
Access some named configuration values as an array of strings. The name is the base name. name + ".count" must be defined to be a positive integer - how many are defined. name + "." + i (1..count) must be defined to be the values.

Parameters:
name - The configuration value name base.
Returns:
The configuration value with this name, or the null if not found.

getInt

int getInt(String name,
           int dflt)
Access some named configuration value as an int.

Parameters:
name - The configuration value name.
dflt - The value to return if not found.
Returns:
The configuration value with this name, or the default value if not found.

getBoolean

boolean getBoolean(String name,
                   boolean dflt)
Access some named configuration value as a boolean.

Parameters:
name - The configuration value name.
dflt - The value to return if not found.
Returns:
The configuration value with this name, or the default value if not found.

getRawProperty

String getRawProperty(String name)
Access the undereferenced value of the given property. That is, Spring-style property placeholders will not be expanded as they would be in other getters on this interface. For example, consider the following configuration:
 
 property1=foo
 property2=${property1}
 
 

Invoking getString(String), passing "property2" will return "foo". However, invoking this method with the same argument will return "${property1}".

Typically, a client of this method, e.g. a dynamic configuration management tool, is interested in reporting on the system's actual state from which return values of other getters are calculated. In such cases, caller-specified default values have no utility. Thus this method does not accept an argument specifying the property's default value.

For a given undefined property "X", this method should return exactly the same value as getString("X"). Thus it may not be possible in all cases to distinguish between defined and undefined properties.

Parameters:
name - a property name. Must not be null
Returns:
the property value. Property placeholders will not have been dereferenced. The value representing an non-existent property is implementation dependent.

getToolOrder

List<String> getToolOrder(String category)
Access the list of tool ids in order for this category, to impose on the displays of many tools

Parameters:
category - The tool category
Returns:
An ordered list of tool ids (String) indicating the desired tool display order, or an empty list if there are none for this category.

getToolsRequired

List<String> getToolsRequired(String category)
Access the list of tool ids that are required for this category.

Parameters:
category - The tool category.
Returns:
A list of tool ids (String) that are required for this category, or an empty list if there are none for this category.

getDefaultTools

List<String> getDefaultTools(String category)
Access the list of tool ids that are selected by default for this category.

Parameters:
category - The tool category.
Returns:
A list of tool ids (String) for this category to use by default, or an empty list if there are none for this category.

getToolCategories

List<String> getToolCategories(String category)
access the list of tool categories for the given site type

Parameters:
category - the site type
Returns:
a list of tool category ids in order

getToolCategoriesAsMap

Map<String,List<String>> getToolCategoriesAsMap(String category)
access the map of tool categories to tool ids for this site type

Parameters:
category - the site type
Returns:
a map of tool category ids to tool ids

getToolToCategoryMap

Map<String,String> getToolToCategoryMap(String category)
access a map of tool id to tool category id for this site type

Parameters:
category - the site type
Returns:
map with tool id as key and category id as value

getConfig

<T> T getConfig(String name,
                T defaultValue)
Retrieves config values from the configuration service

Parameters:
name - the name of the setting to retrieve, Should be a string name: e.g. auto.ddl, mystuff.config, etc.
defaultValue - a specified default value to return if this setting cannot be found, NOTE: You can set the default value to null but you must specify the class type in parens
Returns:
the value of the configuration setting OR the default value if none can be found

getConfigItem

ServerConfigurationService.ConfigItem getConfigItem(String name)
Retrieve the internally stored the config item, this is not really for general use, if you want the value of a configuration variable then you should use getConfig(String, Object)

Parameters:
name - the name of the setting to retrieve, Should be a string name: e.g. auto.ddl, mystuff.config, etc.
Returns:
the config item OR null if none exists

registerConfigItem

ServerConfigurationService.ConfigItem registerConfigItem(ServerConfigurationService.ConfigItem configItem)
Register a configuration item (or override an existing config), this should be called when changing or creating a configuration setting

Parameters:
configItem - an instance of the ServerConfigurationService.ConfigItem interface with the name, value, source params set, use BasicConfigItem as an easy way to construct a ServerConfigurationService.ConfigItem
Returns:
the registered ServerConfigurationService.ConfigItem
Throws:
IllegalArgumentException - if the ServerConfigurationService.ConfigItem is not valid (does not have all required fields set)

registerListener

void registerListener(ServerConfigurationService.ConfigurationListener configurationListener)
Register a listener which will be notified whenever there is a configuration setting change, there is no need to unregister a listener as all listener references will be held weakly (if there are no more variables which reference the listener then it will be GCed and removed from the list of listeners) Registering the same ServerConfigurationService.ConfigurationListener object multiple times has no effect

Parameters:
configurationListener - a ServerConfigurationService.ConfigurationListener object

getConfigData

ServerConfigurationService.ConfigData getConfigData()
Returns data about all the configuration values which are known to the system at the time and some stats which are useful

Returns:
a config data class with data about the known configuration values


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