com.xerox.amazonws.common
Class AWSQueryConnection

java.lang.Object
  extended by com.xerox.amazonws.common.AWSConnection
      extended by com.xerox.amazonws.common.AWSQueryConnection
Direct Known Subclasses:
AutoScaling, DevPayLS, Domain, FlexiblePaymentsService, Item, Jec2, LoadBalancing, MessageQueue, Monitoring, QueueService, SimpleDB

public class AWSQueryConnection
extends AWSConnection

This class provides an interface with the Amazon SQS service. It provides high level methods for listing and creating message queues.

Author:
D. Kavanagh, developer@dotech.com

Field Summary
 
Fields inherited from class com.xerox.amazonws.common.AWSConnection
headers
 
Constructor Summary
AWSQueryConnection(String awsAccessId, String awsSecretKey, boolean isSecure, String server, int port)
          Initializes the queue service with your AWS login information.
 
Method Summary
protected  void close(org.apache.http.HttpEntity entity)
           
protected  void close(InputStream istream)
           
 int getConnectionManagerTimeout()
           
 int getConnectionTimeout()
           
 Map<String,List<String>> getHeaders()
          This method returns the map of headers for this connection
protected  org.apache.http.client.HttpClient getHttpClient()
           
 int getMaxConnections()
          This method returns the number of connections that can be open at once.
 int getMaxRetries()
          This method returns the number of times to retry when a recoverable error occurs.
 TimeZone getServerTimeZone()
          Returns timezone used when creating requests.
 int getSoTimeout()
           
protected  String getString(org.apache.http.HttpEntity entity)
           
protected  String httpDate(Calendar date)
           
<T> T
makeRequest(org.apache.http.client.methods.HttpRequestBase method, String action, Map<String,String> params, Class<T> respType)
          Make a http request and process the response.
 void setConnectionManagerTimeout(int timeout)
           
 void setConnectionTimeout(int timeout)
           
 void setHttpClient(org.apache.http.client.HttpClient hc)
           
 void setMaxConnections(int connections)
          This method sets the number of connections that can be open at once.
 void setMaxRetries(int retries)
          This method sets the number of times to retry when a recoverable error occurs.
 void setProxyValues(String host, int port)
          This method sets the proxy host and port
 void setProxyValues(String host, int port, String user, String password)
          This method sets the proxy host, port, user and password (for authenticating proxies)
 void setProxyValues(String host, int port, String user, String password, String domain)
          This method sets the proxy host, port, user, password and domain (for NTLM authentication)
 void setServerTimeZone(TimeZone serverTimeZone)
          Allows setting non-standard server timezone.
 void setSoTimeout(int timeout)
           
 void useSystemProxy()
          This method indicates the system properties should be used for proxy settings.
 
Methods inherited from class com.xerox.amazonws.common.AWSConnection
encode, encode, getAlgorithm, getAwsAccessKeyId, getPort, getResourcePrefix, getSecretAccessKey, getServer, getSignatureVersion, getUrl, isSecure, makeURL, setResourcePrefix, setServer, setSignatureVersion, urlencode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AWSQueryConnection

public AWSQueryConnection(String awsAccessId,
                          String awsSecretKey,
                          boolean isSecure,
                          String server,
                          int port)
Initializes the queue service with your AWS login information.

Parameters:
awsAccessId - The your user key into AWS
awsSecretKey - The secret string used to generate signatures for authentication.
isSecure - True if the data should be encrypted on the wire on the way to or from SQS.
server - Which host to connect to.
port - Which port to use.
Method Detail

getMaxConnections

public int getMaxConnections()
This method returns the number of connections that can be open at once.

Returns:
the number of connections

setMaxConnections

public void setMaxConnections(int connections)
This method sets the number of connections that can be open at once.

Parameters:
connections - the number of connections

getMaxRetries

public int getMaxRetries()
This method returns the number of times to retry when a recoverable error occurs.

Returns:
the number of times to retry on recoverable error

setMaxRetries

