org.kuali.rice.core.config
Class JAXBConfigImpl

java.lang.Object
  extended by org.kuali.rice.core.config.AbstractBaseConfig
      extended by org.kuali.rice.core.config.JAXBConfigImpl
All Implemented Interfaces:
org.kuali.rice.core.config.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.config.Config
ALT_OJB_FILE, ALT_SPRING_FILE, BAM_ENABLED, BASE_WEB_SERVICE_URL_WORKFLOW_CLIENT_FILE, BASE_WEB_SERVICE_WSDL_PATH, BATCH_MODE, BUS_DEPLOYED_SERVICES, CLIENT_PROTOCOL, 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_SIZE, DATASOURCE_POOL_VALIDATION_QUERY, DATASOURCE_URL, DATASOURCE_USERNAME, DEFAULT_KEW_NOTE_CLASS, DEFAULT_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, NODE_PROPERTIES_PATH, OJB_PLATFORM, OUT_BOX_DEFAULT_PREFERENCE_ON, OUT_BOX_MODE, PLUGIN_DIR, PORTAL_SHOW_SAMPLE_APP, REFRESH_RATE, SERVICE_NAMESPACE, SERVICE_SERVLET_URL, STORE_AND_FORWARD, THREAD_POOL_SIZE, TRANSACTION_TIMEOUT, WEB_SERVICE_CONNECT_RETRY, WSDL_LOCATION_WORKFLOW_CLIENT_FILE
 
Constructor Summary
JAXBConfigImpl()
           
JAXBConfigImpl(org.kuali.rice.core.config.Config config)
           
JAXBConfigImpl(java.util.List<java.lang.String> fileLocs)
           
JAXBConfigImpl(java.util.List<java.lang.String> fileLocs, org.kuali.rice.core.config.Config config)
           
JAXBConfigImpl(java.util.List<java.lang.String> fileLocs, java.util.Properties properties)
           
JAXBConfigImpl(java.util.Properties properties)
           
JAXBConfigImpl(java.lang.String fileLoc)
           
JAXBConfigImpl(java.lang.String fileLoc, org.kuali.rice.core.config.Config config)
           
JAXBConfigImpl(java.lang.String fileLoc, java.util.Properties properties)
           
 
Method Summary
protected  void configureBuiltIns()
          Configures built-in properties.
protected  int generateRandomInteger(java.lang.String rangeSpec)
          Generates a random integer in the range specified by the specifier, in the format: min-max
 java.lang.Object getObject(java.lang.String key)
           
 java.util.Map<java.lang.String,java.lang.Object> getObjects()
           
 java.util.Properties getProperties()
           
 java.lang.String getProperty(java.lang.String key)
           
 boolean isSystemOverride()
           
 void overrideProperty(java.lang.String name, java.lang.String value)
           
 void parseConfig()
           
protected  void parseConfig(java.lang.String filename, javax.xml.bind.Unmarshaller unmarshaller, int depth)
           
