All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.paypal.core.ConnectionManager Maven / Gradle / Ivy

Go to download

PayPal Java SDK Core library base and common to PayPal SDKs. The paypal-core library is a dependency for all PayPal related Java SDKs

There is a newer version: 1.7.2
Show newest version
package com.paypal.core;

/**
 * ConnectionManager acts as a interface to retrieve {@link HttpConnection}
 * objects used by API service
 * 
 */
public final class ConnectionManager {

	/**
	 * Singleton instance
	 */
	private static ConnectionManager instance;

	// Private Constructor
	private ConnectionManager() {
	}

	/**
	 * Singleton accessor method
	 * 
	 * @return {@link ConnectionManager} singleton object
	 */
	public static ConnectionManager getInstance() {
		synchronized (ConnectionManager.class) {
			if (instance == null) {
				instance = new ConnectionManager();
			}
		}
		return instance;
	}

	/**
	 * @return HttpConnection object
	 */
	public HttpConnection getConnection() {
		return new DefaultHttpConnection();
	}

	/**
	 * Overloaded method used factory to load GoogleAppEngineSpecific connection
	 * 
	 * @param httpConfig
	 *            {@link HttpConfiguration} object
	 * @return {@link HttpConnection} object
	 */
	public HttpConnection getConnection(HttpConfiguration httpConfig) {

		if (httpConfig.isGoogleAppEngine()) {
			return new GoogleAppEngineHttpConnection();
		} else {
			return new DefaultHttpConnection();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy