signature:
public class NetUtil { /** * Returns Local Host Name
 * @ return local Host Name
 * @ throws UnknownHostException
 * @ throws SocketException */
public static String getLocalHostName ( ) throws UnknownHostException , SocketException { } }

implementation: try { return getLocalHost ( ) . getHostName ( ) ; } catch ( Exception e ) { Scope . getCurrentScope ( ) . getLog ( NetUtil . class ) . fine ( LogType . LOG , "Error getting hostname" , e ) ; return "unknown" ; }


signature:
public class CreateProcedureGenerator { /** * Convenience method for when the schemaName is set but we don ' t want to parse the body */
public static void surroundWithSchemaSets ( List < Sql > sql , String schemaName , Database database ) { } }

implementation: if ( ( StringUtil . trimToNull ( schemaName ) != null ) && ! LiquibaseConfiguration . getInstance ( ) . getProperty ( ChangeLogParserCofiguration . class , ChangeLogParserCofiguration . USE_PROCEDURE_SCHEMA ) . getValue ( Boolean . class ) ) { String defaultSchema = database . getDefaultSchemaName ( ) ; if ( database instanceof OracleDatabase ) { sql . add ( 0 , new UnparsedSql ( "ALTER SESSION SET CURRENT_SCHEMA=" + database . escapeObjectName ( schemaName , Schema . class ) ) ) ; sql . add ( new UnparsedSql ( "ALTER SESSION SET CURRENT_SCHEMA=" + database . escapeObjectName ( defaultSchema , Schema . class ) ) ) ; } else if ( database instanceof AbstractDb2Database ) { sql . add ( 0 , new UnparsedSql ( "SET CURRENT SCHEMA " + schemaName ) ) ; sql . add ( new UnparsedSql ( "SET CURRENT SCHEMA " + defaultSchema ) ) ; } }


signature:
public class CreateProcedureGenerator { /** * Convenience method for other classes similar to this that want to be able to modify the procedure text to add the schema */
public static String addSchemaToText ( String procedureText , String schemaName , String keywordBeforeName , Database database ) { } }

implementation:
if ( schemaName == null ) { return procedureText ; } if ( ( StringUtil . trimToNull ( schemaName ) != null ) && LiquibaseConfiguration . getInstance ( ) . getProperty ( ChangeLogParserCofiguration . class , ChangeLogParserCofiguration . USE_PROCEDURE_SCHEMA ) . getValue ( Boolean . class ) ) { StringClauses parsedSql = SqlParser . parse ( procedureText , true , true ) ; StringClauses . ClauseIterator clauseIterator = parsedSql . getClauseIterator ( ) ; Object next = "START" ; while ( ( next != null ) && ! next . toString ( ) . equalsIgnoreCase ( keywordBeforeName ) && clauseIterator . hasNext ( ) ) { if ( ! "PACKAGE" . equalsIgnoreCase ( keywordBeforeName ) && "PACKAGE" . equalsIgnoreCase ( ( String ) next ) ) { return procedureText ; } next = clauseIterator . nextNonWhitespace ( ) ; } if ( ( next != null ) && clauseIterator . hasNext ( ) ) { Object procNameClause = clauseIterator . nextNonWhitespace ( ) ; if ( procNameClause instanceof String ) { String [ ] nameParts = ( ( String ) procNameClause ) . split ( "\\." ) ; String finalName ; if ( nameParts . length == 1 ) { finalName = database . escapeObjectName ( schemaName , Schema . class ) + "." + nameParts [ 0 ] ; } else if ( nameParts . length == 2 ) { finalName = database . escapeObjectName ( schemaName , Schema . class ) + "." + nameParts [ 1 ] ; } else if ( nameParts . length == 3 ) { finalName = nameParts [ 0 ] + "." + database . escapeObjectName ( schemaName , Schema . class ) + "." + nameParts [ 2 ] ; } else { finalName = ( String ) procNameClause ; // just go with what was there
} clauseIterator . replace ( finalName ) ; } procedureText = parsedSql . toString ( ) ; } } return procedureText ;


signature:
public class DerbyDatabase { /** * Determine Apache Derby driver major / minor version . */
@ SuppressWarnings ( { } }

implementation:
"static-access" , "unchecked" } ) protected void determineDriverVersion ( ) { try { // Locate the Derby sysinfo class and query its version info
Enumeration < Driver > it = DriverManager . getDrivers ( ) ; while ( it . hasMoreElements ( ) ) { Driver driver = it . nextElement ( ) ; if ( driver . getClass ( ) . getName ( ) . contains ( "derby" ) ) { driverVersionMajor = driver . getMajorVersion ( ) ; driverVersionMinor = driver . getMinorVersion ( ) ; return ; } } // log . debug ( " Unable to load / access Apache Derby driver class " + " to check version " ) ;
driverVersionMajor = 10 ; driverVersionMinor = 6 ; } catch ( Exception e ) { // log . debug ( " Unable to load / access Apache Derby driver class " + " org . apache . derby . tools . sysinfo to check version : " + e . getMessage ( ) ) ;
driverVersionMajor = 10 ; driverVersionMinor = 6 ; }


signature:
public class MD5Util { /** * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order .
 * The returned array will be double the length of the passed array , as it takes two characters to represent any
 * given byte .
 * @ param data
 * a byte [ ] to convert to Hex characters
 * @ return A char [ ] containing hexadecimal characters */
private static char [ ] encodeHex ( byte [ ] data ) { } }

implementation:
int l = data . length ; char [ ] out = new char [ l << 1 ] ; // two characters form the hex value .
for ( int i = 0 , j = 0 ; i < l ; i ++ ) { out [ j ++ ] = DIGITS_LOWER [ ( 0xF0 & data [ i ] ) >>> 4 ] ; out [ j ++ ] = DIGITS_LOWER [ 0x0F & data [ i ] ] ; } return out ;


signature:
public class SchemaSnapshotGenerator { /** * Fetches an array of Strings with the schema names in the database .
 * @ param database The database from which to get the schema names
 * @ return An array of schema name Strings ( May be an empty array )
 * @ throws SQLException propagated java . sql . SQLException
 * @ throws DatabaseException if a different problem occurs during the DBMS - specific code */
protected String [ ] getDatabaseSchemaNames ( Database database ) throws SQLException , DatabaseException { } }

implementation: List < String > returnList = new ArrayList < > ( ) ; ResultSet schemas = null ; try { schemas = ( ( JdbcConnection ) database . getConnection ( ) ) . getMetaData ( ) . getSchemas ( ) ; while ( schemas . next ( ) ) { returnList . add ( JdbcUtils . getValueForColumn ( schemas , "TABLE_SCHEM" , database ) ) ; } } finally { if ( schemas != null ) { schemas . close ( ) ; } } return returnList . toArray ( new String [ returnList . size ( ) ] ) ;


signature:
public class CSVReader { /** * Reads the entire file into a List with each element being a String [ ] of
 * tokens .
 * @ return a List of String [ ] , with each String [ ] representing a line of the
 * file .
 * @ throws IOException if bad things happen during the read */
public List < String [ ] > readAll ( ) throws IOException { } }

implementation: List < String [ ] > allElements = new ArrayList < > ( ) ; while ( hasNext ) { String [ ] nextLineAsTokens = readNext ( ) ; if ( nextLineAsTokens != null ) { allElements . add ( nextLineAsTokens ) ; } } return allElements ;


signature:
public class CSVReader { /** * Reads the next line from the buffer and converts to a string array .
 * @ return a string array with each comma - separated element as a separate
 * entry .
 * @ throws IOException if bad things happen during the read */
public String [ ] readNext ( ) throws IOException { } }

implementation: String [ ] result = null ; do { String nextLine = getNextLine ( ) ; if ( ! hasNext ) { return validateResult ( result ) ; } String [ ] r = parser . parseLineMulti ( nextLine ) ; if ( r . length > 0 ) { if ( result == null ) { result = r ; } else { result = combineResultsFromMultipleReads ( result , r ) ; } } } while ( parser . isPending ( ) ) ; return validateResult ( result ) ;


signature:
public class CSVReader { /** * For multi line records this method combines the current result with the result from previous read ( s ) .
 * @ param buffer - previous data read for this record
 * @ param lastRead - latest data read for this record .
 * @ return String array with union of the buffer and lastRead arrays . */
protected String [ ] combineResultsFromMultipleReads ( String [ ] buffer , String [ ] lastRead ) { } }

implementation: String [ ] t = new String [ buffer . length + lastRead . length ] ; System . arraycopy ( buffer , 0 , t , 0 , buffer . length ) ; System . arraycopy ( lastRead , 0 , t , buffer . length , lastRead . length ) ; return t ;


signature:
public class CSVReader { /** * Reads the next line from the file .
 * @ return the next line from the file without trailing newline
 * @ throws IOException if bad things happen during the read */
protected String getNextLine ( ) throws IOException { } }

implementation: if ( isClosed ( ) ) { hasNext = false ; return null ; } if ( ! this . linesSkiped ) { for ( int i = 0 ; i < skipLines ; i ++ ) { lineReader . readLine ( ) ; linesRead ++ ; } this . linesSkiped = true ; } String nextLine = lineReader . readLine ( ) ; if ( nextLine == null ) { hasNext = false ; } else { linesRead ++ ; } return hasNext ? nextLine : null ;


signature:
public class CSVReader { /** * Checks to see if the file is closed .
 * @ return true if the reader can no longer be read from . */
private boolean isClosed ( ) { } }

implementation:
if ( ! verifyReader ) { return false ; } try { br . mark ( READ_AHEAD_LIMIT ) ; int nextByte = br . read ( ) ; br . reset ( ) ; // resets stream position , possible because its buffered
return nextByte == - 1 ; // read ( ) returns - 1 at end of stream
} catch ( IOException e ) { return true ; }


signature:
public class PollResult { /** * Create a result that represents incremental changes from the configuration
 * source .
 * @ param added properties added
 * @ param changed properties changed
 * @ param deleted properties deleted , in which case the value in the map will be ignored
 * @ param checkPoint Object that served as a marker for this incremental change , for example , a time stamp
 * of the last change . */
public static PollResult createIncremental ( Map < String , Object > added , Map < String , Object > changed , Map < String , Object > deleted , Object checkPoint ) { } }

implementation: return new PollResult ( added , changed , deleted , checkPoint ) ;


signature:
public class DefaultContextualPredicate { /** * For each key in the passed in map , this function returns true if
 * < li > the value derived from the key using the function ( passed in from the constructor ) matches < b > any < / b > of the value included for the same key in the map
 * < li > the above holds true for < b > all < / b > keys in the map */
@ Override public boolean apply ( @ Nullable Map < String , Collection < String > > input ) { } }

implementation: if ( null == input ) { throw new NullPointerException ( ) ; } for ( Map . Entry < String , Collection < String > > entry : input . entrySet ( ) ) { String key = entry . getKey ( ) ; Collection < String > value = entry . getValue ( ) ; if ( ! value . contains ( getValueFromKeyFunction . apply ( key ) ) ) { return false ; } } return true ;


signature:
public class DynamicConfiguration { /** * Start polling the configuration source with the specified scheduler .
 * @ param source PolledConfigurationSource to poll
 * @ param scheduler AbstractPollingScheduler whose { @ link AbstractPollingScheduler # schedule ( Runnable ) } will be
 * used to determine the polling schedule */
public synchronized void startPolling ( PolledConfigurationSource source , AbstractPollingScheduler scheduler ) { } }

implementation: this . scheduler = scheduler ; this . source = source ; init ( source , scheduler ) ; scheduler . startPolling ( source , this ) ;


signature:
public class ZooKeeperConfigurationSource { /** * Adds a listener to the pathChildrenCache , initializes the cache , then starts the cache - management background thread
 * @ throws Exception */
public void start ( ) throws Exception { } }

implementation:
// create the watcher for future configuration updatess
pathChildrenCache . getListenable ( ) . addListener ( new PathChildrenCacheListener ( ) { public void childEvent ( CuratorFramework aClient , PathChildrenCacheEvent event ) throws Exception { Type eventType = event . getType ( ) ; ChildData data = event . getData ( ) ; String path = null ; if ( data != null ) { path = data . getPath ( ) ; // scrub configRootPath out of the key name
String key = removeRootPath ( path ) ; byte [ ] value = data . getData ( ) ; String stringValue = new String ( value , charset ) ; logger . debug ( "received update to pathName [{}], eventType [{}]" , path , eventType ) ; logger . debug ( "key [{}], and value [{}]" , key , stringValue ) ; // fire event to all listeners
Map < String , Object > added = null ; Map < String , Object > changed = null ; Map < String , Object > deleted = null ; if ( eventType == Type . CHILD_ADDED ) { added = new HashMap < String , Object > ( 1 ) ; added . put ( key , stringValue ) ; } else if ( eventType == Type . CHILD_UPDATED ) { changed = new HashMap < String , Object > ( 1 ) ; changed . put ( key , stringValue ) ; } else if ( eventType == Type . CHILD_REMOVED ) { deleted = new HashMap < String , Object > ( 1 ) ; deleted . put ( key , stringValue ) ; } WatchedUpdateResult result = WatchedUpdateResult . createIncremental ( added , changed , deleted ) ; fireEvent ( result ) ; } } } ) ; // passing true to trigger an initial rebuild upon starting . ( blocking call )
pathChildrenCache . start ( true ) ;


signature:
public class WebApplicationProperties { /** * Initialize . The application should call this method once the Application
 * Folder is set using { @ link # setAppConfFolder ( File , String ) } method .
 * @ param appConfFolderFromConfig
 * @ param baseConfigFileName
 * @ param loadLibraryProperties
 * @ param propertiesResourceRelativePath */
public static void initialize ( File appConfFolderFromConfig , String baseConfigFileName , boolean loadLibraryProperties , String propertiesResourceRelativePath ) { } }

implementation: WebApplicationProperties . appConfFolder = appConfFolderFromConfig ; WebApplicationProperties . baseConfigFileName = baseConfigFileName ; WebApplicationProperties . loadLibraryProperties = loadLibraryProperties ; WebApplicationProperties . libraryPropertiesResourceRelativePath = propertiesResourceRelativePath ; initialize ( ) ;


signature:
public class WebApplicationProperties { /** * Initialize .
 * The application should call this method once the Application Folder is set using { @ link # setAppConfFolder ( File , String ) } method . */
public static void initialize ( ) { } }

implementation:
try { initApplicationProperties ( ) ; } catch ( Exception e ) { logger . error ( "Unable to load Application Properties" , e ) ; System . err . println ( "Unable to load Application Properties" ) ; e . printStackTrace ( ) ; } // should we load the properties in the JAR files ?
if ( loadLibraryProperties ) { try { initClasspathPropertiesConfiguration ( ) ; } catch ( Exception e ) { logger . error ( "Unable to load Library Properties" , e ) ; System . err . println ( "Unable to load Library Properties" ) ; e . printStackTrace ( ) ; } } logger . debug ( "Properties loaded:" + getProperties ( ) ) ;


signature:
public class WebApplicationProperties { /** * The folder where the application ' s properties files are located .
 * @ param appConfFolderFromConfig
 * the folder as a < code > File < / code > object where the
 * application ' s properties files are located
 * @ param baseConfigFileName
 * the " base " name of the properties file . For e . g . if you have
 * config . properties , config - test . properties , then the value to
 * pass in is " config " */
public static void setAppConfFolder ( File appConfFolderFromConfig , String baseConfigFileName ) { } }

implementation: WebApplicationProperties . appConfFolder = appConfFolderFromConfig ; WebApplicationProperties . baseConfigFileName = baseConfigFileName ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public void addProperty ( String key , Object value ) { } }

