org.kuali.rice.core.impl.config.property
Class JAXBConfigImpl

java.lang.Object
  extended by org.kuali.rice.core.framework.config.property.AbstractBaseConfig
      extended by org.kuali.rice.core.impl.config.property.JAXBConfigImpl
All Implemented Interfaces:
Config

public class JAXBConfigImpl
extends AbstractBaseConfig

This implementation of the Config interface uses JAXB to parse the config file and maintains an internal copy of all properties in their "raw" form (without any nested properties resolved). This allows properties to be added in stages and still alter values of properties previously read in. It also has settings for whether system properties should override all properties or only serve as default when the property has not been defined.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Nested Class Summary
 class JAXBConfigImpl.ConfigNamespaceURIFilter
          This is a SAX filter that adds the config xml namespace to the document if the document does not have a namespace (for backwards compatibility).
 
Field Summary
 
Fields inherited from interface org.kuali.rice.core.api.config.property.Config
ALT_OJB_FILE, ALT_SPRING_FILE, APPLICATION_NAME, APPLICATION_VERSION, BAM_ENABLED, BASE_WEB_SERVICE_URL_WORKFLOW_CLIENT_FILE, BASE_WEB_SERVICE_WSDL_PATH, BATCH_MODE, CREDENTIALS_SOURCE_FACTORY, DATASOURCE_DRIVER_NAME, DATASOURCE_OJB_SEQUENCE_MANAGER, DATASOURCE_OJB_SEQUENCE_MANAGER_CLASS, DATASOURCE_PASSWORD, DATASOURCE_PLATFORM, DATASOURCE_POOL_MAX_SIZE, DATASOURCE_POOL_MAXWAIT, DATASOURCE_POOL_MIN_SIZE, DATASOURCE_POOL_VALIDATION_QUERY, DATASOURCE_URL, DATASOURCE_USERNAME, DEFAULT_KEW_NOTE_CLASS, DEV_MODE, DOCUMENT_LOCK_TIMEOUT, EDL_CONFIG_LOCATION, EMAIL_SECURITY_PATH, EMBEDDED_PLUGIN_DEFAULT_CURRENT_CLASS_LOADER, EMBEDDED_PLUGIN_LOCATIAON, ENABLE_EMAIL_REMINDER_LIFECYCLE, ENABLE_XML_PIPELINE_LIFECYCLE, ENVIRONMENT, EXTRA_CLASSES_DIR, EXTRA_LIB_DIR, FIRST_DAILY_EMAIL_DELIVERY_DATE, FIRST_WEEKLY_EMAIL_DELIVERY_DATE, KEN_URL, KEW_URL, KEYSTORE_ALIAS, KEYSTORE_FILE, KEYSTORE_PASSWORD, KIM_URL, KR_URL, LOG4J_SETTINGS_PATH, LOG4J_SETTINGS_PROPS, LOG4J_SETTINGS_RELOADINTERVAL_MINS, LOG4J_SETTINGS_XML, M_BEANS, MESSAGE_PERSISTENCE, MODULE_NAME, NODE_PROPERTIES_PATH, OJB_PLATFORM, OUT_BOX_MODE, PLUGIN_DIR, PROD_ENVIRONMENT_CODE, REFRESH_RATE, RICE_VERSION, SERVICE_SERVLET_URL, THREAD_POOL_SIZE, TRANSACTION_TIMEOUT, VERSION, WEB_SERVICE_CONNECT_RETRY, WSDL_LOCATION_WORKFLOW_CLIENT_FILE
 
Constructor Summary
JAXBConfigImpl()
           
JAXBConfigImpl(Config config)
           
JAXBConfigImpl(List<String> fileLocs)
           
JAXBConfigImpl(List<String> fileLocs, Config config)
           
JAXBConfigImpl(List<String> fileLocs, Properties properties)
           
JAXBConfigImpl(Properties properties)
           
JAXBConfigImpl(String fileLoc)
           
JAXBConfigImpl(String fileLoc, Config config)
           