public void setMaxRetries(int retries)
This method sets the number of times to retry when a recoverable error occurs.

Parameters:
retries - the number of times to retry on recoverable error

setProxyValues

public void setProxyValues(String host,
                           int port)
This method sets the proxy host and port

Parameters:
host - the proxy host
port - the proxy port

setProxyValues

public void setProxyValues(String host,
                           int port,
                           String user,
                           String password)
This method sets the proxy host, port, user and password (for authenticating proxies)

Parameters:
host - the proxy host
port - the proxy port
user - the proxy user
password - the proxy password

setProxyValues

public void setProxyValues(String host,
                           int port,
                           String user,
                           String password,
                           String domain)
This method sets the proxy host, port, user, password and domain (for NTLM authentication)

Parameters:
host - the proxy host
port - the proxy port
user - the proxy user
password - the proxy password
domain - the proxy domain

useSystemProxy

public void useSystemProxy()
This method indicates the system properties should be used for proxy settings. These properties are http.proxyHost, http.proxyPort, http.proxyUser and http.proxyPassword


getConnectionManagerTimeout

public int getConnectionManagerTimeout()
Returns:
connection manager timeout in milliseconds
See Also:
org.apache.http.params.HttpClientParams.getConnectionManagerTimeout()

setConnectionManagerTimeout

public void setConnectionManagerTimeout(int timeout)
Parameters:
connection - manager timeout in milliseconds
See Also:
org.apache.http.params.HttpClientParams.getConnectionManagerTimeout()

getSoTimeout

public int getSoTimeout()
Returns:
socket timeout in milliseconds
See Also:
org.apache.http.params.HttpConnectionParams.getSoTimeout(), org.apache.http.params.HttpMethodParams.getSoTimeout()

setSoTimeout

public void setSoTimeout(int timeout)
Parameters:
socket - timeout in milliseconds
See Also:
org.apache.http.params.HttpConnectionParams.getSoTimeout(), org.apache.http.params.HttpMethodParams.getSoTimeout()

getConnectionTimeout

public int getConnectionTimeout()
Returns:
connection timeout in milliseconds
See Also:
org.apache.http.params.HttpConnectionParams.getConnectionTimeout()

setConnectionTimeout

public void setConnectionTimeout(int timeout)
Parameters:
connection - timeout in milliseconds
See Also:
org.apache.http.params.HttpConnectionParams.getConnectionTimeout()

getHeaders

public Map<String,List<String>> getHeaders()
This method returns the map of headers for this connection

Returns:
map of headers (modifiable)

getServerTimeZone

public TimeZone getServerTimeZone()
Returns timezone used when creating requests. This is helpful when talking to servers running in different timezones. Specifically when typica talks with a private Eucalyptus cluster.

Returns:
server timezone setting

setServerTimeZone

public void setServerTimeZone(TimeZone serverTimeZone)
Allows setting non-standard server timezone. (see getter comments)

Parameters:
serverTimeZone - new timezone of server

getHttpClient

protected org.apache.http.client.HttpClient getHttpClient()

setHttpClient

public void setHttpClient(org.apache.http.client.HttpClient hc)

makeRequest

public <T> T makeRequest(org.apache.http.client.methods.HttpRequestBase method,
                         String action,
                         Map<String,String> params,
                         Class<T> respType)
              throws org.apache.http.HttpException,
                     IOException,
                     javax.xml.bind.JAXBException,
                     AWSException,
                     SAXException
Make a http request and process the response. This method also performs automatic retries.

Parameters:
method - The HTTP method to use (GET, POST, DELETE, etc)
action - the name of the action for this query request
params - map of request params
respType - the class that represents the desired/expected return type
Throws:
org.apache.http.HttpException
IOException
javax.xml.bind.JAXBException
AWSException
SAXException

getString

protected String getString(org.apache.http.HttpEntity entity)

close

protected void close(org.apache.http.HttpEntity entity)

close

protected void close(InputStream istream)

httpDate

protected String httpDate(Calendar date)