implementation: config . addProperty ( key , value ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public BigDecimal getBigDecimal ( String key , BigDecimal defaultValue ) { } }

implementation: return config . getBigDecimal ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public BigInteger getBigInteger ( String key , BigInteger defaultValue ) { } }

implementation: return config . getBigInteger ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public Boolean getBoolean ( String key , Boolean defaultValue ) { } }

implementation: return config . getBoolean ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public Byte getByte ( String key , Byte defaultValue ) { } }

implementation: return config . getByte ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public Double getDouble ( String key , Double defaultValue ) { } }

implementation: return config . getDouble ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public Float getFloat ( String key , Float defaultValue ) { } }

implementation: return config . getFloat ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public Integer getInteger ( String key , Integer defaultValue ) { } }

implementation: return config . getInteger ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public List getList ( String key , List defaultValue ) { } }

implementation: return config . getList ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public Long getLong ( String key , Long defaultValue ) { } }

implementation: return config . getLong ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public Short getShort ( String key , Short defaultValue ) { } }

implementation: return config . getShort ( key , defaultValue ) ;


signature:
public class ConfigurationWithPollingSource { /** * Delegates to the underlying configuration . */
@ Override public void setProperty ( String key , Object value ) { } }

implementation: config . setProperty ( key , value ) ;


signature:
public class DynamicPropertyFactory { /** * Initialize the factory with an AbstractConfiguration .
 * The initialization will register a ConfigurationListener with the configuration so that { @ link DynamicProperty }
 * will receives a callback and refresh its value when a property is changed in the configuration .
 * If the factory is already initialized with a default configuration source ( see { @ link # getInstance ( ) } ) , it will re - register
 * itself with the new configuration source passed to this method . Otherwise , this method will throw IllegalArgumentException
 * if it has been initialized with a different and non - default configuration source . This method should be only called once .
 * @ param config Configuration to be attached with DynamicProperty
 * @ return the instance of DynamicPropertyFactory
 * @ throws IllegalArgumentException if the factory has already been initialized with a non - default configuration source */
public static DynamicPropertyFactory initWithConfigurationSource ( AbstractConfiguration config ) { } }

implementation: synchronized ( ConfigurationManager . class ) { if ( config == null ) { throw new NullPointerException ( "config is null" ) ; } if ( ConfigurationManager . isConfigurationInstalled ( ) && config != ConfigurationManager . instance ) { throw new IllegalStateException ( "ConfigurationManager is already initialized with configuration " + ConfigurationManager . getConfigInstance ( ) ) ; } if ( config instanceof DynamicPropertySupport ) { return initWithConfigurationSource ( ( DynamicPropertySupport ) config ) ; } return initWithConfigurationSource ( new ConfigurationBackedDynamicPropertySupportImpl ( config ) ) ; }


signature:
public class DynamicPropertyFactory { /** * Initialize the factory with a { @ link DynamicPropertySupport } .
 * The initialization will register a { @ link PropertyListener } with the DynamicPropertySupport so that DynamicProperty
 * will receives a callback and refresh its value when a property is changed .
 * If the factory is already initialized with a default configuration source ( see { @ link # getInstance ( ) } ) , it will re - register
 * itself with the new configuration source passed to this method . Otherwise , this method will throw IllegalArgumentException
 * if it has been initialized with a non - default configuration source . This method should be only called once .
 * @ param dynamicPropertySupport DynamicPropertySupport to be associated with the DynamicProperty
 * @ return the instance of DynamicPropertyFactory
 * @ throws IllegalArgumentException if the factory has already been initialized with a different and non - default configuration source */
public static DynamicPropertyFactory initWithConfigurationSource ( DynamicPropertySupport dynamicPropertySupport ) { } }

implementation: synchronized ( ConfigurationManager . class ) { if ( dynamicPropertySupport == null ) { throw new IllegalArgumentException ( "dynamicPropertySupport is null" ) ; } AbstractConfiguration configuration = null ; if ( dynamicPropertySupport instanceof AbstractConfiguration ) { configuration = ( AbstractConfiguration ) dynamicPropertySupport ; } else if ( dynamicPropertySupport instanceof ConfigurationBackedDynamicPropertySupportImpl ) { configuration = ( ( ConfigurationBackedDynamicPropertySupportImpl ) dynamicPropertySupport ) . getConfiguration ( ) ; } if ( initializedWithDefaultConfig ) { config = null ; } else if ( config != null && config != dynamicPropertySupport ) { throw new IllegalStateException ( "DynamicPropertyFactory is already initialized with a diffrerent configuration source: " + config ) ; } if ( ConfigurationManager . isConfigurationInstalled ( ) && ( configuration != null && configuration != ConfigurationManager . instance ) ) { throw new IllegalStateException ( "ConfigurationManager is already initialized with configuration " + ConfigurationManager . getConfigInstance ( ) ) ; } if ( configuration != null && configuration != ConfigurationManager . instance ) { ConfigurationManager . setDirect ( configuration ) ; } setDirect ( dynamicPropertySupport ) ; return instance ; }


signature:
public class DynamicPropertyFactory { /** * Get the instance to create dynamic properties . If the factory is not initialized with a configuration source
 * ( see { @ link # initWithConfigurationSource ( AbstractConfiguration ) } and { @ link # initWithConfigurationSource ( DynamicPropertySupport ) } ) ,
 * it will fist try to initialize itself with a default { @ link ConcurrentCompositeConfiguration } , with the following two
 * sub configurations :
 * < ul >
 * < li > A SystemConfiguration , which contains all the system properties . You can disable adding this Configuration by setting
 * system property { @ value # DISABLE _ DEFAULT _ SYS _ CONFIG } to < code > true < / code >
 * < li > A { @ link DynamicURLConfiguration } , which at a fixed interval polls
 * a configuration file ( see { @ link URLConfigurationSource # DEFAULT _ CONFIG _ FILE _ NAME } ) on classpath and a set of URLs specified via a system property
 * ( see { @ link URLConfigurationSource # CONFIG _ URL } ) .
 * < / ul >
 * Between the two sub - configurations , the SystemConfiguration will take the precedence when determining property values .
 * You can disable the initialization with the default configuration by setting system property { @ value # DISABLE _ DEFAULT _ CONFIG } to " true " . */
public static DynamicPropertyFactory getInstance ( ) { } }

implementation: if ( config == null ) { synchronized ( ConfigurationManager . class ) { if ( config == null ) { AbstractConfiguration configFromManager = ConfigurationManager . getConfigInstance ( ) ; if ( configFromManager != null ) { initWithConfigurationSource ( configFromManager ) ; initializedWithDefaultConfig = ! ConfigurationManager . isConfigurationInstalled ( ) ; logger . info ( "DynamicPropertyFactory is initialized with configuration sources: " + configFromManager ) ; } } } } return instance ;


signature:
public class DynamicPropertyFactory { /** * Create a new property whose value is a string and subject to change on - the - fly .
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration */
public DynamicStringProperty getStringProperty ( String propName , String defaultValue ) { } }

implementation: return getStringProperty ( propName , defaultValue , null ) ;


signature:
public class DynamicPropertyFactory { /** * Create a new property whose value is a string and subject to change on - the - fly .
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration
 * @ param propertyChangeCallback a Runnable to be called when the property is changed */
public DynamicStringProperty getStringProperty ( String propName , String defaultValue , final Runnable propertyChangeCallback ) { } }

implementation: checkAndWarn ( propName ) ; DynamicStringProperty property = new DynamicStringProperty ( propName , defaultValue ) ; addCallback ( propertyChangeCallback , property ) ; return property ;


