private List<StringKeyValueBean> loadConfiguration(){
		List<StringKeyValueBean> result = new LinkedList<StringKeyValueBean>();
		Resource resource = null;
		if (primaryConfigFileLocation == null){
			return result;		// fail silently because we must be in test
		}else{
			resource = new ClassPathResource(primaryConfigFileLocation);
			if (!resource.exists()){
				if (secondaryConfigFileLocation == null){
					return result;		// fail silently because we must be in test
				}
				resource = new ClassPathResource(secondaryConfigFileLocation);
			}
		}

		Properties properties = null;
		try {
			properties = PropertiesLoaderUtils.loadProperties(resource);
			
			// sort them, make the more specific ones at the top, and "*"/".*" at the bottom
			List<StringKeyValueBean> sorted = new ArrayList<StringKeyValueBean>(properties.size());
			for (Entry<Object, Object> entry: properties.entrySet()){
				sorted.add(new StringKeyValueBean(entry.getKey().toString(), entry.getValue().toString()));
			}
			Collections.sort(sorted, new Comparator<StringKeyValueBean>(){
				@Override
				public int compare(StringKeyValueBean b0,	StringKeyValueBean b1) {
					if (b0.getKey().equals(b1.getKey())){
						return 0;
					}
					if ("*".equals(b0.getKey()) || ".*".equals(b0.getKey())){
						return 1;
					}else if ("*".equals(b1.getKey()) || ".*".equals(b1.getKey())){
						return -1;
					}
					return b1.getKey().compareTo(b0.getKey());
				}
			});
			result.addAll(sorted);
		} catch (Exception e) {
			logger.warn("Cannot load environments configuration file from class path: " + 
					(resource == null ? "<null>" : resource.getDescription()), e);
		}
		
		return result;
	}
private List < StringKeyValueBean > loadConfiguration ( ) { List < StringKeyValueBean > result = new LinkedList < StringKeyValueBean > ( ) ; Resource resource = null ; if ( primaryConfigFileLocation == null ) { return result ; } else { resource = new ClassPathResource ( primaryConfigFileLocation ) ; if ( ! resource . exists ( ) ) { if ( secondaryConfigFileLocation == null ) { return result ; } resource = new ClassPathResource ( secondaryConfigFileLocation ) ; } } Properties properties = null ; try { properties = PropertiesLoaderUtils . loadProperties ( resource ) ; List < StringKeyValueBean > sorted = new ArrayList < StringKeyValueBean > ( properties . size ( ) ) ; for ( Entry < Object , Object > entry : properties . entrySet ( ) ) { sorted . add ( new StringKeyValueBean ( entry . getKey ( ) . toString ( ) , entry . getValue ( ) . toString ( ) ) ) ; } Collections . sort ( sorted , new Comparator < StringKeyValueBean > ( ) { @ Override public int compare ( StringKeyValueBean b0 , StringKeyValueBean b1 ) { if ( b0 . getKey ( ) . equals ( b1 . getKey ( ) ) ) { return 0 ; } if ( "*" . equals ( b0 . getKey ( ) ) || ".*" . equals ( b0 . getKey ( ) ) ) { return 1 ; } else if ( "*" . equals ( b1 . getKey ( ) ) || ".*" . equals ( b1 . getKey ( ) ) ) { return - 1 ; } return b1 . getKey ( ) . compareTo ( b0 . getKey ( ) ) ; } } ) ; result . addAll ( sorted ) ; } catch ( Exception e ) { logger . warn ( "Cannot load environments configuration file from class path: " + ( resource == null ? "<null>" : resource . getDescription ( ) ) , e ) ; } return result ; }
Load hostname - profiles mapping configuration
@return the configuration with all-matching wild card at the bottom.