protected  java.lang.String parseValue(java.lang.String value, java.util.Set<java.lang.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(org.kuali.rice.core.config.Config config)
           
 void putObject(java.lang.String key, java.lang.Object value)
           
 void putObjects(java.util.Map<java.lang.String,java.lang.Object> objects)
           
 void putProperties(java.util.Properties properties)
           
 void putProperty(java.lang.String key, java.lang.String value)
          This overrided the property.
 void removeObject(java.lang.String key)
           
 void removeProperty(java.lang.String key)
           
protected  java.lang.String replaceVariable(java.lang.String name, java.lang.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  java.lang.String resolve(java.lang.String key)
           
protected  java.lang.String resolve(java.lang.String key, java.util.Set 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(java.lang.String name, java.lang.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(javax.xml.bind.Unmarshaller unmarshaller, java.io.InputStream in)
           
 
Methods inherited from class org.kuali.rice.core.config.AbstractBaseConfig
getAlternateOJBFile, getAlternateSpringFile, getBaseWebServiceURL, getBaseWebServiceWsdlPath, getBatchMode, getBooleanProperty, getClientProtocol, getClientWSDLFullPathAndFileName, getDailyEmailFirstDeliveryDate, getDefaultKewNoteClass, getDefaultNoteClass, getDevMode, getDocumentLockTimeout, getEDLConfigLocation, getEmailConfigurationPath, getEmailReminderLifecycleEnabled, getEmbeddedPluginLocation, getEndPointUrl, getEnvironment, getKENBaseURL, getKEWBaseURL, getKeystoreAlias, getKeystoreFile, getKeystorePassword, getKIMBaseURL, getKRBaseURL, getLog4jFileLocation, getLog4jReloadInterval, getOutBoxDefaultPreferenceOn, getOutBoxOn, getPortalShowSampleApp, getPropertiesWithPrefix, getRefreshRate, getServiceNamespace, getStoreAndForward, getTransactionTimeout, getWebServicesConnectRetry, getWeeklyEmailFirstDeliveryDate, getXmlPipelineLifeCycleEnabled
 
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(org.kuali.rice.core.config.Config config)

JAXBConfigImpl

public JAXBConfigImpl(java.lang.String fileLoc,
                      org.kuali.rice.core.config.Config config)

JAXBConfigImpl

public JAXBConfigImpl(java.util.List<java.lang.String> fileLocs,
                      org.kuali.rice.core.config.Config config)

JAXBConfigImpl

public JAXBConfigImpl(java.lang.String fileLoc)

JAXBConfigImpl

public JAXBConfigImpl(java.util.List<java.lang.String> fileLocs)

JAXBConfigImpl

public JAXBConfigImpl(java.util.Properties properties)

JAXBConfigImpl

public JAXBConfigImpl(java.lang.String fileLoc,
                      java.util.Properties properties)

JAXBConfigImpl

public JAXBConfigImpl(java.util.List<java.lang.String> fileLocs,
                      java.util.Properties properties)
Method Detail

getObject

public java.lang.Object getObject(java.lang.String key)
Specified by:
getObject in interface org.kuali.rice.core.config.Config
Specified by:
getObject in class AbstractBaseConfig

getObjects

public java.util.Map<java.lang.String,java.lang.Object> getObjects()
Specified by:
getObjects in interface org.kuali.rice.core.config.Config
Specified by:
getObjects in class AbstractBaseConfig

getProperties

public java.util.Properties getProperties()
Specified by:
getProperties in interface org.kuali.rice.core.config.Config
Specified by:
getProperties in class AbstractBaseConfig

getProperty

public java.lang.String getProperty(java.lang.String key)
Specified by:
getProperty in interface org.kuali.rice.core.config.Config
Specified by:
getProperty in class AbstractBaseConfig

overrideProperty

public void overrideProperty(java.lang.String name,
                             java.lang.String value)
Specified by:
overrideProperty in interface org.kuali.rice.core.config.Config
Specified by:
overrideProperty in class AbstractBaseConfig

putProperty

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

See Also:
org.kuali.rice.core.config.Config#putProperty(java.lang.String, java.lang.Object)

putProperties

public void putProperties(java.util.Properties properties)

parseConfig

public void parseConfig()
                 throws java.io.IOException
Specified by:
parseConfig in interface org.kuali.rice.core.config.Config
Specified by:
parseConfig in class AbstractBaseConfig
Throws:
java.io.IOException

parseConfig

protected void parseConfig(java.lang.String filename,
                           javax.xml.bind.Unmarshaller unmarshaller,
                           int depth)
                    throws java.io.IOException
Throws:
java.io.IOException

setProperty

protected void setProperty(java.lang.String name,
                           java.lang.String value)

resolve

protected java.lang.String resolve(java.lang.String key)

resolve

protected java.lang.String resolve(java.lang.String key,
                                   java.util.Set 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 java.lang.String parseValue(java.lang.String value,
                                      java.util.Set<java.lang.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 java.lang.String replaceVariable(java.lang.String name,
                                           java.lang.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(java.lang.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(javax.xml.bind.Unmarshaller unmarshaller,
                           java.io.InputStream in)
                    throws java.lang.Exception
Throws:
java.lang.Exception

putObject

public void putObject(java.lang.String key,
                      java.lang.Object value)

putObjects

public void putObjects(java.util.Map<java.lang.String,java.lang.Object> objects)

removeObject

public void removeObject(java.lang.String key)

removeProperty

public void removeProperty(java.lang.String key)

putConfig

public void putConfig(org.kuali.rice.core.config.Config config)


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.