signature:
public class DynamicPropertyFactory { /** * Create a new property whose value is an integer and subject to change on - the - fly .
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration
 * @ param propertyChangeCallback a Runnable to be called when the property is changed */
public DynamicIntProperty getIntProperty ( String propName , int defaultValue , final Runnable propertyChangeCallback ) { } }

implementation: checkAndWarn ( propName ) ; DynamicIntProperty property = new DynamicIntProperty ( propName , defaultValue ) ; addCallback ( propertyChangeCallback , property ) ; return property ;


signature:
public class DynamicPropertyFactory { /** * Create a new property whose value is a long and subject to change on - the - fly .
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration
 * @ param propertyChangeCallback a Runnable to be called when the property is changed */
public DynamicLongProperty getLongProperty ( String propName , long defaultValue , final Runnable propertyChangeCallback ) { } }

implementation: checkAndWarn ( propName ) ; DynamicLongProperty property = new DynamicLongProperty ( propName , defaultValue ) ; addCallback ( propertyChangeCallback , property ) ; return property ;


signature:
public class DynamicPropertyFactory { /** * Create a new property whose value is a boolean and subject to change on - the - fly .
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration
 * @ param propertyChangeCallback a Runnable to be called when the property is changed */
public DynamicBooleanProperty getBooleanProperty ( String propName , boolean defaultValue , final Runnable propertyChangeCallback ) { } }

implementation: checkAndWarn ( propName ) ; DynamicBooleanProperty property = new DynamicBooleanProperty ( propName , defaultValue ) ; addCallback ( propertyChangeCallback , property ) ; return property ;


signature:
public class DynamicPropertyFactory { /** * Create a new property whose value is a float and subject to change on - the - fly .
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration
 * @ param propertyChangeCallback a Runnable to be called when the property is changed */
public DynamicFloatProperty getFloatProperty ( String propName , float defaultValue , final Runnable propertyChangeCallback ) { } }

implementation: checkAndWarn ( propName ) ; DynamicFloatProperty property = new DynamicFloatProperty ( propName , defaultValue ) ; addCallback ( propertyChangeCallback , property ) ; return property ;


signature:
public class DynamicPropertyFactory { /** * Create a new property whose value is a double and subject to change on - the - fly .
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration
 * @ param propertyChangeCallback a Runnable to be called when the property is changed */
public DynamicDoubleProperty getDoubleProperty ( String propName , double defaultValue , final Runnable propertyChangeCallback ) { } }

implementation: checkAndWarn ( propName ) ; DynamicDoubleProperty property = new DynamicDoubleProperty ( propName , defaultValue ) ; addCallback ( propertyChangeCallback , property ) ; return property ;


signature:
public class DynamicPropertyFactory { /** * Create a new contextual property of type T
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration
 * @ param < T > the type of the property value */
public < T > DynamicContextualProperty < T > getContextualProperty ( String propName , T defaultValue ) { } }

implementation: return getContextualProperty ( propName , defaultValue , null ) ;


signature:
public class DynamicPropertyFactory { /** * Create a new contextual property of type T
 * @ param propName property name
 * @ param defaultValue default value if the property is not defined in underlying configuration
 * @ param propertyChangeCallback a Runnable to be called when the property is changed
 * @ param < T > the type of the property value */
public < T > DynamicContextualProperty < T > getContextualProperty ( String propName , T defaultValue , final Runnable propertyChangeCallback ) { } }

implementation: checkAndWarn ( propName ) ; DynamicContextualProperty < T > property = new DynamicContextualProperty < T > ( propName , defaultValue ) ; addCallback ( propertyChangeCallback , property ) ; return property ;


signature:
public class DynamoDbDeploymentContextTableCache { /** * Scan the table in dynamo and create a map with the results . In this case the map has a complex type as the value ,
 * so that Deployment Context is taken into account .
 * @ param table
 * @ return */
@ Override protected Map < String , PropertyWithDeploymentContext > loadPropertiesFromTable ( String table ) { } }

implementation:
Map < String , PropertyWithDeploymentContext > propertyMap = new HashMap < String , PropertyWithDeploymentContext > ( ) ; Map < String , AttributeValue > lastKeysEvaluated = null ; do { ScanRequest scanRequest = new ScanRequest ( ) . withTableName ( table ) . withExclusiveStartKey ( lastKeysEvaluated ) ; ScanResult result = dbScanWithThroughputBackOff ( scanRequest ) ; for ( Map < String , AttributeValue > item : result . getItems ( ) ) { String keyVal = item . get ( keyAttributeName . get ( ) ) . getS ( ) ; // Need to deal with the fact that these attributes might not exist
DeploymentContext . ContextKey contextKey = item . containsKey ( contextKeyAttributeName . get ( ) ) ? DeploymentContext . ContextKey . valueOf ( item . get ( contextKeyAttributeName . get ( ) ) . getS ( ) ) : null ; String contextVal = item . containsKey ( contextValueAttributeName . get ( ) ) ? item . get ( contextValueAttributeName . get ( ) ) . getS ( ) : null ; String key = keyVal + ";" + contextKey + ";" + contextVal ; propertyMap . put ( key , new PropertyWithDeploymentContext ( contextKey , contextVal , keyVal , item . get ( valueAttributeName . get ( ) ) . getS ( ) ) ) ; } lastKeysEvaluated = result . getLastEvaluatedKey ( ) ; } while ( lastKeysEvaluated != null ) ; return propertyMap ;


signature:
public class BaseConfigMBean { /** * Calls < code > config . setProperty ( ) < / code > . If the underlying configuration
 * is { @ link ConcurrentCompositeConfiguration } , it calls { @ link ConcurrentCompositeConfiguration # setOverrideProperty ( String , Object ) }
 * instead . */
@ Override public void updateProperty ( String key , String value ) { } }

implementation: if ( config instanceof ConcurrentCompositeConfiguration ) { ( ( ConcurrentCompositeConfiguration ) config ) . setOverrideProperty ( key , value ) ; } else { config . setProperty ( key , value ) ; }


signature:
public class BaseConfigMBean { /** * Calls < code > config . clearProperty ( ) < / code > . If the underlying configuration
 * is { @ link ConcurrentCompositeConfiguration } , it calls { @ link ConcurrentCompositeConfiguration # clearOverrideProperty ( String ) }
 * instead .
 * < p > < b > Warning : < / b > { @ link ConcurrentCompositeConfiguration # clearOverrideProperty ( String ) } does not clear the
 * property with the whole { @ link ConcurrentCompositeConfiguration } , if any other child configurations in it has the same property . */
@ Override public void clearProperty ( String key ) { } }

implementation: if ( config instanceof ConcurrentCompositeConfiguration ) { ( ( ConcurrentCompositeConfiguration ) config ) . clearOverrideProperty ( key ) ; } else { config . clearProperty ( key ) ; }


signature:
public class BaseConfigMBean { /** * Calls < code > config . addrProperty ( ) < / code > . If the underlying configuration
 * is { @ link ConcurrentCompositeConfiguration } , it calls { @ link ConcurrentCompositeConfiguration # setOverrideProperty ( String , Object ) }
 * instead . */
@ Override public void addProperty ( String key , String value ) { } }

implementation: if ( config instanceof ConcurrentCompositeConfiguration ) { ( ( ConcurrentCompositeConfiguration ) config ) . setOverrideProperty ( key , value ) ; } else { config . addProperty ( key , value ) ; }


signature:
public class ConfigurationBasedDeploymentContext { /** * Get the deployment environment . If property " archaius . deployment . environment "
 * is set in the system wide configuration , it will return it . Otherwise , it will return super . getDeploymentEnvironment ( ) . */
@ Override public String getDeploymentEnvironment ( ) { } }

implementation: String value = getValueFromConfig ( DeploymentContext . ContextKey . environment . getKey ( ) ) ; if ( value != null ) { return value ; } else { value = getValueFromConfig ( DEPLOYMENT_ENVIRONMENT_PROPERTY ) ; if ( value != null ) { return value ; } else { return super . getDeploymentEnvironment ( ) ; } }


signature:
public class ConfigurationBasedDeploymentContext { /** * Call super and also update the configuration to reflect the changes .
 * @ param value */
@ Override public void setDeploymentEnvironment ( String value ) { } }

implementation: super . setDeploymentEnvironment ( value ) ; setValueInConfig ( DEPLOYMENT_ENVIRONMENT_PROPERTY , value ) ; setValueInConfig ( ContextKey . environment . getKey ( ) , value ) ;


signature:
public class ConfigurationBasedDeploymentContext { /** * Get the deployment environment . If property " archaius . deployment . datacenter "
 * is set in the system wide configuration , it will return it . Otherwise , it will return super . getDeploymentDatacenter ( ) . */
@ Override public String getDeploymentDatacenter ( ) { } }

implementation: String value = getValueFromConfig ( DeploymentContext . ContextKey . datacenter . getKey ( ) ) ; if ( value != null ) { return value ; } else { value = getValueFromConfig ( DEPLOYMENT_DATACENTER_PROPERTY ) ; } if ( value != null ) { return value ; } else { return super . getDeploymentDatacenter ( ) ; }


signature:
public class ConfigurationBasedDeploymentContext { /** * Call super and also update the configuration to reflect the changes .
 * @ param value */
@ Override public void setDeploymentDatacenter ( String value ) { } }

implementation: super . setDeploymentDatacenter ( value ) ; setValueInConfig ( DEPLOYMENT_DATACENTER_PROPERTY , value ) ; setValueInConfig ( ContextKey . datacenter . getKey ( ) , value ) ;


signature:
public class ConfigurationBasedDeploymentContext { /** * Get the deployment environment . If property " archaius . deployment . applicationId "
 * is set in the system wide configuration , it will return it . Otherwise , it will return super . getApplicationId ( ) . */
@ Override public String getApplicationId ( ) { } }

implementation: String value = getValueFromConfig ( DeploymentContext . ContextKey . appId . getKey ( ) ) ; if ( value != null ) { return value ; } else { value = getValueFromConfig ( DEPLOYMENT_APPLICATION_ID_PROPERTY ) ; } if ( value != null ) { return value ; } else { return super . getApplicationId ( ) ; }


signature:
public class ConfigurationBasedDeploymentContext { /** * Call super and also update the configuration to reflect the changes .
 * @ param value */
@ Override public void setApplicationId ( String value ) { } }

implementation: super . setApplicationId ( value ) ; setValueInConfig ( DEPLOYMENT_APPLICATION_ID_PROPERTY , value ) ; setValueInConfig ( ContextKey . appId . getKey ( ) , value ) ;


signature:
public class ConfigurationBasedDeploymentContext { /** * Get the deployment environment . If property " archaius . deployment . serverId "
 * is set in the system wide configuration , it will return it . Otherwise , it will return super . getDeploymentServerId ( ) . */
@ Override public String getDeploymentServerId ( ) { } }

implementation: String value = getValueFromConfig ( DeploymentContext . ContextKey . serverId . getKey ( ) ) ; if ( value != null ) { return value ; } else { value = getValueFromConfig ( DEPLOYMENT_SERVER_ID_PROPERTY ) ; } if ( value != null ) { return value ; } else { return super . getDeploymentServerId ( ) ; }


signature:
public class ConfigurationBasedDeploymentContext { /** * Call super and also update the configuration to reflect the changes .
 * @ param value */
@ Override public void setDeploymentServerId ( String value ) { } }

implementation: super . setDeploymentServerId ( value ) ; setValueInConfig ( DEPLOYMENT_SERVER_ID_PROPERTY , value ) ; setValueInConfig ( ContextKey . serverId . getKey ( ) , value ) ;


signature:
public class ConfigurationBasedDeploymentContext { /** * Get the deployment environment . If property " archaius . deployment . stack "
 * is set in the system wide configuration , it will return it . Otherwise , it will return super . getDeploymentStack ( ) . */
@ Override public String getDeploymentStack ( ) { } }

