com.paypal.core.ConnectionManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of paypal-core Show documentation
Show all versions of paypal-core Show documentation
PayPal Java SDK Core library base and common to PayPal SDKs. The paypal-core library is a dependency for all PayPal related Java SDKs
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();
}
}
}