JAXBConfigImpl(String fileLoc, Properties properties)
           
 
Method Summary
protected  void configureBuiltIns()
          Configures built-in properties.
protected  int generateRandomInteger(String rangeSpec)
          Generates a random integer in the range specified by the specifier, in the format: min-max
 Object getObject(String key)
           
 Map<String,Object> getObjects()
           
 Properties getProperties()
          Returns properties explicitly configured in this Config
 String getProperty(String key)
           
 boolean isSystemOverride()
           
 void parseConfig()
           
protected  void parseConfig(String filename, Unmarshaller unmarshaller, int depth)
           
protected  String parseValue(String value, Set<String> keySet)
          This method parses the value string to find all nested properties (foo=${nested}) and replaces them with the value returned from calling resolve().
 void putConfig(Config config)
          This method takes a config object and merges it with the current object.
 void putObject(String key, Object value)
           
 void putObjects(Map<String,Object> objects)
           
 void putProperties(Properties properties)
           
 void putProperty(String key, String value)
          This overrided the property.
 void removeObject(String key)
           
 void removeProperty(String key)
           
protected  String replaceVariable(String name, String value)
          This method is used when reading in new properties to check if there is a direct reference to the key in the value.
protected  String resolve(String key)
           
protected  String resolve(String key, Set<String> keySet)
          This method will determine the value for a property by looking it up in the raw properties.
protected  void resolveRawToCache()
          This method iterates through the raw properties and stores their resolved values in the resolved properties map, which acts as a cache so we don't have to run the recursion every time getProperty() is called.
protected  void setProperty(String name, String value)
           
 void setSystemOverride(boolean systemOverride)
          If set to true then system properties will always be checked first, disregarding any values in the config.
protected  Config unmarshal(Unmarshaller unmarshaller, InputStream in)
           
 
Methods inherited from class org.kuali.rice.core.framework.config.property.AbstractBaseConfig
getAlternateOJBFile, getAlternateSpringFile, getApplicationName, getApplicationVersion, getBaseWebServiceURL, getBaseWebServiceWsdlPath, getBatchMode, getBooleanProperty, getBooleanProperty, getClientWSDLFullPathAndFileName, getDailyEmailFirstDeliveryDate, getDefaultKewNoteClass, getDevMode, getDocumentLockTimeout, getEDLConfigLocation, getEmailConfigurationPath, getEmailReminderLifecycleEnabled, getEmbeddedPluginLocation, getEndPointUrl, getEnvironment, getKENBaseURL, getKEWBaseURL, getKeystoreAlias, getKeystoreFile, getKeystorePassword, getKIMBaseURL, getKRBaseURL, getLog4jFileLocation, getLog4jReloadInterval, getNumericProperty, getNumericProperty, getOutBoxOn, getProductionEnvironmentCode, getPropertiesWithPrefix, getRefreshRate, getRiceVersion, getTransactionTimeout, getWebServicesConnectRetry, getWeeklyEmailFirstDeliveryDate, getXmlPipelineLifeCycleEnabled, isProductionEnvironment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAXBConfigImpl

public JAXBConfigImpl()

JAXBConfigImpl

public JAXBConfigImpl(Config config)

JAXBConfigImpl

public JAXBConfigImpl(String fileLoc,
                      Config config)

JAXBConfigImpl

public JAXBConfigImpl(List<String> fileLocs,
                      Config config)

JAXBConfigImpl

public JAXBConfigImpl(String fileLoc)

JAXBConfigImpl

public JAXBConfigImpl(List<String> fileLocs)

JAXBConfigImpl

public JAXBConfigImpl(Properties properties)

JAXBConfigImpl

public JAXBConfigImpl(String fileLoc,
                      Properties properties)

JAXBConfigImpl

public JAXBConfigImpl(List<String> fileLocs,
                      Properties properties)
Method Detail

getObject

public Object getObject(String key)
Specified by:
getObject in interface Config
Specified by:
getObject in class AbstractBaseConfig

getObjects

public Map<String,Object> getObjects()
Specified by:
getObjects in interface Config
Specified by:
getObjects in class AbstractBaseConfig

getProperties

public Properties getProperties()
Description copied from interface: Config
Returns properties explicitly configured in this Config

Specified by:
getProperties in interface Config
Specified by:
getProperties in class AbstractBaseConfig
Returns:
properties explicitly configured in this Config

getProperty

public String getProperty(String key)
Specified by:
getProperty in interface Config
Specified by:
getProperty in class AbstractBaseConfig

putProperty

public void putProperty(String key,
                        String value)
This overrided the property. Takes the place of the now depricated overrideProperty

See Also:
Config#putProperty(java.lang.String, java.lang.String)

putProperties

public void putProperties(Properties properties)

parseConfig

public void parseConfig()
                 throws IOException
Specified by:
parseConfig in interface Config
Specified by:
parseConfig in class AbstractBaseConfig
Throws:
IOException

parseConfig

protected void parseConfig(String filename,
                           Unmarshaller unmarshaller,
                           int depth)
                    throws IOException
Throws:
IOException

setProperty

protected void setProperty(String name,
                           String value)

resolve

protected String resolve(String key)

resolve

protected String resolve(String key,
                         Set<String> keySet)
This method will determine the value for a property by looking it up in the raw properties. If the property value contains a nested property (foo=${nested}) it will start the recursion by calling parseValue(). It will also check for a system property of the same name and, based on the value of systemOverride, 'override with' the system property or 'default to' the system property if not found in the raw properties. This method only determines the resolved value, it does not modify the properties in the resolved or raw properties objects.

Parameters:
key - they key of the property for which to determine the value
keySet - contains all keys used so far in this recursion. used to check for circular references.
Returns:

parseValue

protected String parseValue(String value,
                            Set<String> keySet)
This method parses the value string to find all nested properties (foo=${nested}) and replaces them with the value returned from calling resolve(). It does this in a new string and does not modify the raw or resolved properties objects.

Parameters:
value - the string to search for nest properties
keySet - contains all keys used so far in this recursion. used to check for circular references.
Returns:

replaceVariable

protected String replaceVariable(String name,
                                 String value)
This method is used when reading in new properties to check if there is a direct reference to the key in the value. This emulates operating system environment variable setting behavior and replaces the reference in the value with the current value of the property from the rawProperties.
 ex:
 path=/usr/bin;${someVar}
 path=${path};/some/other/path
 
 resolves to:
 path=/usr/bin;${someVar};/some/other/path
 
It does not resolve the the value from rawProperties as it could contain nested properties that might change later. If the property does not exist in the rawProperties it will check for a default system property now to prevent a circular reference error.

Parameters:
name - the property name
value - the value to check for nested property of the same name
Returns:

resolveRawToCache

protected void resolveRawToCache()
This method iterates through the raw properties and stores their resolved values in the resolved properties map, which acts as a cache so we don't have to run the recursion every time getProperty() is called.


configureBuiltIns

protected void configureBuiltIns()
Configures built-in properties.


generateRandomInteger

protected int generateRandomInteger(String rangeSpec)
Generates a random integer in the range specified by the specifier, in the format: min-max

Parameters:
rangeSpec - a range specification, 'min-max'
Returns:
a random integer in the range specified by the specifier, in the format: min-max

isSystemOverride

public boolean isSystemOverride()

setSystemOverride

public void setSystemOverride(boolean systemOverride)
If set to true then system properties will always be checked first, disregarding any values in the config. The default is false.

Parameters:
systemOverride -

unmarshal

protected Config unmarshal(Unmarshaller unmarshaller,
                           InputStream in)
                    throws SAXException,
                           JAXBException,
                           ParserConfigurationException,
                           IOException
Throws:
SAXException
JAXBException
ParserConfigurationException
IOException

putObject

public void putObject(String key,
                      Object value)

putObjects

public void putObjects(Map<String,Object> objects)

removeObject

public void removeObject(String key)

removeProperty

public void removeProperty(String key)

putConfig

public void putConfig(Config config)
Description copied from interface: Config
This method takes a config object and merges it with the current object.



Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.