implementation: String value = getValueFromConfig ( DeploymentContext . ContextKey . stack . getKey ( ) ) ; if ( value != null ) { return value ; } else { value = getValueFromConfig ( DEPLOYMENT_STACK_PROPERTY ) ; } if ( value != null ) { return value ; } else { return super . getDeploymentStack ( ) ; }


signature:
public class ConfigurationBasedDeploymentContext { /** * Call super and also update the configuration to reflect the changes .
 * @ param value */
@ Override public void setDeploymentStack ( String value ) { } }

implementation: super . setDeploymentStack ( value ) ; setValueInConfig ( DEPLOYMENT_STACK_PROPERTY , value ) ; setValueInConfig ( ContextKey . stack . getKey ( ) , value ) ;


signature:
public class ConfigurationBasedDeploymentContext { /** * Get the deployment environment . If property " archaius . deployment . region "
 * is set in the system wide configuration , it will return it . Otherwise , it will return super . getDeploymentRegion ( ) . */
@ Override public String getDeploymentRegion ( ) { } }

implementation: String value = getValueFromConfig ( DeploymentContext . ContextKey . region . getKey ( ) ) ; if ( value != null ) { return value ; } else { value = getValueFromConfig ( DEPLOYMENT_REGION_PROPERTY ) ; } if ( value != null ) { return value ; } else { return super . getDeploymentRegion ( ) ; }


signature:
public class ConfigurationBasedDeploymentContext { /** * Call super and also update the configuration to reflect the changes .
 * @ param value */
@ Override public void setDeploymentRegion ( String value ) { } }

implementation: super . setDeploymentRegion ( value ) ; setValueInConfig ( DEPLOYMENT_REGION_PROPERTY , value ) ; setValueInConfig ( ContextKey . region . getKey ( ) , value ) ;


signature:
public class DynamicProperty { /** * Gets the DynamicProperty for a given property name .
 * This may be a previously constructed object ,
 * or an object constructed on - demand to satisfy the request .
 * @ param propName the name of the property
 * @ return a DynamicProperty object that holds the cached value of
 * the configuration property named { @ code propName } */
public static DynamicProperty getInstance ( String propName ) { } }

implementation:
// This is to ensure that a configuration source is registered with
// DynamicProperty
if ( dynamicPropertySupportImpl == null ) { DynamicPropertyFactory . getInstance ( ) ; } DynamicProperty prop = ALL_PROPS . get ( propName ) ; if ( prop == null ) { prop = new DynamicProperty ( propName ) ; DynamicProperty oldProp = ALL_PROPS . putIfAbsent ( propName , prop ) ; if ( oldProp != null ) { prop = oldProp ; } } return prop ;


signature:
public class DynamicProperty { /** * return true iff the value actually changed */
private boolean updateValue ( ) { } }

implementation: String newValue ; try { if ( dynamicPropertySupportImpl != null ) { newValue = dynamicPropertySupportImpl . getString ( propName ) ; } else { return false ; } } catch ( Exception e ) { e . printStackTrace ( ) ; logger . error ( "Unable to update property: " + propName , e ) ; return false ; } return updateValue ( newValue ) ;


signature:
public class DynamicProperty { /** * return true iff the value actually changed */
boolean updateValue ( Object newValue ) { } }

implementation: String nv = ( newValue == null ) ? null : newValue . toString ( ) ; synchronized ( lock ) { if ( ( nv == null && stringValue == null ) || ( nv != null && nv . equals ( stringValue ) ) ) { return false ; } stringValue = nv ; setStatusForValues ( ) ; changedTime = System . currentTimeMillis ( ) ; return true ; }


signature:
public class DynamicProperty { /** * return true iff the value actually changed */
private static boolean updateProperty ( String propName , Object value ) { } }

implementation: DynamicProperty prop = ALL_PROPS . get ( propName ) ; if ( prop != null && prop . updateValue ( value ) ) { prop . notifyCallbacks ( ) ; return true ; } return false ;


signature:
public class DynamicProperty { /** * return true iff _ some _ value actually changed */
private static boolean updateAllProperties ( ) { } }

implementation: boolean changed = false ; for ( DynamicProperty prop : ALL_PROPS . values ( ) ) { if ( prop . updateValue ( ) ) { prop . notifyCallbacks ( ) ; changed = true ; } } return changed ;


signature:
public class AbstractDynamoDbConfigurationSource { /** * TODO Javadoc */
public void validateDb ( ) { } }

implementation: String table = tableName . get ( ) ; loadPropertiesFromTable ( table ) ; log . info ( "Successfully polled Dynamo for a new configuration based on table:" + table ) ;


signature:
public class PropertyWrapper { /** * Add the callback to be triggered when the value of the property is changed
 * @ param callback */
@ Override public void addCallback ( Runnable callback ) { } }

implementation: if ( callback != null ) { prop . addCallback ( callback ) ; callbacks . add ( callback ) ; }


signature:
public class PropertyWrapper { /** * Remove all callbacks registered through this instance of property */
@ Override public void removeAllCallbacks ( ) { } }

implementation: final Set < Runnable > callbacksToRemove = new HashSet < Runnable > ( callbacks ) ; for ( Runnable callback : callbacksToRemove ) { prop . removeCallback ( callback ) ; } callbacks . removeAll ( callbacksToRemove ) ;


signature:
public class HttpVerbUriRegexPropertyValue { /** * Expects property value to be of the form & lt ; uriRegex & gt ; OR & lt ; HTTP
 * Verb name & gt ; & lt ; space & gt ; & lt ; uriRegex & gt ;
 * @ param propValue
 * property value
 * @ return { @ link HttpVerbUriRegexPropertyValue } instance corresponding to
 * propValue if propValue is not null , null otherwise */
public static HttpVerbUriRegexPropertyValue getVerbUriRegex ( String propValue ) { } }

implementation:
HttpVerbUriRegexPropertyValue returnValue = null ; if ( propValue != null ) { propValue = propValue . trim ( ) ; int methodSeparatorIndex = propValue . indexOf ( METHOD_SEPARATOR ) ; String uriRegex = propValue ; // to begin with
Verb verb = Verb . ANY_VERB ; if ( methodSeparatorIndex != - 1 ) { // user may have supplied a verb
verb = getVerb ( propValue . substring ( 0 , methodSeparatorIndex ) ) ; if ( verb != Verb . ANY_VERB ) { // update uriRegex
uriRegex = propValue . substring ( methodSeparatorIndex + 1 ) ; } } returnValue = new HttpVerbUriRegexPropertyValue ( verb , uriRegex ) ; } return returnValue ;


signature: public class JDBCConfigurationSource { @ Override public PollResult poll ( boolean initial , Object checkPoint ) throws Exception { } }

implementation:
// implement logic to retrieve properties from DB
Map < String , Object > map = load ( ) ; return PollResult . createFull ( map ) ;


signature:
public class JDBCConfigurationSource { /** * Returns a < code > Map < String , Object > < / code > of properties stored in the
 * database
 * @ throws Exception */
synchronized Map < String , Object > load ( ) throws Exception { } }

implementation: Map < String , Object > map = new HashMap < String , Object > ( ) ; Connection conn = null ; PreparedStatement pstmt = null ; ResultSet rs = null ; try { conn = getConnection ( ) ; pstmt = conn . prepareStatement ( query . toString ( ) ) ; rs = pstmt . executeQuery ( ) ; while ( rs . next ( ) ) { String key = ( String ) rs . getObject ( keyColumnName ) ; Object value = rs . getObject ( valueColumnName ) ; map . put ( key , value ) ; } } catch ( SQLException e ) { throw e ; } finally { close ( conn , pstmt , rs ) ; } return map ;


signature:
public class JDBCConfigurationSource { /** * Close a < code > Connection < / code > and , < code > Statement < / code > . Avoid
 * closing if null and hide any SQLExceptions that occur .
 * @ param conn
 * The database connection to close
 * @ param stmt
 * The statement to close */
private void close ( Connection conn , Statement stmt , ResultSet rs ) { } }

implementation: try { if ( rs != null ) { rs . close ( ) ; } } catch ( SQLException e ) { log . error ( "An error occured on closing the ResultSet" , e ) ; } try { if ( stmt != null ) { stmt . close ( ) ; } } catch ( SQLException e ) { log . error ( "An error occured on closing the statement" , e ) ; } try { if ( conn != null ) { conn . close ( ) ; } } catch ( SQLException e ) { log . error ( "An error occured on closing the connection" , e ) ; }


signature:
public class ConfigurationUtils { /** * Convert CombinedConfiguration into { @ link ConcurrentCompositeConfiguration } as the later has better performance
 * and thread safety .
 * @ param config Configuration to be converted */
public static ConcurrentCompositeConfiguration convertToConcurrentCompositeConfiguration ( CombinedConfiguration config ) { } }

implementation: ConcurrentCompositeConfiguration root = new ConcurrentCompositeConfiguration ( ) ; IdentityHashMap < Configuration , String > reverseMap = new IdentityHashMap < Configuration , String > ( ) ; for ( String name : ( Set < String > ) config . getConfigurationNames ( ) ) { Configuration child = config . getConfiguration ( name ) ; reverseMap . put ( child , name ) ; } for ( int i = 0 ; i < config . getNumberOfConfigurations ( ) ; i ++ ) { Configuration child = config . getConfiguration ( i ) ; String name = reverseMap . get ( child ) ; if ( child instanceof CombinedConfiguration ) { CombinedConfiguration combinedConf = ( CombinedConfiguration ) child ; ConcurrentCompositeConfiguration newConf = convertToConcurrentCompositeConfiguration ( combinedConf ) ; root . addConfiguration ( newConf , name ) ; } else { Configuration conf = new ConcurrentMapConfiguration ( child ) ; root . addConfiguration ( ( AbstractConfiguration ) conf , name ) ; } } return root ;


signature:
public class ConfigurationUtils { /** * Gets all named sub - configuration from a configuration in a map . This method examines each sub - configuration
 * which is an instance of { @ link ConcurrentCompositeConfiguration } or CombinedConfiguration and extract the
 * named configurations out of them .
 * @ param conf Configuration to get all the named sub - configurations
 * @ return map where key is the name of the sub - configuration and value is the sub - configuration */
public static Map < String , Configuration > getAllNamedConfiguration ( Configuration conf ) { } }

implementation: List < Configuration > toProcess = new ArrayList < Configuration > ( ) ; Map < String , Configuration > map = new HashMap < String , Configuration > ( ) ; toProcess . add ( conf ) ; while ( ! toProcess . isEmpty ( ) ) { Configuration current = toProcess . remove ( 0 ) ; if ( current instanceof ConcurrentCompositeConfiguration ) { ConcurrentCompositeConfiguration composite = ( ConcurrentCompositeConfiguration ) current ; for ( String name : composite . getConfigurationNames ( ) ) { map . put ( name , composite . getConfiguration ( name ) ) ; } for ( Configuration c : composite . getConfigurations ( ) ) { toProcess . add ( c ) ; } } else if ( current instanceof CombinedConfiguration ) { CombinedConfiguration combined = ( CombinedConfiguration ) current ; for ( String name : ( Set < String > ) combined . getConfigurationNames ( ) ) { map . put ( name , combined . getConfiguration ( name ) ) ; } for ( int i = 0 ; i < combined . getNumberOfConfigurations ( ) ; i ++ ) { toProcess . add ( combined . getConfiguration ( i ) ) ; } } } return map ;


