public class MwsConnection extends Object implements Cloneable, Closeable
Parameters that describe a MwsConnection are Server address and port, caller credentials and network connection configuration.
Simplest use case is:
1) Create an MwsConnection instance. 2) Configure the connection using setter methods. 3) Create and initialize a Request object. 4) Call response = connection.execute(requestObject) 5) Use the response object or handle exceptions. 6) Repeat steps 3-5 as necessary. 7) Close the connection object.
| Constructor and Description |
|---|
MwsConnection()
Create with defaults.
|
MwsConnection(URI endpoint,
String applicationName,
String applicationVersion,
String awsAccessKeyId,
String awsSecretKeyId)
Create a connection.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends MwsObject> |
call(MwsRequestType type,
MwsObject requestData)
Call an operation and return the response data.
|
<T extends MwsObject> |
callAsync(MwsRequestType type,
MwsObject requestData)
Call a request async, return a future on the response data.
|
MwsConnection |
clone()
Clone this connection, creates an unconnected connection with all the
same settings.
|
void |
close() |
String |
getApplicationName()
Get the client application name.
|
String |
getApplicationVersion()
Get the client application version.
|
String |
getAwsAccessKeyId()
Get the configured AWS access key id.
|
int |
getConnectionTimeout()
Get the connection timeout.
|
URI |
getEndpoint()
Gets end point property.
|
ExecutorService |
getExecutorService()
Get the executor service that will be used for async requests.
|
String |
getLibraryVersion()
Get the client library version.
|
int |
getMaxAsyncQueueSize()
Get the MaxAsyncQueueSize property.
|
int |
getMaxAsyncThreads()
Get MaxAsyncThreads property.
|
int |
getMaxConnections()
Gets MaxConnections property
|
int |
getMaxErrorRetry()
Gets MaxErrorRetry property
|
String |
getProxyHost()
Gets ProxyHost property
|
String |
getProxyPassword()
Gets ProxyPassword property
|
int |
getProxyPort()
Gets ProxyPort property.
|
String |
getProxyUsername()
Gets the proxy username property.
|
String |
getRequestHeader(String name)
Gets the currently set value of a request header
|
protected Map<String,String> |
getRequestHeaders()
Gets the currently set request headers
|
String |
getSignatureMethod()
Gets SignatureMethod property
|
String |
getSignatureVersion()
Gets SignatureVersion property
|
int |
getSocketTimeout()
Gets SocketTimeout property
|
String |
getUserAgent()
Gets UserAgent property
|
void |
includeRequestHeader(String name,
String value)
Sets the value of a request header to be included on every request
|
MwsCall |
newCall(String servicePath,
String operationName)
Create a new request.
|
void |
setApplicationName(String name)
Set the application name.
|
void |
setApplicationVersion(String version)
Set the application version.
|
void |
setAwsAccessKeyId(String awsAccessKeyId)
Set the access key id.
|
void |
setAwsSecretKeyId(String awsSecretKeyId)
Set the secret key.
|
void |
setConnectionTimeout(int timeout)
Set the connection timeout.
|
void |
setEndpoint(URI endpoint)
Sets service endpoint property.
|
void |
setExecutorService(ExecutorService executor)
Set the executor service to use for async requests.
|
void |
setLibraryVersion(String libraryVersion)
Set the client library version.
|
void |
setMaxAsyncQueueSize(int maxAsyncQueueSize)
Set MaxAsyncQueueSize property.
|
void |
setMaxAsyncThreads(int maxAsyncThreads)
Set MaxAsyncThreads property.
|
void |
setMaxConnections(int maxConnections)
Set MaxConnections property.
|
void |
setMaxErrorRetry(int maxErrorRetry)
Sets MaxErrorRetry property
|
void |
setProxyHost(String proxyHost)
Sets ProxyHost property
|
void |
setProxyPassword(String proxyPassword)
Sets ProxyPassword property
|
void |
setProxyPort(int proxyPort)
Sets ProxyPort property.
|
void |
setProxyUsername(String proxyUsername)
Sets ProxyUsername property.
|
void |
setSignatureMethod(String signatureMethod)
Sets SignatureMethod property
|
void |
setSignatureVersion(String signatureVersion)
Sets SignatureVersion property
|
void |
setSocketTimeout(int socketTimeout)
Sets SocketTimeout property
|
void |
setUserAgent(String applicationName,
String applicationVersion,
String programmingLanguage,
String... additionalNameValuePairs)
Sets UserAgent property
|
public MwsConnection()
public MwsConnection(URI endpoint, String applicationName, String applicationVersion, String awsAccessKeyId, String awsSecretKeyId)
endpoint - The endpoint URI.applicationName - The calling applications name.applicationVersion - The calling applications version.awsAccessKeyId - The developer access key id.awsSecretKeyId - The developers secret key id.public <T extends MwsObject> T call(MwsRequestType type, MwsObject requestData)
requestData - The request data.public <T extends MwsObject> Future<T> callAsync(MwsRequestType type, MwsObject requestData)
requestData - public MwsConnection clone()
public void close()
close in interface Closeableclose in interface AutoCloseablepublic String getApplicationName()
public String getApplicationVersion()
public String getAwsAccessKeyId()
public int getConnectionTimeout()
public URI getEndpoint()
public ExecutorService getExecutorService()
public String getLibraryVersion()
public int getMaxAsyncQueueSize()
public int getMaxAsyncThreads()
public int getMaxConnections()
public int getMaxErrorRetry()
public String getProxyHost()
public String getProxyPassword()
public int getProxyPort()
public String getProxyUsername()
public String getSignatureMethod()
public String getSignatureVersion()
public int getSocketTimeout()
public String getUserAgent()
protected Map<String,String> getRequestHeaders()
public String getRequestHeader(String name)
name - the name of the header to getpublic MwsCall newCall(String servicePath, String operationName)
After first call to this method connection parameters can no longer be updated.
servicePath - operationName - public void setApplicationName(String name)
name - public void setApplicationVersion(String version)
version - public void setAwsAccessKeyId(String awsAccessKeyId)
awsAccessKeyId - public void setAwsSecretKeyId(String awsSecretKeyId)
awsSecretKeyId - public void setConnectionTimeout(int timeout)
timeout - The connection timeout in milliseconds;public void setEndpoint(URI endpoint)
endpoint - The service end point URI.public void setExecutorService(ExecutorService executor)
executor - public void setLibraryVersion(String libraryVersion)
Used to create default user agent string.
libraryVersion - public void setMaxAsyncQueueSize(int maxAsyncQueueSize)
When the async queue is full further async calls will execute on the
calling thread.
see setMaxAsyncThreads(int)
maxAsyncQueueSize - public void setMaxAsyncThreads(int maxAsyncThreads)
This is the maximum number of threads to spawn for async operations.
When Max number of threads is reached, requests will be stored in the queue. When queue becomes full, request will be executed on the calling thread.
Only used to configure default shared executor service when it is first created. If caller supplies an executor service for a connection or the shared executor already exists then this parameter is ignored.
maxAsyncThreads - public void setMaxConnections(int maxConnections)
All MwsConnection instances share the same connection pool. Only the first MwsConnection configures the pool size.
maxConnections - Max number of http connectionspublic void setMaxErrorRetry(int maxErrorRetry)
maxErrorRetry - Max number of retries on 50x errorspublic void setProxyHost(String proxyHost)
proxyHost - Proxy Host for connectionpublic void setProxyPassword(String proxyPassword)
proxyPassword - Proxy Password for connectionpublic void setProxyPort(int proxyPort)
proxyPort - Proxy Port for connection.public void setProxyUsername(String proxyUsername)
proxyUsername - Proxy username for connection.public void setSignatureMethod(String signatureMethod)
signatureMethod - Signature Method for signing requestspublic void setSignatureVersion(String signatureVersion)
signatureVersion - Signature Version for signing requestspublic void setSocketTimeout(int socketTimeout)
socketTimeout - Timeout for waiting for datapublic void setUserAgent(String applicationName, String applicationVersion, String programmingLanguage, String... additionalNameValuePairs)
applicationName - applicationVersion - programmingLanguage - additionalNameValuePairs - Copyright © 2014. All Rights Reserved.