Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.paypal.base;
  
  import java.util.HashMap;
  import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 
ConfigManager loads configuration from 'sdk_config.properties' file found in the classpath. There are certain default parameters that the system chooses to use if not seen a part of the configuration. They are enumerated below with the defaults is parenthesis http.ConnectionTimeOut(5000 ms), http.Retry(2), http.ReadTimeOut(30000 ms), http.MaxConnections(100), http.IPAddress(127.0.0.1), http.GoogleAppEngine(false)
 
 public final class ConfigManager {
 
 	private static final Logger log = LoggerFactory.getLogger(ConfigManager.class);

Singleton instance variable
 
 	private static ConfigManager conf;

Underlying property implementation
 
 	private Properties properties;

Initialized notifier
 
 	private boolean propertyLoaded = false;

Map View of internal java.util.Properties
 
 	private Map<StringStringmapView = null;

Map View of internal Default java.util.Properties
 
 	private static Map<StringStringdefaultMapView = null;

 
 	private static final Properties DEFAULT_PROPERTIES;
 
 	// Initialize DEFAULT_PROPERTIES
 	static {
 		.put(."DigiCertSHA2ExtendedValidationServerCA.crt");
 		for (Object object : .keySet()) {
 					.getProperty(object.toString()).trim());
 		}
 	}

Private constructor
 
 	private ConfigManager() {
 
 		/*
 		 * Load configuration for default 'sdk_config.properties'
 		 */
 		ResourceLoader resourceLoader = new ResourceLoader(
 		 = new Properties();
 		try {
 			InputStream inputStream = resourceLoader.getInputStream();
 			.load(inputStream);
 		} catch (IOException e) {
 			// We tried reading the config, but it seems like you dont have it. Skipping...
			.debug(. + " not present. Skipping...");
catch (AccessControlException e) {
			.debug("Unable to read " + . + ". Skipping...");
finally {
		}
	}

Singleton accessor method

Returns:
ConfigManager object
	public static ConfigManager getInstance() {
		synchronized (ConfigManager.class) {
			if ( == null) {
				 = new ConfigManager();
			}
		}
		return ;
	}

Returns the Default java.util.Properties of System Configuration

Returns:
Default java.util.Properties
	public static Properties getDefaultProperties() {
	}

Returns a java.util.Map view of Default java.util.Properties

Returns:
java.util.Map view of Default java.util.Properties
	public static Map<StringStringgetDefaultSDKMap() {
	}

Combines some java.util.Properties with Default java.util.Properties

Parameters:
receivedProperties Properties used to combine with Default java.util.Properties
Returns:
Combined java.util.Properties
			Properties receivedProperties) {
		Properties combinedProperties = new Properties(getDefaultProperties());
		if ((receivedProperties != null) && (receivedProperties.size() > 0)) {
			try {
				receivedProperties.store(bosnull);
				combinedProperties.load(new ByteArrayInputStream(bos
catch (IOException e) {
				// Something failed trying to load the properties. Skipping...
			}
		}
		return combinedProperties;
	}

Loads the internal properties with the passed java.io.InputStream

Deprecated:
use initConfig() instead
Parameters:
is InputStream
Throws:
java.io.IOException
	public void load(InputStream isthrows IOException {
		}
	}

Initializes the internal properties with the passed java.util.Properties instance

Deprecated:
use initConfig() instead
Parameters:
properties Properties instance
	public void load(Properties properties) {
		if (properties == null) {
					"Initialization properties cannot be null");
		}
		this. = properties;
		}
	}

Constructs a java.util.Map object from the underlying java.util.Properties. The java.util.Properties object is loaded for 'sdk_config.properties' file in the classpath

Returns:
java.util.Map
		if ( == null) {
			synchronized () {
				if ( != null) {
					for (Object object : .keySet()) {
								.getProperty(object.toString()).trim());
					}
				}
			}
		}
		return new HashMap<StringString>();
	}

Returns a value for the corresponding key

Deprecated:
Parameters:
key String key
Returns:
String value
	public String getValue(String key) {
		return .getProperty(key);
	}

Mimics the call to java.util.Properties.getProperty(key, defaultValue)

Deprecated:
Parameters:
key String key to search in properties file
defaultValue Default value to be sent in case of a miss
Returns:
String value corresponding to the key or default value
	public String getValueWithDefault(String keyString defaultValue) {
		return .getProperty(keydefaultValue);
	}

Gets all the values in the particular category in configuration (eg: acct)

Deprecated:
Parameters:
category
Returns:
Map
	public Map<StringStringgetValuesByCategory(String category) {
		HashMap<StringStringmap = new HashMap<StringString>();
		for (Object obj : .keySet()) {
			key = (Stringobj;
			if (key.contains(category)) {
				map.put(key.getProperty(key));
			}
		}
		return map;
	}

Returns the key prefixes for all configured accounts

Deprecated:
Returns:
java.util.Set of Accounts
	public Set<StringgetNumOfAcct() {
		Set<Stringset = new HashSet<String>();
		for (Object obj : .keySet()) {
			key = (Stringobj;
			if (key.contains("acct")) {
				int pos = key.indexOf('.');
				String acct = key.substring(0, pos);
				set.add(acct);
			}
		}
		return set;
	}

Deprecated:
Returns:
	public boolean isPropertyLoaded() {
	}
	private void setPropertyLoaded(boolean propertyLoaded) {
		this. = propertyLoaded;
	}
New to GrepCode? Check out our FAQ X