signature:
public class ConfigurationUtils { /** * Utility method to obtain < code > Properties < / code > given an instance of < code > AbstractConfiguration < / code > .
 * Returns an empty < code > Properties < / code > object if the config has no properties or is null .
 * @ param config Configuration to get the properties
 * @ return properties extracted from the configuration */
public static Properties getProperties ( Configuration config ) { } }

implementation: Properties p = new Properties ( ) ; if ( config != null ) { Iterator < String > it = config . getKeys ( ) ; while ( it . hasNext ( ) ) { String key = it . next ( ) ; if ( key != null ) { Object value = config . getProperty ( key ) ; if ( value != null ) { p . put ( key , value ) ; } } } } return p ;


signature:
public class ConfigurationUtils { /** * Load properties from InputStream with utf - 8 encoding , and it will take care of closing the input stream .
 * @ param fin
 * @ return
 * @ throws IOException */
public static Properties loadPropertiesFromInputStream ( InputStream fin ) throws IOException { } }

implementation: Properties props = new Properties ( ) ; InputStreamReader reader = new InputStreamReader ( fin , "UTF-8" ) ; try { props . load ( reader ) ; return props ; } finally { if ( reader != null ) { reader . close ( ) ; } if ( fin != null ) { fin . close ( ) ; } }


signature:
public class OverridingPropertiesConfiguration { /** * Need to override this method for PDCLOUD - 1809. */
@ Override public void addProperty ( String name , Object value ) { } }

implementation:
if ( containsKey ( name ) ) { // clear without triggering an event
clearPropertyDirect ( name ) ; } super . addProperty ( name , value ) ;


signature:
public class DynamicPropertyUpdater { /** * Updates the properties in the config param given the contents of the result param .
 * @ param result
 * either an incremental or full set of data
 * @ param config
 * underlying config map
 * @ param ignoreDeletesFromSource
 * if true , deletes will be skipped */
public void updateProperties ( final WatchedUpdateResult result , final Configuration config , final boolean ignoreDeletesFromSource ) { } }

implementation: if ( result == null || ! result . hasChanges ( ) ) { return ; } logger . debug ( "incremental result? [{}]" , result . isIncremental ( ) ) ; logger . debug ( "ignored deletes from source? [{}]" , ignoreDeletesFromSource ) ; if ( ! result . isIncremental ( ) ) { Map < String , Object > props = result . getComplete ( ) ; if ( props == null ) { return ; } for ( Entry < String , Object > entry : props . entrySet ( ) ) { addOrChangeProperty ( entry . getKey ( ) , entry . getValue ( ) , config ) ; } Set < String > existingKeys = new HashSet < String > ( ) ; for ( Iterator < String > i = config . getKeys ( ) ; i . hasNext ( ) ; ) { existingKeys . add ( i . next ( ) ) ; } if ( ! ignoreDeletesFromSource ) { for ( String key : existingKeys ) { if ( ! props . containsKey ( key ) ) { deleteProperty ( key , config ) ; } } } } else { Map < String , Object > props = result . getAdded ( ) ; if ( props != null ) { for ( Entry < String , Object > entry : props . entrySet ( ) ) { addOrChangeProperty ( entry . getKey ( ) , entry . getValue ( ) , config ) ; } } props = result . getChanged ( ) ; if ( props != null ) { for ( Entry < String , Object > entry : props . entrySet ( ) ) { addOrChangeProperty ( entry . getKey ( ) , entry . getValue ( ) , config ) ; } } if ( ! ignoreDeletesFromSource ) { props = result . getDeleted ( ) ; if ( props != null ) { for ( String name : props . keySet ( ) ) { deleteProperty ( name , config ) ; } } } }


signature:
public class DynamicPropertyUpdater { /** * Add or update the property in the underlying config depending on if it exists
 * @ param name
 * @ param newValue
 * @ param config */
void addOrChangeProperty ( final String name , final Object newValue , final Configuration config ) { } }

implementation:
// We do not want to abort the operation due to failed validation on one property
try { if ( ! config . containsKey ( name ) ) { logger . debug ( "adding property key [{}], value [{}]" , name , newValue ) ; config . addProperty ( name , newValue ) ; } else { Object oldValue = config . getProperty ( name ) ; if ( newValue != null ) { Object newValueArray ; if ( oldValue instanceof CopyOnWriteArrayList && AbstractConfiguration . getDefaultListDelimiter ( ) != '\0' ) { newValueArray = new CopyOnWriteArrayList ( ) ; Iterable < String > stringiterator = Splitter . on ( AbstractConfiguration . getDefaultListDelimiter ( ) ) . omitEmptyStrings ( ) . trimResults ( ) . split ( ( String ) newValue ) ; for ( String s : stringiterator ) { ( ( CopyOnWriteArrayList ) newValueArray ) . add ( s ) ; } } else { newValueArray = newValue ; } if ( ! newValueArray . equals ( oldValue ) ) { logger . debug ( "updating property key [{}], value [{}]" , name , newValue ) ; config . setProperty ( name , newValue ) ; } } else if ( oldValue != null ) { logger . debug ( "nulling out property key [{}]" , name ) ; config . setProperty ( name , null ) ; } } } catch ( ValidationException e ) { logger . warn ( "Validation failed for property " + name , e ) ; }


signature:
public class DynamicPropertyUpdater { /** * Delete a property in the underlying config
 * @ param key
 * @ param config */
void deleteProperty ( final String key , final Configuration config ) { } }

implementation: if ( config . containsKey ( key ) ) { logger . debug ( "deleting property key [" + key + "]" ) ; config . clearProperty ( key ) ; }


signature:
public class ConcurrentMapConfiguration { /** * Adds the specified value for the given property . This method supports
 * single values and containers ( e . g . collections or arrays ) as well . In the
 * latter case , { @ link # addPropertyDirect ( String , Object ) } will be called for each
 * element .
 * @ param key the property key
 * @ param value the value object
 * @ param delimiter the list delimiter character */
private void addPropertyValues ( String key , Object value , char delimiter ) { } }

implementation: Iterator it = PropertyConverter . toIterator ( value , delimiter ) ; while ( it . hasNext ( ) ) { addPropertyDirect ( key , it . next ( ) ) ; }


signature:
public class ConcurrentMapConfiguration { /** * Override the same method in { @ link AbstractConfiguration } to simplify the logic
 * to avoid multiple events being generated . It calls { @ link # clearPropertyDirect ( String ) }
 * followed by logic to add the property including calling { @ link # addPropertyDirect ( String , Object ) } . */
@ Override public void setProperty ( String key , Object value ) throws ValidationException { } }

implementation: if ( value == null ) { throw new NullPointerException ( "Value for property " + key + " is null" ) ; } fireEvent ( EVENT_SET_PROPERTY , key , value , true ) ; setPropertyImpl ( key , value ) ; fireEvent ( EVENT_SET_PROPERTY , key , value , false ) ;


signature:
public class ConcurrentMapConfiguration { /** * Load properties into the configuration . This method iterates through
 * the entries of the properties and call { @ link # setProperty ( String , Object ) } for
 * non - null key / value . */
public void loadProperties ( Properties props ) { } }

implementation: for ( Map . Entry < Object , Object > entry : props . entrySet ( ) ) { String key = ( String ) entry . getKey ( ) ; Object value = entry . getValue ( ) ; if ( key != null && value != null ) { setProperty ( key , value ) ; } }


signature:
public class ConcurrentMapConfiguration { /** * Copy properties of a configuration into this configuration . This method simply
 * iterates the keys of the configuration to be copied and call { @ link # setProperty ( String , Object ) }
 * for non - null key / value . */
@ Override public void copy ( Configuration c ) { } }

implementation: if ( c != null ) { for ( Iterator it = c . getKeys ( ) ; it . hasNext ( ) ; ) { String key = ( String ) it . next ( ) ; Object value = c . getProperty ( key ) ; if ( key != null && value != null ) { setProperty ( key , value ) ; } } }


signature:
public class ConcurrentMapConfiguration { /** * Clear the map and fire corresonding events . */
@ Override public void clear ( ) { } }

implementation: fireEvent ( EVENT_CLEAR , null , null , true ) ; map . clear ( ) ; fireEvent ( EVENT_CLEAR , null , null , false ) ;


signature:
public class ConcurrentMapConfiguration { /** * Utility method to get a Properties object from this Configuration */
public Properties getProperties ( ) { } }

implementation: Properties p = new Properties ( ) ; for ( Iterator i = getKeys ( ) ; i . hasNext ( ) ; ) { String name = ( String ) i . next ( ) ; String value = getString ( name ) ; p . put ( name , value ) ; } return p ;


signature:
public class ConcurrentMapConfiguration { /** * Creates an event and calls { @ link ConfigurationListener # configurationChanged ( ConfigurationEvent ) }
 * for all listeners while catching Throwable . */
@ Override protected void fireEvent ( int type , String propName , Object propValue , boolean beforeUpdate ) { } }

implementation: if ( listeners == null || listeners . size ( ) == 0 ) { return ; } ConfigurationEvent event = createEvent ( type , propName , propValue , beforeUpdate ) ; for ( ConfigurationListener l : listeners ) { try { l . configurationChanged ( event ) ; } catch ( ValidationException e ) { if ( beforeUpdate ) { throw e ; } else { logger . error ( "Unexpected exception" , e ) ; } } catch ( Throwable e ) { logger . error ( "Error firing configuration event" , e ) ; } }


signature:
public class ConcurrentMapConfiguration { /** * Creates an error event and calls { @ link ConfigurationErrorListener # configurationError ( ConfigurationErrorEvent ) }
 * for all listeners while catching Throwable . */
@ Override protected void fireError ( int type , String propName , Object propValue , Throwable ex ) { } }

implementation: if ( errorListeners == null || errorListeners . size ( ) == 0 ) { return ; } ConfigurationErrorEvent event = createErrorEvent ( type , propName , propValue , ex ) ; for ( ConfigurationErrorListener l : errorListeners ) { try { l . configurationError ( event ) ; } catch ( Throwable e ) { logger . error ( "Error firing configuration error event" , e ) ; } }


signature:
public class AbstractPollingScheduler { /** * Do an initial poll from the source and apply the result to the configuration .
 * @ param source source of the configuration
 * @ param config Configuration to apply the polling result
 * @ throws RuntimeException if any error occurs in polling the configuration source */
protected synchronized void initialLoad ( final PolledConfigurationSource source , final Configuration config ) { } }

implementation: PollResult result = null ; try { result = source . poll ( true , null ) ; checkPoint = result . getCheckPoint ( ) ; fireEvent ( EventType . POLL_SUCCESS , result , null ) ; } catch ( Throwable e ) { throw new RuntimeException ( "Unable to load Properties source from " + source , e ) ; } try { populateProperties ( result , config ) ; } catch ( Throwable e ) { throw new RuntimeException ( "Unable to load Properties" , e ) ; }


signature:
public class AbstractPollingScheduler { /** * Gets the runnable to be scheduled . The implementation does the following
 * < li > Gets the next check point
 * < li > call source . poll ( fase , checkpoint )
 * < li > fire event for poll listeners
 * < li > If success , update the configuration with the polled result
 * @ return Runnable to be scheduled in { @ link # schedule ( Runnable ) } */
protected Runnable getPollingRunnable ( final PolledConfigurationSource source , final Configuration config ) { } }

implementation: return new Runnable ( ) { public void run ( ) { log . debug ( "Polling started" ) ; PollResult result = null ; try { result = source . poll ( false , getNextCheckPoint ( checkPoint ) ) ; checkPoint = result . getCheckPoint ( ) ; fireEvent ( EventType . POLL_SUCCESS , result , null ) ; } catch ( Throwable e ) { log . error ( "Error getting result from polling source" , e ) ; fireEvent ( EventType . POLL_FAILURE , null , e ) ; return ; } try { populateProperties ( result , config ) ; } catch ( Throwable e ) { log . error ( "Error occured applying properties" , e ) ; } } } ;


