org.dspace.services
Interface ConfigurationService


public interface ConfigurationService

This service handles retrieval of the configuration data for a DSpace instance.

The configuration files are properties files which look like this for simple values:

thing.name = aaronz thing.number = 1234 thing.on = true thing.value = abc,def,ghi For these simple cases the service will automatically translate the settings into strings, booleans, numbers and arrays as requested in the various getPropertyAsType(String, Class) methods.

There are special case configuration parameters allowed as well.

The first allows setting of a parameter on any DSpace service by the given name:

emailEnabled@org.dspace.Service = true adminUser@org.dspace.impl.MyService = aaronz This should be used sparingly and really only by system admins (not developers). Developers should be using simple config values to expose service configurations.

The second allows controlling the implementation used for a service interface or provider:

$org.dspace.Service = org.dspace.impl.MyService

Author:
Aaron Zeckoski (azeckoski @ gmail.com)

Method Summary
 Map<String,String> getAllProperties()
          Get all currently known configuration settings
 Properties getProperties()
          Convenience method - get all configuration properties (settings) from the system.
 String getProperty(String name)
          Convenience method - get a configuration property (setting) from the system.
<T> T
getPropertyAsType(String name, Class<T> type)
          Get a configuration property (setting) from the system as a specified type.
<T> T
getPropertyAsType(String name, T defaultValue)
          Get a configuration property (setting) from the system, or return a default value if none is found.
<T> T
getPropertyAsType(String name, T defaultValue, boolean setDefaultIfNotFound)
          Get a configuration property (setting) from the system, or return (and possibly store) a default value if none is found.
 boolean setProperty(String name, Object value)
          Set a configuration property (setting) in the system.
 

Method Detail

getPropertyAsType

<T> T getPropertyAsType(String name,
                        Class<T> type)
Get a configuration property (setting) from the system as a specified type.

Type Parameters:
T -
Parameters:
name - the property name
type - the type to return the property as
Returns:
the property value OR null if none is found
Throws:
UnsupportedOperationException - if the type cannot be converted to the requested type

getPropertyAsType

<T> T getPropertyAsType(String name,
                        T defaultValue)
Get a configuration property (setting) from the system, or return a default value if none is found.

Type Parameters:
T -
Parameters:
name - the property name
defaultValue - the value to return if this name is not found
Returns:
the property value OR null if none is found
Throws:
IllegalArgumentException - if the defaultValue type does not match the type of the property by name

getPropertyAsType

<T> T getPropertyAsType(String name,
                        T defaultValue,
                        boolean setDefaultIfNotFound)
Get a configuration property (setting) from the system, or return (and possibly store) a default value if none is found.

Type Parameters:
T -
Parameters:
name - the property name
defaultValue - the value to return if this name is not found
setDefaultIfNotFound - if this is true and the config value is not found then the default value will be set in the configuration store assuming it is not null. Otherwise the default value is just returned but not set.
Returns:
the property value OR null if none is found
Throws:
IllegalArgumentException - if the defaultValue type does not match the type of the property by name

getAllProperties

Map<String,String> getAllProperties()
Get all currently known configuration settings

Returns:
all the configuration properties as a map of name -> value

getProperty

String getProperty(String name)
Convenience method - get a configuration property (setting) from the system.

Parameters:
name - the property name
Returns:
the property value OR null if none is found

getProperties

Properties getProperties()
Convenience method - get all configuration properties (settings) from the system.

Returns:
all the configuration properties in a properties object (name -> value)

setProperty

boolean setProperty(String name,
                    Object value)
Set a configuration property (setting) in the system. Type is not important here since conversion happens automatically when properties are requested.

Parameters:
name - the property name
value - the property value (set this to null to clear out the property)
Returns:
true if the property is new or changed from the existing value, false if it is the same
Throws:
IllegalArgumentException - if the name is null
UnsupportedOperationException - if the type cannot be converted to something that is understandable by the system as a configuration property value


Copyright © Monday, September 1, 2008-2010 The DSpace Foundation. All Rights Reserved.