signature:
public class AbstractPollingScheduler { /** * Initiate the first poll of the configuration source and schedule the runnable . This may start a new thread or
 * thread pool depending on the implementation of { @ link # schedule ( Runnable ) } .
 * @ param source Configuration source being polled
 * @ param config Configuration where the properties will be updated
 * @ throws RuntimeException if any error occurs in the initial polling */
public void startPolling ( final PolledConfigurationSource source , final Configuration config ) { } }

implementation: initialLoad ( source , config ) ; Runnable r = getPollingRunnable ( source , config ) ; schedule ( r ) ;


signature:
public class ExpandedConfigurationListenerAdapter { /** * { @ inheritDoc }
 * @ see ConfigurationListener # configurationChanged ( ConfigurationEvent ) */
@ SuppressWarnings ( "unchecked" ) @ Override public void configurationChanged ( final ConfigurationEvent event ) { } }

implementation:
if ( pauseListener ) { return ; } // Grab the event information . Some values may be null .
final Object source = event . getSource ( ) ; final String name = event . getPropertyName ( ) ; final Object value = event . getPropertyValue ( ) ; final boolean beforeUpdate = event . isBeforeUpdate ( ) ; // Handle the different types .
switch ( event . getType ( ) ) { // Key identifies node where the Collection of nodes was added , or
// null if it was at the root .
case HierarchicalConfiguration . EVENT_ADD_NODES : case ConcurrentCompositeConfiguration . EVENT_CONFIGURATION_SOURCE_CHANGED : expandedListener . configSourceLoaded ( source ) ; break ; // Key identifies the individual property that was added .
case AbstractConfiguration . EVENT_ADD_PROPERTY : expandedListener . addProperty ( source , name , value , beforeUpdate ) ; break ; // Entire configuration was cleared .
case AbstractConfiguration . EVENT_CLEAR : expandedListener . clear ( source , beforeUpdate ) ; break ; // Key identifies the single property that was cleared .
case AbstractConfiguration . EVENT_CLEAR_PROPERTY : expandedListener . clearProperty ( source , name , value , beforeUpdate ) ; break ; // Key identifies the nodes that were removed , along with all its
// children . Value after update is the List of nodes that were
// cleared . Before the update , the value is null .
case HierarchicalConfiguration . EVENT_CLEAR_TREE : // Ignore this . We rewrote the clearTree ( ) method below .
break ; // The current property set is invalid .
case CombinedConfiguration . EVENT_COMBINED_INVALIDATE : // listener . configSourceLoaded ( source ) ;
break ; // Key identifies the property that was read .
case AbstractConfiguration . EVENT_READ_PROPERTY : break ; // Key identifies the property that was set .
case AbstractConfiguration . EVENT_SET_PROPERTY : expandedListener . setProperty ( source , name , value , beforeUpdate ) ; break ; default : break ; }


signature:
public class WatchedUpdateResult { /** * Create a result that represents incremental changes from the configuration source .
 * @ param added
 * properties added
 * @ param changed
 * properties changed
 * @ param deleted
 * properties deleted , in which case the value in the map will be ignored */
public static WatchedUpdateResult createIncremental ( Map < String , Object > added , Map < String , Object > changed , Map < String , Object > deleted ) { } }

implementation: return new WatchedUpdateResult ( added , changed , deleted ) ;


signature:
public class WatchedUpdateResult { /** * Indicate whether this result has any content . If the result is incremental , this is true if there is any any
 * added , changed or deleted properties . If the result is complete , this is true if { @ link # getComplete ( ) } is null . */
public boolean hasChanges ( ) { } }

implementation: if ( incremental ) { return ( added != null && added . size ( ) > 0 ) || ( changed != null && changed . size ( ) > 0 ) || ( deleted != null && deleted . size ( ) > 0 ) ; } else { return complete != null ; }


signature:
public class ConcurrentCompositeConfiguration { /** * Adds a new child configuration to this configuration with an optional
 * name . The configuration will be added to the end of the list
 * if < em > container configuration < / em > has been changed to new one or no longer at the end of
 * the list . Otherwise it will be added in front of the < em > container configuration < / em > .
 * @ param config the configuration to add ( must not be < b > null < / b > )
 * @ param name the name of this configuration ( can be < b > null < / b > ) */
public void addConfiguration ( AbstractConfiguration config , String name ) { } }

implementation: if ( containerConfigurationChanged ) { addConfigurationAtIndex ( config , name , configList . size ( ) ) ; } else { addConfigurationAtIndex ( config , name , configList . indexOf ( containerConfiguration ) ) ; }


signature:
public class ConcurrentCompositeConfiguration { /** * Adds a child configuration and makes it the < em > container
 * configuration < / em > . This means that all future property write operations
 * are executed on this configuration . Note that the current container
 * configuration stays in the list of child configurations
 * at its current position , but it passes its role as container
 * configuration to the new one .
 * @ param config the configuration to be added
 * @ param name the name of the configuration to be added
 * @ param index index to add this configuration
 * @ throws IndexOutOfBoundsException */
public void setContainerConfiguration ( AbstractConfiguration config , String name , int index ) throws IndexOutOfBoundsException { } }

implementation: if ( ! configList . contains ( config ) ) { checkIndex ( index ) ; containerConfigurationChanged = true ; containerConfiguration = config ; addConfigurationAtIndex ( config , name , index ) ; } else { logger . warn ( config + " is not added as it already exits" ) ; }


signature:
public class ConcurrentCompositeConfiguration { /** * Change the position of the < em > container configuration < / em > to a new index .
 * @ throws IndexOutOfBoundsException */
public void setContainerConfigurationIndex ( int newIndex ) throws IndexOutOfBoundsException { } }

implementation:
if ( newIndex < 0 || newIndex >= configList . size ( ) ) { throw new IndexOutOfBoundsException ( "Cannot change to the new index " + newIndex + " in the list of size " + configList . size ( ) ) ; } else if ( newIndex == configList . indexOf ( containerConfiguration ) ) { // nothing to do
return ; } containerConfigurationChanged = true ; configList . remove ( containerConfiguration ) ; configList . add ( newIndex , containerConfiguration ) ;


signature:
public class ConcurrentCompositeConfiguration { /** * Add a configuration with a name at a particular index .
 * @ throws IndexOutOfBoundsException */
public void addConfigurationAtIndex ( AbstractConfiguration config , String name , int index ) throws IndexOutOfBoundsException { } }

implementation: if ( ! configList . contains ( config ) ) { checkIndex ( index ) ; configList . add ( index , config ) ; if ( name != null ) { namedConfigurations . put ( name , config ) ; } config . addConfigurationListener ( eventPropagater ) ; fireEvent ( EVENT_CONFIGURATION_SOURCE_CHANGED , null , null , false ) ; } else { logger . warn ( config + " is not added as it already exits" ) ; }


signature:
public class ConcurrentCompositeConfiguration { /** * Remove a configuration . The container configuration cannot be removed .
 * @ param config The configuration to remove */
public boolean removeConfiguration ( Configuration config ) { } }

implementation:
// Make sure that you can ' t remove the inMemoryConfiguration from
// the CompositeConfiguration object
if ( ! config . equals ( containerConfiguration ) ) { String configName = getNameForConfiguration ( config ) ; if ( configName != null ) { namedConfigurations . remove ( configName ) ; } return configList . remove ( config ) ; } else { throw new IllegalArgumentException ( "Can't remove container configuration" ) ; }


signature:
public class ConcurrentCompositeConfiguration { /** * Removes the configuration with the specified name .
 * @ param name the name of the configuration to be removed
 * @ return the removed configuration ( < b > null < / b > if this configuration
 * was not found ) */
public Configuration removeConfiguration ( String name ) { } }

implementation: Configuration conf = getConfiguration ( name ) ; if ( conf != null && ! conf . equals ( containerConfiguration ) ) { configList . remove ( conf ) ; namedConfigurations . remove ( name ) ; } else if ( conf != null && conf . equals ( containerConfiguration ) ) { throw new IllegalArgumentException ( "Can't remove container configuration" ) ; } return conf ;


signature:
public class ConcurrentCompositeConfiguration { /** * Removes all child configurations and reinitializes the < em > container
 * configuration < / em > . < strong > Attention : < / strong > A new container
 * configuration is created ; the old one is lost . */
@ Override public final void clear ( ) { } }

implementation:
fireEvent ( EVENT_CLEAR , null , null , true ) ; configList . clear ( ) ; namedConfigurations . clear ( ) ; // recreate the in memory configuration
containerConfiguration = new ConcurrentMapConfiguration ( ) ; containerConfiguration . setThrowExceptionOnMissing ( isThrowExceptionOnMissing ( ) ) ; containerConfiguration . setListDelimiter ( getListDelimiter ( ) ) ; containerConfiguration . setDelimiterParsingDisabled ( isDelimiterParsingDisabled ( ) ) ; containerConfiguration . addConfigurationListener ( eventPropagater ) ; configList . add ( containerConfiguration ) ; overrideProperties = new ConcurrentMapConfiguration ( ) ; overrideProperties . setThrowExceptionOnMissing ( isThrowExceptionOnMissing ( ) ) ; overrideProperties . setListDelimiter ( getListDelimiter ( ) ) ; overrideProperties . setDelimiterParsingDisabled ( isDelimiterParsingDisabled ( ) ) ; overrideProperties . addConfigurationListener ( eventPropagater ) ; fireEvent ( EVENT_CLEAR , null , null , false ) ; containerConfigurationChanged = false ; invalidate ( ) ;


signature:
public class ConcurrentCompositeConfiguration { /** * Set the property with the < em > container configuration < / em > .
 * < b > Warning : < / b > { @ link # getProperty ( String ) } on this key may not return the same value set by this method
 * if there is any other configuration that contain the same property and is in front of the
 * < em > container configuration < / em > in the configurations list . */
@ Override public void setProperty ( String key , Object value ) { } }

implementation: containerConfiguration . setProperty ( key , value ) ;


signature:
public class ConcurrentCompositeConfiguration { /** * Add the property with the < em > container configuration < / em > .
 * < b > Warning : < / b > { @ link # getProperty ( String ) } on this key may not return the same value set by this method
 * if there is any other configuration that contain the same property and is in front of the
 * < em > container configuration < / em > in the configurations list . */
@ Override public void addProperty ( String key , Object value ) { } }

implementation: containerConfiguration . addProperty ( key , value ) ;


signature:
public class ConcurrentCompositeConfiguration { /** * Read property from underlying composite . It first checks if the property has been overridden
 * by { @ link # setOverrideProperty ( String , Object ) } and if so return the overriding value .
 * Otherwise , it iterates through the list of sub configurations until it finds one that contains the
 * property and return the value from that sub configuration . It returns null of the property does
 * not exist .
 * @ param key key to use for mapping
 * @ return object associated with the given configuration key . null if it does not exist . */
public Object getProperty ( String key ) { } }

implementation: if ( overrideProperties . containsKey ( key ) ) { return overrideProperties . getProperty ( key ) ; } Configuration firstMatchingConfiguration = null ; for ( Configuration config : configList ) { if ( config . containsKey ( key ) ) { firstMatchingConfiguration = config ; break ; } } if ( firstMatchingConfiguration != null ) { return firstMatchingConfiguration . getProperty ( key ) ; } else { return null ; }


signature:
public class ConcurrentCompositeConfiguration { /** * Get all the keys contained by sub configurations .
 * @ throws ConcurrentModificationException if concurrent modification happens on any sub configuration
 * when it is iterated to get all the keys */
public Iterator < String > getKeys ( ) throws ConcurrentModificationException { } }

implementation: Set < String > keys = new LinkedHashSet < String > ( ) ; for ( Iterator < String > it = overrideProperties . getKeys ( ) ; it . hasNext ( ) ; ) { keys . add ( it . next ( ) ) ; } for ( Configuration config : configList ) { for ( Iterator < String > it = config . getKeys ( ) ; it . hasNext ( ) ; ) { try { keys . add ( it . next ( ) ) ; } catch ( ConcurrentModificationException e ) { logger . error ( "unexpected exception when iterating the keys for configuration " + config + " with name " + getNameForConfiguration ( config ) ) ; throw e ; } } } return keys . iterator ( ) ;


signature:
public class ConcurrentCompositeConfiguration { /** * Get the list of the keys contained in the sub configurations that match the
 * specified prefix . */
@ Override public Iterator < String > getKeys ( String prefix ) { } }

implementation: Set < String > keys = new LinkedHashSet < String > ( ) ; for ( Iterator < String > it = overrideProperties . getKeys ( prefix ) ; it . hasNext ( ) ; ) { keys . add ( it . next ( ) ) ; } for ( Configuration config : configList ) { for ( Iterator < String > it = config . getKeys ( prefix ) ; it . hasNext ( ) ; ) { keys . add ( it . next ( ) ) ; } } return keys . iterator ( ) ;


signature:
public class ConcurrentCompositeConfiguration { /** * Check if the any of the sub configurations contains the specified key .
 * @ param key the key whose presence in this configuration is to be tested
 * @ return < code > true < / code > if the configuration contains a value for this
 * key , < code > false < / code > otherwise */
@ Override public boolean containsKey ( String key ) { } }

implementation: if ( overrideProperties . containsKey ( key ) ) { return true ; } for ( Configuration config : configList ) { if ( config . containsKey ( key ) ) { return true ; } } return false ;


signature:
public class ConcurrentCompositeConfiguration { /** * Get a List of objects associated with the given configuration key .
 * If the key doesn ' t map to an existing object , the default value
 * is returned .
 * @ param key The configuration key .
 * @ param defaultValue The default value .
 * @ return The associated List of value . */
@ Override public List getList ( String key , List defaultValue ) { } }

implementation:
List < Object > list = new ArrayList < Object > ( ) ; // add all elements from the first configuration containing the requested key
Iterator < AbstractConfiguration > it = configList . iterator ( ) ; if ( overrideProperties . containsKey ( key ) ) { appendListProperty ( list , overrideProperties , key ) ; } while ( it . hasNext ( ) && list . isEmpty ( ) ) { Configuration config = it . next ( ) ; if ( ( config != containerConfiguration || containerConfigurationChanged ) && config . containsKey ( key ) ) { appendListProperty ( list , config , key ) ; } } // add all elements from the in memory configuration
if ( list . isEmpty ( ) ) { appendListProperty ( list , containerConfiguration , key ) ; } if ( list . isEmpty ( ) ) { return defaultValue ; } ListIterator < Object > lit = list . listIterator ( ) ; while ( lit . hasNext ( ) ) { lit . set ( interpolate ( lit . next ( ) ) ) ; } return list ;


signature:
public class ConcurrentCompositeConfiguration { /** * Get an array of strings associated with the given configuration key .
 * If the key doesn ' t map to an existing object an empty array is returned
 * @ param key The configuration key .
 * @ return The associated string array if key is found . */
@ Override public String [ ] getStringArray ( String key ) { } }

implementation:
List < Object > list = getList ( key ) ; // transform property values into strings
String [ ] tokens = new String [ list . size ( ) ] ; for ( int i = 0 ; i < tokens . length ; i ++ ) { tokens [ i ] = String . valueOf ( list . get ( i ) ) ; } return tokens ;


signature:
public class ConcurrentCompositeConfiguration { /** * Returns the configuration source , in which the specified key is defined .
 * This method will iterate over all existing child configurations and check
 * whether they contain the specified key . The following constellations are
 * possible :
 * < ul >
 * < li > If the child configurations contains this key , the first one is returned . < / li >
 * < li > If none of the child configurations contain the key , < b > null < / b > is
 * returned . < / li >
 * < / ul >
 * @ param key the key to be checked
 * @ return the source configuration of this key */
public Configuration getSource ( String key ) { } }

implementation: if ( key == null ) { throw new IllegalArgumentException ( "Key must not be null!" ) ; } if ( overrideProperties . containsKey ( key ) ) { return overrideProperties ; } for ( Configuration conf : configList ) { if ( conf . containsKey ( key ) ) { return conf ; } } return null ;


signature:
public class ConcurrentCompositeConfiguration { /** * Adds the value of a property to the given list . This method is used by
 * { @ code getList ( ) } for gathering property values from the child
 * configurations .
 * @ param dest the list for collecting the data
 * @ param config the configuration to query
 * @ param key the key of the property */
private static void appendListProperty ( List < Object > dest , Configuration config , String key ) { } }

implementation: Object value = config . getProperty ( key ) ; if ( value != null ) { if ( value instanceof Collection ) { Collection < ? > col = ( Collection < ? > ) value ; dest . addAll ( col ) ; } else { dest . add ( value ) ; } }


signature:
public class ConfigurationManager { /** * Install the system wide configuration with the ConfigurationManager . This will also install
 * the configuration with the { @ link DynamicPropertyFactory } by calling { @ link DynamicPropertyFactory # initWithConfigurationSource ( AbstractConfiguration ) } .
 * This call can be made only once , otherwise IllegalStateException will be thrown . */
public static synchronized void install ( AbstractConfiguration config ) throws IllegalStateException { } }

implementation: if ( ! customConfigurationInstalled ) { setDirect ( config ) ; if ( DynamicPropertyFactory . getBackingConfigurationSource ( ) != config ) { DynamicPropertyFactory . initWithConfigurationSource ( config ) ; } } else { throw new IllegalStateException ( "A non-default configuration is already installed" ) ; }


signature:
public class ConfigurationManager { /** * Get the current system wide configuration . If there has not been set , it will return a default
 * { @ link ConcurrentCompositeConfiguration } which contains a SystemConfiguration from Apache Commons
 * Configuration and a { @ link DynamicURLConfiguration } . */
public static AbstractConfiguration getConfigInstance ( ) { } }

implementation: if ( instance == null ) { synchronized ( ConfigurationManager . class ) { if ( instance == null ) { instance = getConfigInstance ( Boolean . getBoolean ( DynamicPropertyFactory . DISABLE_DEFAULT_CONFIG ) ) ; } } } return instance ;


signature:
public class ConfigurationManager { /** * Load properties from resource file ( s ) into the system wide configuration
 * @ param path relative path of the resources
 * @ throws IOException */
public static void loadPropertiesFromResources ( String path ) throws IOException { } }

implementation:
if ( instance == null ) { instance = getConfigInstance ( ) ; } ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; Enumeration < URL > resources = loader . getResources ( path ) ; if ( ! resources . hasMoreElements ( ) ) { // non - existent config path . Throw an exception . Issue # 150
throw new IOException ( "Cannot locate " + path + " as a classpath resource." ) ; } while ( resources . hasMoreElements ( ) ) { URL url = resources . nextElement ( ) ; InputStream fin = url . openStream ( ) ; Properties props = ConfigurationUtils . loadPropertiesFromInputStream ( fin ) ; if ( instance instanceof AggregatedConfiguration ) { String name = getConfigName ( url ) ; ConcurrentMapConfiguration config = new ConcurrentMapConfiguration ( ) ; config . loadProperties ( props ) ; ( ( AggregatedConfiguration ) instance ) . addConfiguration ( config , name ) ; } else { ConfigurationUtils . loadProperties ( props , instance ) ; } }


signature:
public class ConfigurationManager { /** * Load resource configName . properties first . Then load configName - deploymentEnvironment . properties
 * into the system wide configuration . For example , if configName is " application " , and deployment environment
 * is " test " , this API will first load " application . properties " , then load " application - test . properties " to
 * override any property that also exist in " application . properties " .
 * @ param configName prefix of the properties file name .
 * @ throws IOException
 * @ see DeploymentContext # getDeploymentEnvironment ( ) */
public static void loadCascadedPropertiesFromResources ( String configName ) throws IOException { } }

implementation: Properties props = loadCascadedProperties ( configName ) ; if ( instance instanceof AggregatedConfiguration ) { ConcurrentMapConfiguration config = new ConcurrentMapConfiguration ( ) ; config . loadProperties ( props ) ; ( ( AggregatedConfiguration ) instance ) . addConfiguration ( config , configName ) ; } else { ConfigurationUtils . loadProperties ( props , instance ) ; }


signature:
public class ConfigurationManager { /** * Load properties from the specified configuration into system wide configuration */
public static void loadPropertiesFromConfiguration ( AbstractConfiguration config ) { } }

implementation: if ( instance == null ) { instance = getConfigInstance ( ) ; } if ( instance instanceof AggregatedConfiguration ) { ( ( AggregatedConfiguration ) instance ) . addConfiguration ( config ) ; } else { Properties props = ConfigurationUtils . getProperties ( config ) ; ConfigurationUtils . loadProperties ( props , instance ) ; }


signature:
public class ConfigurationManager { /** * Load the specified properties into system wide configuration */
public static void loadProperties ( Properties properties ) { } }

implementation: if ( instance == null ) { instance = getConfigInstance ( ) ; } ConfigurationUtils . loadProperties ( properties , instance ) ;


signature:
public class FixedDelayPollingScheduler { /** * This method is implemented with
 * { @ link java . util . concurrent . ScheduledExecutorService # scheduleWithFixedDelay ( Runnable , long , long , TimeUnit ) } */
@ Override protected synchronized void schedule ( Runnable runnable ) { } }

implementation: executor = Executors . newScheduledThreadPool ( 1 , new ThreadFactory ( ) { @ Override public Thread newThread ( Runnable r ) { Thread t = new Thread ( r , "pollingConfigurationSource" ) ; t . setDaemon ( true ) ; return t ; } } ) ; executor . scheduleWithFixedDelay ( runnable , initialDelayMillis , delayMillis , TimeUnit . MILLISECONDS ) ;


signature:
public class SampleApplication { /** * SampleApplication entrypoint
 * @ param args */
public static void main ( String [ ] args ) { } }

implementation:
// @ SuppressWarnings ( value = { " unused " } )
new SampleApplication ( ) ; // Step 1.
// Create a Source of Configuration
// Here we use a simple ConcurrentMapConfiguration
// You can use your own , or use of the pre built ones including JDBCConfigurationSource
// which lets you load properties from any RDBMS
AbstractConfiguration myConfiguration = new ConcurrentMapConfiguration ( ) ; myConfiguration . setProperty ( "com.netflix.config.samples.sampleapp.prop1" , "value1" ) ; myConfiguration . setProperty ( "com.netflix.config.samples.SampleApp.SampleBean.name" , "A Coffee Bean from Gautemala" ) ; // STEP 2 : Optional . Dynamic Runtime property change option
// We would like to utilize the benefits of obtaining dynamic property
// changes
// initialize the DynamicPropertyFactory with our configuration source
DynamicPropertyFactory . initWithConfigurationSource ( myConfiguration ) ; // STEP 3 : Optional . Option to inspect and modify properties using JConsole
// We would like to inspect properties via JMX JConsole and potentially
// update
// these properties too
// Register the MBean
// This can be also achieved automatically by setting " true " to
// system property " archaius . dynamicPropertyFactory . registerConfigWithJMX "
configMBean = ConfigJMXManager . registerConfigMbean ( myConfiguration ) ; // once this application is launched , launch JConsole and navigate to
// the
// Config MBean ( under the MBeans tab )
System . out . println ( "Started SampleApplication. Launch JConsole to inspect and update properties" ) ; System . out . println ( "To see how callback work, update property com.netflix.config.samples.SampleApp.SampleBean.sensitiveBeanData from BaseConfigBean in JConsole" ) ; SampleBean sampleBean = new SampleBean ( ) ; System . out . println ( "SampleBean:" + sampleBean ) ; System . out . println ( sampleBean . getName ( ) ) ;


signature:
public class URLConfigurationSource { /** * Retrieve the content of the property files . For each poll , it always
 * returns the complete union of properties defined in all URLs . If one
 * property is defined in content of more than one URL , the value in file later on the
 * list will override the value in the previous one .
 * @ param initial this parameter is ignored by the implementation
 * @ param checkPoint this parameter is ignored by the implementation
 * @ throws IOException IOException occurred in file operation */
@ Override public PollResult poll ( boolean initial , Object checkPoint ) throws IOException { } }

implementation: if ( configUrls == null || configUrls . length == 0 ) { return PollResult . createFull ( null ) ; } Map < String , Object > map = new HashMap < String , Object > ( ) ; for ( URL url : configUrls ) { InputStream fin = url . openStream ( ) ; Properties props = ConfigurationUtils . loadPropertiesFromInputStream ( fin ) ; for ( Entry < Object , Object > entry : props . entrySet ( ) ) { map . put ( ( String ) entry . getKey ( ) , entry . getValue ( ) ) ; } } return PollResult . createFull ( map ) ;


signature: public class ScoreCalculationSpeedSubSingleStatistic { @ Override public void open ( Solver < Solution_ > solver ) { } }

implementation: ( ( DefaultSolver < Solution_ > ) solver ) . addPhaseLifecycleListener ( listener ) ;


signature: public class PooledEntityPlacerConfig { @ Override public PooledEntityPlacer buildEntityPlacer ( HeuristicConfigPolicy configPolicy ) { } }

implementation:
MoveSelectorConfig moveSelectorConfig ; if ( ConfigUtils . isEmptyCollection ( moveSelectorConfigList ) ) { moveSelectorConfig = buildMoveSelectorConfig ( configPolicy ) ; } else if ( moveSelectorConfigList . size ( ) == 1 ) { moveSelectorConfig = moveSelectorConfigList . get ( 0 ) ; } else { // TODO moveSelectorConfigList is only a List because of XStream limitations .
throw new IllegalArgumentException ( "The moveSelectorConfigList (" + moveSelectorConfigList + ") must be a singleton or empty. Use a single " + UnionMoveSelectorConfig . class . getSimpleName ( ) + " or " + CartesianProductMoveSelectorConfig . class . getSimpleName ( ) + " element to nest multiple MoveSelectors." ) ; } MoveSelector moveSelector = moveSelectorConfig . buildMoveSelector ( configPolicy , SelectionCacheType . JUST_IN_TIME , SelectionOrder . ORIGINAL ) ; return new PooledEntityPlacer ( moveSelector ) ;


signature:
public class Location { /** * The angle relative to the direction EAST .
 * @ param location never null
 * @ return in Cartesian coordinates */
public double getAngle ( Location location ) { } }

implementation:
// Euclidean distance ( Pythagorean theorem ) - not correct when the surface is a sphere
double latitudeDifference = location . latitude - latitude ; double longitudeDifference = location . longitude - longitude ; return Math . atan2 ( latitudeDifference , longitudeDifference ) ;


signature: public class BestSolutionRecaller { @ Override public void solvingStarted ( DefaultSolverScope < Solution_ > solverScope ) { } }

implementation:
// Starting bestSolution is already set by Solver . solve ( Solution )
InnerScoreDirector < Solution_ > scoreDirector = solverScope . getScoreDirector ( ) ; Score score = scoreDirector . calculateScore ( ) ; solverScope . setBestScore ( score ) ; solverScope . setBestSolutionTimeMillis ( System . currentTimeMillis ( ) ) ; // The original bestSolution might be the final bestSolution and should have an accurate Score
solverScope . getSolutionDescriptor ( ) . setScore ( solverScope . getBestSolution ( ) , score ) ; if ( score . isSolutionInitialized ( ) ) { solverScope . setStartingInitializedScore ( score ) ; } else { solverScope . setStartingInitializedScore ( null ) ; } if ( assertInitialScoreFromScratch ) { scoreDirector . assertWorkingScoreFromScratch ( score , "Initial score calculated" ) ; } if ( assertShadowVariablesAreNotStale ) { scoreDirector . assertShadowVariablesAreNotStale ( score , "Initial score calculated" ) ; }


signature:
public class LookUpManager { /** * As defined by { @ link ScoreDirector # lookUpWorkingObject ( Object ) } .
 * @ param externalObject sometimes null
 * @ return null if externalObject is null
 * @ throws IllegalArgumentException if there is no workingObject for externalObject , if it cannot be looked up
 * or if the externalObject ' s class is not supported
 * @ throws IllegalStateException if it cannot be looked up
 * @ param < E > the object type */
public < E > E lookUpWorkingObject ( E externalObject ) { } }

implementation: if ( externalObject == null ) { return null ; } LookUpStrategy lookUpStrategy = lookUpStrategyResolver . determineLookUpStrategy ( externalObject ) ; return lookUpStrategy . lookUpWorkingObject ( idToWorkingObjectMap , externalObject ) ;


signature:
public class LookUpManager { /** * As defined by { @ link ScoreDirector # lookUpWorkingObjectOrReturnNull ( Object ) } .
 * @ param externalObject sometimes null
 * @ return null if externalObject is null or if there is no workingObject for externalObject
 * @ throws IllegalArgumentException if it cannot be looked up or if the externalObject ' s class is not supported
 * @ throws IllegalStateException if it cannot be looked up
 * @ param < E > the object type */
public < E > E lookUpWorkingObjectOrReturnNull ( E externalObject ) { } }

implementation: if ( externalObject == null ) { return null ; } LookUpStrategy lookUpStrategy = lookUpStrategyResolver . determineLookUpStrategy ( externalObject ) ; return lookUpStrategy . lookUpWorkingObjectIfExists ( idToWorkingObjectMap , externalObject ) ;


signature: public class DefaultConstructionHeuristicForager { @ Override public void stepStarted ( ConstructionHeuristicStepScope stepScope ) { } }

implementation: super . stepStarted ( stepScope ) ; selectedMoveCount = 0L ; earlyPickedMoveScope = null ; maxScoreMoveScope = null ;


signature: public class HeuristicConfigPolicy { public void addEntityMimicRecorder ( String id , EntityMimicRecorder mimicRecordingEntitySelector ) { } }

implementation: EntityMimicRecorder put = entityMimicRecorderMap . put ( id , mimicRecordingEntitySelector ) ; if ( put != null ) { throw new IllegalStateException ( "Multiple " + EntityMimicRecorder . class . getSimpleName ( ) + "s (usually " + EntitySelector . class . getSimpleName ( ) + "s) have the same id (" + id + ")." ) ; }


signature: public class AbstractConfig { protected EntityDescriptor deduceEntityDescriptor ( SolutionDescriptor solutionDescriptor , Class < ? > entityClass ) { } }

implementation: EntityDescriptor entityDescriptor ; if ( entityClass != null ) { entityDescriptor = solutionDescriptor . getEntityDescriptorStrict ( entityClass ) ; if ( entityDescriptor == null ) { throw new IllegalArgumentException ( "The config (" + this + ") has an entityClass (" + entityClass + ") that is not a known planning entity.\n" + "Check your solver configuration. If that class (" + entityClass . getSimpleName ( ) + ") is not in the entityClassSet (" + solutionDescriptor . getEntityClassSet ( ) + "), check your " + PlanningSolution . class . getSimpleName ( ) + " implementation's annotated methods too." ) ; } } else { Collection < EntityDescriptor > entityDescriptors = solutionDescriptor . getGenuineEntityDescriptors ( ) ; if ( entityDescriptors . size ( ) != 1 ) { throw new IllegalArgumentException ( "The config (" + this + ") has no entityClass (" + entityClass + ") configured and because there are multiple in the entityClassSet (" + solutionDescriptor . getEntityClassSet ( ) + "), it can not be deduced automatically." ) ; } entityDescriptor = entityDescriptors . iterator ( ) . next ( ) ; } return entityDescriptor ;


signature: public class CompositeAcceptor { @ Override public void solvingStarted ( DefaultSolverScope solverScope ) { } }

implementation: for ( Acceptor acceptor : acceptorList ) { acceptor . solvingStarted ( solverScope ) ; }


signature: public class AbstractCachingMoveSelector { @ Override public void constructCache ( DefaultSolverScope solverScope ) { } }

implementation: long childSize = childMoveSelector . getSize ( ) ; if ( childSize > ( long ) Integer . MAX_VALUE ) { throw new IllegalStateException ( "The selector (" + this + ") has a childMoveSelector (" + childMoveSelector + ") with childSize (" + childSize + ") which is higher than Integer.MAX_VALUE." ) ; } cachedMoveList = new ArrayList < > ( ( int ) childSize ) ; childMoveSelector . iterator ( ) . forEachRemaining ( cachedMoveList :: add ) ; logger . trace ( "    Created cachedMoveList: size ({}), moveSelector ({})." , cachedMoveList . size ( ) , this ) ;


signature: public class PillarChangeMove { @ Override public boolean isMoveDoable ( ScoreDirector < Solution_ > scoreDirector ) { } }

implementation: Object oldValue = variableDescriptor . getValue ( pillar . get ( 0 ) ) ; if ( Objects . equals ( oldValue , toPlanningValue ) ) { return false ; } if ( ! variableDescriptor . isValueRangeEntityIndependent ( ) ) { ValueRangeDescriptor < Solution_ > valueRangeDescriptor = variableDescriptor . getValueRangeDescriptor ( ) ; Solution_ workingSolution = scoreDirector . getWorkingSolution ( ) ; for ( Object entity : pillar ) { ValueRange rightValueRange = valueRangeDescriptor . extractValueRange ( workingSolution , entity ) ; if ( ! rightValueRange . contains ( toPlanningValue ) ) { return false ; } } } return true ;


signature: public class MoveListFactoryToMoveSelectorBridge { @ Override public void constructCache ( DefaultSolverScope solverScope ) { } }

implementation: cachedMoveList = moveListFactory . createMoveList ( solverScope . getScoreDirector ( ) . getWorkingSolution ( ) ) ; logger . trace ( "    Created cachedMoveList: size ({}), moveSelector ({})." , cachedMoveList . size ( ) , this ) ;


signature: public class LocalSearchPhaseConfig { @ Override public LocalSearchPhase buildPhase ( int phaseIndex , HeuristicConfigPolicy solverConfigPolicy , BestSolutionRecaller bestSolutionRecaller , Termination solverTermination ) { } }

implementation: HeuristicConfigPolicy phaseConfigPolicy = solverConfigPolicy . createPhaseConfigPolicy ( ) ; DefaultLocalSearchPhase phase = new DefaultLocalSearchPhase ( phaseIndex , solverConfigPolicy . getLogIndentation ( ) , bestSolutionRecaller , buildPhaseTermination ( phaseConfigPolicy , solverTermination ) ) ; phase . setDecider ( buildDecider ( phaseConfigPolicy , phase . getTermination ( ) ) ) ; EnvironmentMode environmentMode = phaseConfigPolicy . getEnvironmentMode ( ) ; if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { phase . setAssertStepScoreFromScratch ( true ) ; } if ( environmentMode . isIntrusiveFastAsserted ( ) ) { phase . setAssertExpectedStepScore ( true ) ; phase . setAssertShadowVariablesAreNotStaleAfterStep ( true ) ; } return phase ;