Issue 146: initial support for amazon SQS

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2627 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2010-01-11 00:08:04 +00:00
parent a06b06e40a
commit 05a7f5233b
117 changed files with 2425 additions and 114 deletions

View File

@ -16,7 +16,7 @@
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2.domain;
package org.jclouds.aws.domain;
import static com.google.common.base.Preconditions.checkNotNull;
@ -24,7 +24,7 @@ import com.google.common.base.CaseFormat;
/**
*
* Regions used for all ec2 commands.
* Regions used for all aws commands.
*
* @author Adrian Cole
*/

View File

@ -47,6 +47,12 @@ public class EC2ContextFactory {
modules).buildContext();
}
public static RestContext<EC2AsyncClient, EC2Client> createContext(Properties properties,
String awsAccessKeyId, String awsSecretAccessKey, Module... modules) {
return new EC2ContextBuilder(new EC2PropertiesBuilder(properties).withCredentials(
awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules).buildContext();
}
public static RestContext<EC2AsyncClient, EC2Client> createContext(String awsAccessKeyId,
String awsSecretAccessKey, Module... modules) {
return new EC2ContextBuilder(new EC2PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey)

View File

@ -20,7 +20,7 @@ package org.jclouds.aws.ec2;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_ENDPOINT;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_EXPIREINTERVAL;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_AWS_EXPIREINTERVAL;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
@ -39,7 +39,7 @@ public class EC2PropertiesBuilder extends HttpPropertiesBuilder {
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_EC2_ENDPOINT, "https://ec2.amazonaws.com");
properties.setProperty(PROPERTY_EC2_EXPIREINTERVAL, "60");
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
return properties;
}
@ -65,7 +65,7 @@ public class EC2PropertiesBuilder extends HttpPropertiesBuilder {
}
public EC2PropertiesBuilder withRequestExpiration(long seconds) {
properties.setProperty(PROPERTY_EC2_EXPIREINTERVAL, seconds + "");
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, seconds + "");
return this;
}
}

View File

@ -31,12 +31,12 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.domain.InstanceState;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.compute.ComputeService;

View File

@ -26,12 +26,11 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.predicates.InstanceStateRunning;
import org.jclouds.aws.ec2.reference.EC2Constants;
import org.jclouds.aws.ec2.services.AMIAsyncClient;
@ -50,6 +49,7 @@ import org.jclouds.aws.ec2.services.MonitoringAsyncClient;
import org.jclouds.aws.ec2.services.MonitoringClient;
import org.jclouds.aws.ec2.services.SecurityGroupAsyncClient;
import org.jclouds.aws.ec2.services.SecurityGroupClient;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
@ -114,7 +114,7 @@ public class EC2RestClientModule extends AbstractModule {
@Provides
@TimeStamp
protected String provideTimeStamp(final DateService dateService,
@Named(EC2Constants.PROPERTY_EC2_EXPIREINTERVAL) final int expiration) {
@Named(EC2Constants.PROPERTY_AWS_EXPIREINTERVAL) final int expiration) {
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis()
+ (expiration * 1000)));
}

View File

@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date;
import org.jclouds.aws.domain.Region;
/**
*
* @see <a href=

View File

@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import org.jclouds.aws.domain.Region;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

View File

@ -23,6 +23,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Set;
import org.jclouds.aws.domain.Region;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

View File

@ -20,6 +20,8 @@ package org.jclouds.aws.ec2.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.aws.domain.Region;
/**
*

View File

@ -20,6 +20,8 @@ package org.jclouds.aws.ec2.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.aws.domain.Region;
import com.google.inject.internal.Nullable;
/**

View File

@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.InetAddress;
import org.jclouds.aws.domain.Region;
import com.google.inject.internal.Nullable;
/**

View File

@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import org.jclouds.aws.domain.Region;
import com.google.inject.internal.Nullable;
/**

View File

@ -25,6 +25,7 @@ import java.util.Date;
import java.util.Map;
import java.util.Set;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment.Status;
import com.google.common.collect.Maps;

View File

@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import org.jclouds.aws.domain.Region;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-SecurityGroupItemType.html"

View File

@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date;
import org.jclouds.aws.domain.Region;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSnapshot.html"

View File

@ -25,6 +25,8 @@ import java.util.Set;
import javax.annotation.Nullable;
import org.jclouds.aws.domain.Region;
import com.google.common.base.CaseFormat;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

View File

@ -24,8 +24,8 @@ import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Region;
import com.google.common.base.Function;

View File

@ -24,8 +24,8 @@ import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.Region;
import com.google.common.base.Function;

View File

@ -20,7 +20,7 @@ package org.jclouds.aws.ec2.options;
import java.util.Set;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.options.internal.BaseEC2RequestOptions;
/**

View File

@ -22,7 +22,7 @@ import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.services.InstanceClient;
import org.jclouds.logging.Logger;

View File

@ -22,8 +22,8 @@ import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.InstanceState;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.services.InstanceClient;
import org.jclouds.logging.Logger;

View File

@ -21,8 +21,8 @@ package org.jclouds.aws.ec2.predicates;
import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.InstanceState;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.services.InstanceClient;
import org.jclouds.logging.Logger;

View File

@ -21,8 +21,8 @@ package org.jclouds.aws.ec2.predicates;
import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.InstanceState;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.services.InstanceClient;
import org.jclouds.logging.Logger;

View File

@ -28,8 +28,4 @@ import org.jclouds.aws.reference.AWSConstants;
public interface EC2Constants extends AWSConstants {
public static final String PROPERTY_EC2_ENDPOINT = "jclouds.ec2.endpoint";
/**
* how long do we wait before expiring requests.
*/
public static final String PROPERTY_EC2_EXPIREINTERVAL = "jclouds.ec2.expireinterval";
}

View File

@ -28,14 +28,13 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.binders.BindProductCodesToIndexedFormParams;
import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams;
import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams;
import org.jclouds.aws.ec2.domain.Image;
import org.jclouds.aws.ec2.domain.Permission;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
import org.jclouds.aws.ec2.options.CreateImageOptions;
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
@ -46,6 +45,7 @@ import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
import org.jclouds.aws.ec2.xml.ImageIdHandler;
import org.jclouds.aws.ec2.xml.PermissionHandler;
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;

View File

@ -22,9 +22,9 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Image;
import org.jclouds.aws.ec2.domain.Permission;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
import org.jclouds.aws.ec2.options.CreateImageOptions;
import org.jclouds.aws.ec2.options.DescribeImagesOptions;

View File

@ -28,15 +28,15 @@ import java.util.Set;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
import org.jclouds.aws.ec2.options.DescribeRegionsOptions;
import org.jclouds.aws.ec2.xml.DescribeAvailabilityZonesResponseHandler;
import org.jclouds.aws.ec2.xml.DescribeRegionsResponseHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;

View File

@ -23,8 +23,8 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
import org.jclouds.aws.ec2.options.DescribeRegionsOptions;
import org.jclouds.concurrent.Timeout;

View File

@ -27,16 +27,15 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams;
import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams;
import org.jclouds.aws.ec2.binders.BindVolumeIdsToIndexedFormParams;
import org.jclouds.aws.ec2.domain.Attachment;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Permission;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Snapshot;
import org.jclouds.aws.ec2.domain.Volume;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.AvailabilityZoneToEndpoint;
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
import org.jclouds.aws.ec2.functions.ReturnVoidOnVolumeAvailable;
@ -49,6 +48,7 @@ import org.jclouds.aws.ec2.xml.DescribeSnapshotsResponseHandler;
import org.jclouds.aws.ec2.xml.DescribeVolumesResponseHandler;
import org.jclouds.aws.ec2.xml.PermissionHandler;
import org.jclouds.aws.ec2.xml.SnapshotHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;

View File

@ -21,10 +21,10 @@ package org.jclouds.aws.ec2.services;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Permission;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Snapshot;
import org.jclouds.aws.ec2.domain.Volume;
import org.jclouds.aws.ec2.options.CreateSnapshotOptions;

View File

@ -28,13 +28,13 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.binders.BindInetAddressesToIndexedFormParams;
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;

View File

@ -23,8 +23,8 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.concurrent.Timeout;
/**

View File

@ -29,16 +29,15 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.binders.BindInstanceIdsToIndexedFormParams;
import org.jclouds.aws.ec2.binders.IfNotNullBindAvailabilityZoneToFormParam;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.InstanceStateChange;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
import org.jclouds.aws.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.ConvertUnencodedBytesToBase64EncodedString;
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
import org.jclouds.aws.ec2.options.RunInstancesOptions;
@ -51,6 +50,7 @@ import org.jclouds.aws.ec2.xml.InstanceTypeHandler;
import org.jclouds.aws.ec2.xml.RunInstancesResponseHandler;
import org.jclouds.aws.ec2.xml.StringValueHandler;
import org.jclouds.aws.ec2.xml.UnencodeStringValueHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;

View File

@ -24,11 +24,11 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.InstanceState;
import org.jclouds.aws.ec2.domain.InstanceStateChange;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
import org.jclouds.aws.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;

View File

@ -27,13 +27,13 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.binders.BindKeyNameToIndexedFormParams;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
import org.jclouds.aws.ec2.xml.KeyPairResponseHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;
@ -55,7 +55,7 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface KeyPairAsyncClient {
/**
* @see BaseEC2Client#createKeyPairInRegion
* @see KeyPairClient#createKeyPairInRegion
*/
@POST
@Path("/")
@ -66,7 +66,7 @@ public interface KeyPairAsyncClient {
@FormParam("KeyName") String keyName);
/**
* @see BaseEC2Client#describeKeyPairsInRegion
* @see KeyPairClient#describeKeyPairsInRegion
*/
@POST
@Path("/")
@ -77,7 +77,7 @@ public interface KeyPairAsyncClient {
@BinderParam(BindKeyNameToIndexedFormParams.class) String... keyPairNames);
/**
* @see BaseEC2Client#deleteKeyPairInRegion
* @see KeyPairClient#deleteKeyPairInRegion
*/
@POST
@Path("/")

View File

@ -21,8 +21,8 @@ package org.jclouds.aws.ec2.services;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.concurrent.Timeout;
/**

View File

@ -27,12 +27,12 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.binders.BindInstanceIdsToIndexedFormParams;
import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;

View File

@ -21,8 +21,8 @@ package org.jclouds.aws.ec2.services;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.concurrent.Timeout;
/**

View File

@ -27,16 +27,16 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.binders.BindGroupNameToIndexedFormParams;
import org.jclouds.aws.ec2.binders.BindUserIdGroupPairToSourceSecurityGroupFormParams;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.SecurityGroup;
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
import org.jclouds.aws.ec2.xml.DescribeSecurityGroupsResponseHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;

View File

@ -21,8 +21,8 @@ package org.jclouds.aws.ec2.services;
import java.util.SortedSet;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.SecurityGroup;
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
import org.jclouds.concurrent.Timeout;

View File

@ -21,8 +21,8 @@ package org.jclouds.aws.ec2.util;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.rest.internal.GeneratedHttpRequest;
/**

View File

@ -28,9 +28,9 @@ import java.util.Set;
import javax.annotation.Resource;
import javax.inject.Inject;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Volume;
import org.jclouds.aws.ec2.util.EC2Utils;
import org.jclouds.date.DateService;

View File

@ -22,9 +22,9 @@ import java.util.Set;
import javax.annotation.Resource;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo.State;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger;

View File

@ -23,7 +23,7 @@ import java.util.Map;
import javax.annotation.Resource;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.domain.Region;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger;

View File

@ -16,7 +16,7 @@
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2.filters;
package org.jclouds.aws.filters;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;

View File

@ -31,4 +31,8 @@ public interface AWSConstants extends HttpConstants, PoolConstants {
public static final String PROPERTY_AWS_SECRETACCESSKEY = "jclouds.aws.secretaccesskey";
public static final String PROPERTY_AWS_ACCESSKEYID = "jclouds.aws.accesskeyid";
/**
* how long do we wait before expiring requests.
*/
public static final String PROPERTY_AWS_EXPIREINTERVAL = "jclouds.aws.expireinterval";
}

View File

@ -47,14 +47,20 @@ public class S3ContextFactory {
.buildContext();
}
public static RestContext<S3AsyncClient, S3Client> createContext(Properties properties,
String awsAccessKeyId, String awsSecretAccessKey, Module... modules) {
return new S3ContextBuilder(new S3PropertiesBuilder(properties).withCredentials(
awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules).buildContext();
}
public static RestContext<S3AsyncClient, S3Client> createContext(String awsAccessKeyId,
String awsSecretAccessKey, Module... modules) {
return new S3ContextBuilder(new S3PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey)
.build()).withModules(modules).buildContext();
}
public static RestContext<S3AsyncClient, S3Client> createContext(URI endpoint, String awsAccessKeyId,
String awsSecretAccessKey, Module... modules) {
public static RestContext<S3AsyncClient, S3Client> createContext(URI endpoint,
String awsAccessKeyId, String awsSecretAccessKey, Module... modules) {
return new S3ContextBuilder(new S3PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey)
.withEndpoint(endpoint).build()).withModules(modules).buildContext();
}

View File

@ -43,7 +43,8 @@ import com.google.inject.Module;
* @see S3BlobStoreContext
*/
public class S3BlobStoreContextFactory {
public static BlobStoreContext<S3AsyncClient, S3Client> createContext(Properties properties, Module... modules) {
public static BlobStoreContext<S3AsyncClient, S3Client> createContext(Properties properties,
Module... modules) {
return new S3BlobStoreContextBuilder(new S3PropertiesBuilder(properties).build())
.withModules(modules).buildContext();
}
@ -54,8 +55,14 @@ public class S3BlobStoreContextFactory {
awsSecretAccessKey).build()).withModules(modules).buildContext();
}
public static BlobStoreContext<S3AsyncClient, S3Client> createContext(URI endpoint, String awsAccessKeyId,
String awsSecretAccessKey, Module... modules) {
public static BlobStoreContext<S3AsyncClient, S3Client> createContext(Properties properties,
String awsAccessKeyId, String awsSecretAccessKey, Module... modules) {
return new S3BlobStoreContextBuilder(new S3PropertiesBuilder(properties).withCredentials(
awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules).buildContext();
}
public static BlobStoreContext<S3AsyncClient, S3Client> createContext(URI endpoint,
String awsAccessKeyId, String awsSecretAccessKey, Module... modules) {
return new S3BlobStoreContextBuilder(new S3PropertiesBuilder(awsAccessKeyId,
awsSecretAccessKey).withEndpoint(endpoint).build()).withModules(modules)
.buildContext();

View File

@ -0,0 +1,39 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* Related to a resource of type SQS
*
* @author Adrian Cole
*
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface SQS {
}

View File

@ -0,0 +1,99 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs;
import static org.jclouds.aws.sqs.reference.SQSParameters.ACTION;
import static org.jclouds.aws.sqs.reference.SQSParameters.VERSION;
import java.util.Set;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.sqs.domain.Queue;
import org.jclouds.aws.sqs.functions.QueueLocation;
import org.jclouds.aws.sqs.functions.RegionToEndpoint;
import org.jclouds.aws.sqs.options.CreateQueueOptions;
import org.jclouds.aws.sqs.options.ListQueuesOptions;
import org.jclouds.aws.sqs.xml.ListQueuesResponseHandler;
import org.jclouds.aws.sqs.xml.MD5Handler;
import org.jclouds.aws.sqs.xml.QueueHandler;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides access to SQS via their REST API.
* <p/>
*
* @author Adrian Cole
*/
@RequestFilters(FormSigner.class)
@FormParams(keys = VERSION, values = "2009-02-01")
@VirtualHost
public interface SQSAsyncClient {
/**
* @see SQSClient#listQueuesInRegion
*/
@POST
@Path("/")
@FormParams(keys = ACTION, values = "ListQueues")
@XMLResponseParser(ListQueuesResponseHandler.class)
ListenableFuture<? extends Set<Queue>> listQueuesInRegion(
@EndpointParam(parser = RegionToEndpoint.class) Region region,
ListQueuesOptions... options);
/**
* @see SQSClient#createQueuesInRegion
*/
@POST
@Path("/")
@FormParams(keys = ACTION, values = "CreateQueue")
@XMLResponseParser(QueueHandler.class)
ListenableFuture<Queue> createQueueInRegion(
@EndpointParam(parser = RegionToEndpoint.class) Region region,
@FormParam("QueueName") String queueName, CreateQueueOptions... options);
/**
* @see SQSClient#deleteQueue
*/
@POST
@Path("/")
@FormParams(keys = ACTION, values = "DeleteQueue")
ListenableFuture<Void> deleteQueue(@EndpointParam(parser = QueueLocation.class) Queue queue);
/**
* @see SQSClient#sendMessage
*/
@POST
@Path("/")
@FormParams(keys = ACTION, values = "SendMessage")
@XMLResponseParser(MD5Handler.class)
ListenableFuture<byte[]> sendMessage(@EndpointParam(parser = QueueLocation.class) Queue queue,
@FormParam("MessageBody") String message);
}

View File

@ -0,0 +1,127 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.sqs.domain.Queue;
import org.jclouds.aws.sqs.options.CreateQueueOptions;
import org.jclouds.aws.sqs.options.ListQueuesOptions;
import org.jclouds.concurrent.Timeout;
/**
* Provides access to SQS via their REST API.
* <p/>
*
* @author Adrian Cole
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface SQSClient {
/**
* The ListQueues action returns a list of your queues. The maximum number of queues that can be
* returned is 1000. If you specify a value for the optional QueueNamePrefix parameter, only
* queues with a name beginning with the specified value are returned
*
* @param region
* Queues are Region-specific.
* @param options
* specify prefix or other options
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/APIReference/Query_QueryListQueues.html"
* />
*/
Set<Queue> listQueuesInRegion(Region region, ListQueuesOptions... options);
/**
*
* The CreateQueue action creates a new queue.
* <p/>
* When you request CreateQueue, you provide a name for the queue. To successfully create a new
* queue, you must provide a name that is unique within the scope of your own queues. If you
* provide the name of an existing queue, a new queue isn't created and an error isn't returned.
* Instead, the request succeeds and the queue URL for the existing queue is returned (for more
* information about queue URLs, see Queue and Message Identifiers in the Amazon SQS Developer
* Guide). Exception: if you provide a value for DefaultVisibilityTimeout that is different from
* the value for the existing queue, you receive an error.
* <h3>Note</h3>
*
* If you delete a queue, you must wait at least 60 seconds before creating a queue with the same
* name.
* <p/>
* A default value for the queue's visibility timeout (30 seconds) is set when the queue is
* created. You can override this value with the DefaultVisibilityTimeout request parameter. For
* more information, see Visibility Timeout in the Amazon SQS Developer Guide.
*
* @param region
* Queues are Region-specific.
* @param queueName
* The name to use for the queue created. Constraints: Maximum 80 characters;
* alphanumeric characters, hyphens (-), and underscores (_) are allowed.
* @param options
* like the visibility timeout (in seconds) to use for this queue.
*/
Queue createQueueInRegion(Region region, String queueName, CreateQueueOptions... options);
/**
* The DeleteQueue action deletes the queue specified by the queue URL, regardless of whether the
* queue is empty. If the specified queue does not exist, SQS returns a successful response. <h3>
* Caution</h3>
*
* Use DeleteQueue with care; once you delete your queue, any messages in the queue are no longer
* available.
* <p/>
* When you delete a queue, the deletion process takes up to 60 seconds. Requests you send
* involving that queue during the 60 seconds might succeed. For example, a SendMessage request
* might succeed, but after the 60 seconds, the queue and that message you sent no longer exist.
* Also, when you delete a queue, you must wait at least 60 seconds before creating a queue with
* the same name.
* <p/>
* We reserve the right to delete queues that have had no activity for more than 30 days. For
* more information, see About SQS Queues in the Amazon SQS Developer Guide.
*
* @param queue
* queue you want to delete
*/
void deleteQueue(Queue queue);
/**
* The SendMessage action delivers a message to the specified queue. The maximum allowed message
* size is 8 KB.
* <p/>
* Important
* <p/>
* The following list shows the characters (in Unicode) allowed in your message, according to the
* W3C XML specification (for more information, go to http://www.w3.org/TR/REC-xml/#charsets). If
* you send any characters not included in the list, your request will be rejected.
* <p/>
* #x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] | [#x10000 to #x10FFFF]
*
* @param queue
* queue you want to send to
*
* @param message
* The message to send. Type: String maximum 8 KB in size. For a list of allowed
* characters, see the preceding important note
* @return md5 of the content sent
*/
byte[] sendMessage(Queue queue, String message);
}

View File

@ -0,0 +1,76 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import org.jclouds.aws.sqs.config.SQSContextModule;
import org.jclouds.aws.sqs.config.SQSRestClientModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.rest.RestContextBuilder;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* Creates {@link SQSContext} or {@link Injector} instances based on the most commonly requested
* arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
*
* @author Adrian Cole
* @see SQSContext
*/
public class SQSContextBuilder extends RestContextBuilder<SQSAsyncClient, SQSClient> {
public SQSContextBuilder(Properties props) {
super(new TypeLiteral<SQSAsyncClient>() {
}, new TypeLiteral<SQSClient>() {
}, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new SQSContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new SQSRestClientModule());
}
@Override
public SQSContextBuilder withExecutorService(ExecutorService service) {
return (SQSContextBuilder) super.withExecutorService(service);
}
@Override
public SQSContextBuilder withModules(Module... modules) {
return (SQSContextBuilder) super.withModules(modules);
}
}

View File

@ -0,0 +1,67 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs;
import java.net.URI;
import java.util.Properties;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.rest.RestContext;
import com.google.inject.Module;
/**
* Creates {@link SQSContext} instances based on the most commonly requested arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
*
* @author Adrian Cole
* @see SQSAsyncClient
*/
public class SQSContextFactory {
public static RestContext<SQSAsyncClient, SQSClient> createContext(Properties properties,
Module... modules) {
return new SQSContextBuilder(new SQSPropertiesBuilder(properties).build()).withModules(
modules).buildContext();
}
public static RestContext<SQSAsyncClient, SQSClient> createContext(Properties properties, String awsAccessKeyId,
String awsSecretAccessKey, Module... modules) {
return new SQSContextBuilder(new SQSPropertiesBuilder(properties).withCredentials(awsAccessKeyId, awsSecretAccessKey)
.build()).withModules(modules).buildContext();
}
public static RestContext<SQSAsyncClient, SQSClient> createContext(String awsAccessKeyId,
String awsSecretAccessKey, Module... modules) {
return new SQSContextBuilder(new SQSPropertiesBuilder(awsAccessKeyId, awsSecretAccessKey)
.build()).withModules(modules).buildContext();
}
public static RestContext<SQSAsyncClient, SQSClient> createContext(URI endpoint,
String awsAccessKeyId, String awsSecretAccessKey, Module... modules) {
return new SQSContextBuilder(new SQSPropertiesBuilder(awsAccessKeyId, awsSecretAccessKey)
.withEndpoint(endpoint).build()).withModules(modules).buildContext();
}
}

View File

@ -0,0 +1,75 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_EXPIREINTERVAL;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1;
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1;
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1;
import java.net.URI;
import java.util.Properties;
import org.jclouds.http.HttpPropertiesBuilder;
/**
* Builds properties used in SQS Clients
*
* @author Adrian Cole
*/
public class SQSPropertiesBuilder extends HttpPropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_EAST_1, "https://queue.amazonaws.com");
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_WEST_1, "https://us-west-1.queue.amazonaws.com");
properties.setProperty(PROPERTY_SQS_ENDPOINT_EU_WEST_1, "https://eu-west-1.queue.amazonaws.com");
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
return properties;
}
public SQSPropertiesBuilder(Properties properties) {
super(properties);
}
public SQSPropertiesBuilder(String id, String secret) {
super();
withCredentials(id, secret);
}
public SQSPropertiesBuilder withCredentials(String id, String secret) {
properties.setProperty(PROPERTY_AWS_ACCESSKEYID, checkNotNull(id, "awsAccessKeyId"));
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, checkNotNull(secret,
"awsSecretAccessKey"));
return this;
}
public SQSPropertiesBuilder withEndpoint(URI endpoint) {
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_EAST_1, checkNotNull(endpoint, "endpoint").toString());
return this;
}
public SQSPropertiesBuilder withRequestExpiration(long seconds) {
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, seconds + "");
return this;
}
}

View File

@ -0,0 +1,59 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.config;
import java.net.URI;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.aws.sqs.SQS;
import org.jclouds.aws.sqs.SQSAsyncClient;
import org.jclouds.aws.sqs.SQSClient;
import org.jclouds.http.functions.config.ParserModule.CDateAdapter;
import org.jclouds.http.functions.config.ParserModule.DateAdapter;
import org.jclouds.lifecycle.Closer;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
/**
* Configures the SQS connection, including logging and http transport.
*
* @author Adrian Cole
*/
public class SQSContextModule extends AbstractModule {
@Override
protected void configure() {
bind(DateAdapter.class).to(CDateAdapter.class);
}
@Provides
@Singleton
RestContext<SQSAsyncClient, SQSClient> provideContext(Closer closer, SQSAsyncClient defaultApi,
SQSClient synchApi, @SQS URI endPoint,
@Named(AWSConstants.PROPERTY_AWS_ACCESSKEYID) String account) {
return new RestContextImpl<SQSAsyncClient, SQSClient>(closer, defaultApi, synchApi, endPoint,
account);
}
}

View File

@ -0,0 +1,128 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.config;
import java.net.URI;
import java.util.Date;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
import org.jclouds.aws.sqs.SQS;
import org.jclouds.aws.sqs.SQSAsyncClient;
import org.jclouds.aws.sqs.SQSClient;
import org.jclouds.aws.sqs.reference.SQSConstants;
import org.jclouds.aws.util.RequestSigner;
import org.jclouds.concurrent.internal.SyncProxy;
import org.jclouds.date.DateService;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientFactory;
import com.google.common.collect.ImmutableMap;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
/**
* Configures the SQS connection.
*
* @author Adrian Cole
*/
@RequiresHttp
@ConfiguresRestClient
public class SQSRestClientModule extends AbstractModule {
@Override
protected void configure() {
bindErrorHandlers();
bindRetryHandlers();
}
@Provides
@TimeStamp
protected String provideTimeStamp(final DateService dateService,
@Named(SQSConstants.PROPERTY_AWS_EXPIREINTERVAL) final int expiration) {
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis()
+ (expiration * 1000)));
}
@Provides
@Singleton
protected SQSAsyncClient provideAsyncClient(RestClientFactory factory) {
return factory.create(SQSAsyncClient.class);
}
@Provides
@Singleton
public SQSClient provideClient(SQSAsyncClient client) throws IllegalArgumentException,
SecurityException, NoSuchMethodException {
return SyncProxy.create(SQSClient.class, client);
}
@Provides
@Singleton
Map<Region, URI> provideRegions(
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1) String useast,
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1) String uswest,
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1) String euwest) {
return ImmutableMap.<Region, URI> of(Region.US_EAST_1, URI.create(useast), Region.US_WEST_1,
URI.create(uswest), Region.EU_WEST_1, URI.create(euwest));
}
@Provides
@Singleton
RequestSigner provideRequestSigner(FormSigner in) {
return in;
}
@Provides
@Singleton
@SQS
protected URI provideURI(@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1) String endpoint) {
return URI.create(endpoint);
}
protected void bindErrorHandlers() {
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
ParseAWSErrorFromXmlContent.class);
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
ParseAWSErrorFromXmlContent.class);
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
ParseAWSErrorFromXmlContent.class);
}
protected void bindRetryHandlers() {
bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(
AWSRedirectionRetryHandler.class);
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(
AWSClientErrorRetryHandler.class);
}
}

View File

@ -0,0 +1,104 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import org.jclouds.aws.domain.Region;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryListQueues.html"
* />
* @author Adrian Cole
*/
public class Queue implements Comparable<Queue> {
private final Region region;
private final String name;
private final URI location;
public Queue(Region region, String name, URI location) {
this.region = checkNotNull(region,"region");
this.location = checkNotNull(location, "location");
this.name = checkNotNull(name, "name");
}
@Override
public int compareTo(Queue o) {
return location.toASCIIString().compareTo(o.location.toASCIIString());
}
public Region getRegion() {
return region;
}
public URI getLocation() {
return location;
}
public String getName() {
return name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((region == null) ? 0 : region.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Queue other = (Queue) obj;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (region == null) {
if (other.region != null)
return false;
} else if (!region.equals(other.region))
return false;
return true;
}
@Override
public String toString() {
return "Queue [location=" + location + ", name=" + name + ", region=" + region + "]";
}
}

View File

@ -0,0 +1,40 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.functions;
import java.net.URI;
import javax.inject.Singleton;
import org.jclouds.aws.sqs.domain.Queue;
import com.google.common.base.Function;
/**
*
* @author Adrian Cole
*/
@Singleton
public class QueueLocation implements Function<Object, URI> {
public URI apply(Object from) {
return ((Queue) from).getLocation();
}
}

View File

@ -0,0 +1,51 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.functions;
import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.sqs.SQS;
import com.google.common.base.Function;
/**
*
* @author Adrian Cole
*/
@Singleton
public class RegionToEndpoint implements Function<Object, URI> {
private final Map<Region, URI> regionToEndpoint;
private final URI defaultUri;
@Inject
public RegionToEndpoint(Map<Region, URI> regionToEndpoint, @SQS URI defaultUri) {
this.regionToEndpoint = regionToEndpoint;
this.defaultUri = defaultUri;
}
public URI apply(Object from) {
return from.equals(Region.DEFAULT) ? defaultUri : regionToEndpoint.get(from);
}
}

View File

@ -0,0 +1,73 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.options;
import org.jclouds.http.options.BaseHttpRequestOptions;
/**
* Contains options supported in the Form API for the CreateQueue operation. <h2>
* Usage</h2> The recommended way to instantiate a CreateQueueOptions object is to statically import
* CreateQueueOptions.Builder.* and invoke a static creation method followed by an instance mutator
* (if needed):
* <p/>
* <code>
* import static org.jclouds.aws.sqs.options.CreateQueueOptions.Builder.*
* <p/>
* SQSClient connection = // get connection
* Queue queue = connection.createQueueInRegion(defaultVisibilityTimeout("foo"));
* <code>
*
* @author Adrian Cole
* @see <a
* href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryCreateQueue.html"
* />
*/
public class CreateQueueOptions extends BaseHttpRequestOptions {
/**
* A default value for the queue's visibility timeout (30 seconds) is set when the queue is
* created. You can override this value with the DefaultVisibilityTimeout request parameter. For
* more information, see Visibility Timeout in the Amazon SQS Developer Guide.
*
* @param seconds
* The visibility timeout (in seconds) to use for this queue. 0 to 43200 (maximum 12
* hours); Default: 30 seconds
*/
public CreateQueueOptions defaultVisibilityTimeout(int seconds) {
//TODO validate
formParameters.put("DefaultVisibilityTimeout", seconds+"");
return this;
}
public String getRestorableBy() {
return getFirstFormOrNull("DefaultVisibilityTimeout");
}
public static class Builder {
/**
* @see CreateQueueOptions#defaultVisibilityTimeout(int )
*/
public static CreateQueueOptions defaultVisibilityTimeout(int seconds) {
CreateQueueOptions options = new CreateQueueOptions();
return options.defaultVisibilityTimeout(seconds);
}
}
}

View File

@ -0,0 +1,72 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.options;
import org.jclouds.http.options.BaseHttpRequestOptions;
/**
* Contains options supported in the Form API for the ListQueues operation. <h2>
* Usage</h2> The recommended way to instantiate a ListQueuesOptions object is to statically import
* ListQueuesOptions.Builder.* and invoke a static creation method followed by an instance mutator
* (if needed):
* <p/>
* <code>
* import static org.jclouds.aws.sqs.options.ListQueuesOptions.Builder.*
* <p/>
* SQSClient connection = // get connection
* Set<Queue> queues = connection.listQueuesInRegion(queuePrefix("foo"));
* <code>
*
* @author Adrian Cole
* @see <a
* href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryListQueues.html"
* />
*/
public class ListQueuesOptions extends BaseHttpRequestOptions {
/**
* String to use for filtering the list results. Only those queues whose name begins with the
* specified string are returned.
*
* @param prefix
* Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are
* allowed.
*/
public ListQueuesOptions queuePrefix(String prefix) {
//TODO validate
formParameters.put("QueueNamePrefix", prefix);
return this;
}
public String getRestorableBy() {
return getFirstFormOrNull("QueueNamePrefix");
}
public static class Builder {
/**
* @see ListQueuesOptions#queuePrefix(String )
*/
public static ListQueuesOptions queuePrefix(String prefix) {
ListQueuesOptions options = new ListQueuesOptions();
return options.queuePrefix(prefix);
}
}
}

View File

@ -0,0 +1,25 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
/**
* This package contains an Amazon SQS client implemented by {@link org.jclouds.http.HttpCommandExecutorService} commands.
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/index.html"/>
* @author Adrian Cole
*/
package org.jclouds.aws.sqs;

View File

@ -0,0 +1,32 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.reference;
import org.jclouds.aws.reference.AWSConstants;
/**
* Configuration properties and constants used in SQS connections.
*
* @author Adrian Cole
*/
public interface SQSConstants extends AWSConstants {
public static final String PROPERTY_SQS_ENDPOINT_EU_WEST_1 = "jclouds.sqs.endpoint.eu_west_1";
public static final String PROPERTY_SQS_ENDPOINT_US_EAST_1 = "jclouds.sqs.endpoint.us_east_1";
public static final String PROPERTY_SQS_ENDPOINT_US_WEST_1 = "jclouds.sqs.endpoint.us_west_1";
}

View File

@ -0,0 +1,55 @@
package org.jclouds.aws.sqs.reference;
/**
* Configuration properties and constants used in SQS connections.
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/APIReference/Query_QueryParams.html"
* />
* @author Adrian Cole
*/
public interface SQSParameters {
/**
* The action to perform. For example: CreateQueue.
*/
public static final String ACTION = "Action";
/**
* The API version to use, as specified in the WSDL. For example: 2009-02-01.
*/
public static final String VERSION = "Version";
/**
* Your Access Key ID. For example: 0AS7253JW73RRM652K02. For more information, see Your AWS
* Identifiers in the Amazon SQS Developer Guide.
*/
public static final String AWS_ACCESS_KEY_ID = "AWSAccessKeyId";
/**
* The date and time the request is signed, in the format YYYY-MM-DDThh:mm:ssZ, as specified in
* the ISO 8601 standard. Query requests must include either Timestamp or Expires, but not both.
*
*/
public static final String TIMESTAMP = "Timestamp";
/**
* The date and time at which the signature included in the request expires, in the format
* YYYY-MM-DDThh:mm:ssZ, as specified in the ISO 8601 standard. Query requests must include
* either Timestamp or Expires, but not both.
*/
public static final String EXPIRES = "Expires";
/**
* A request signature (for information, see Request Authentication in the Amazon SQS Developer
* Guide). For example: Qnpl4Qk/7tINHzfXCiT7VbBatDA=.
*/
public static final String SIGNATURE = "Signature";
/**
*Required when you use signature version 2 with Query requests. For more information, see Query
* Request Authentication in the Amazon SQS Developer Guide.
*/
public static final String SIGNATURE_METHOD = "SignatureMethod";
/**
* For more information, see Query Request Authentication in the Amazon SQS Developer Guide.
*/
public static final String SIGNATURE_VERSION = "SignatureVersion";
}

View File

@ -0,0 +1,23 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
/**
* This package contains properties and reference data used in SQS.
* @author Adrian Cole
*/
package org.jclouds.aws.sqs.reference;

View File

@ -0,0 +1,61 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.xml;
import java.util.Set;
import javax.inject.Inject;
import org.jclouds.aws.sqs.domain.Queue;
import org.jclouds.http.functions.ParseSax;
import com.google.common.collect.Sets;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryListQueues.html"
* />
* @author Adrian Cole
*/
public class ListQueuesResponseHandler extends ParseSax.HandlerWithResult<Set<Queue>> {
Set<Queue> queues = Sets.newLinkedHashSet();
private final QueueHandler qHandler;
@Inject
ListQueuesResponseHandler(QueueHandler qHandler) {
this.qHandler = qHandler;
}
public Set<Queue> getResult() {
return queues;
}
public void endElement(String uri, String name, String qName) {
qHandler.endElement(uri, name, qName);
if (qName.equals("QueueUrl")) {
queues.add(qHandler.getResult());
}
}
public void characters(char ch[], int start, int length) {
qHandler.characters(ch, start, length);
}
}

View File

@ -0,0 +1,60 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.xml;
import javax.inject.Inject;
import org.jclouds.encryption.EncryptionService;
import org.jclouds.http.functions.ParseSax;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QuerySendMessage.html"
* />
* @author Adrian Cole
*/
public class MD5Handler extends ParseSax.HandlerWithResult<byte[]> {
private StringBuilder currentText = new StringBuilder();
byte[] md5;
private final EncryptionService encryptionService;
@Inject
MD5Handler(EncryptionService encryptionService) {
this.encryptionService = encryptionService;
}
public byte[] getResult() {
return md5;
}
public void endElement(String uri, String name, String qName) {
if (qName.equals("MD5OfMessageBody")) {
String md5Hex = currentText.toString().trim();
this.md5 = encryptionService.fromHexString(md5Hex);
}
currentText = new StringBuilder();
}
public void characters(char ch[], int start, int length) {
currentText.append(ch, start, length);
}
}

View File

@ -0,0 +1,72 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.sqs.xml;
import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
import javax.ws.rs.core.UriBuilder;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.sqs.domain.Queue;
import org.jclouds.http.functions.ParseSax;
import com.google.common.collect.ImmutableBiMap;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryListQueues.html"
* />
* @author Adrian Cole
*/
public class QueueHandler extends ParseSax.HandlerWithResult<Queue> {
private StringBuilder currentText = new StringBuilder();
Queue queue;
private final ImmutableBiMap<Region, URI> regionBiMap;
@Inject
QueueHandler(Map<Region, URI> regionMap) {
this.regionBiMap = ImmutableBiMap.copyOf(regionMap);
}
public Queue getResult() {
return queue;
}
public void endElement(String uri, String name, String qName) {
if (qName.equals("QueueUrl")) {
String uriText = currentText.toString().trim();
String queueName = uriText.substring(uriText.lastIndexOf('/') + 1);
URI location = URI.create(uriText);
URI regionURI = UriBuilder.fromUri(location).replacePath("").build();
Region region = regionBiMap.inverse().get(regionURI);
this.queue = new Queue(region, queueName, location);
}
currentText = new StringBuilder();
}
public void characters(char ch[], int start, int length) {
currentText.append(ch, start, length);
}
}

View File

@ -35,12 +35,12 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.InstanceState;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;

View File

@ -36,13 +36,13 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment;
import org.jclouds.aws.ec2.domain.Image;
import org.jclouds.aws.ec2.domain.InstanceState;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.RootDeviceType;
import org.jclouds.aws.ec2.domain.RunningInstance;

View File

@ -27,8 +27,8 @@ import java.util.ArrayList;
import java.util.List;
import org.jclouds.aws.ec2.config.EC2RestClientModule;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.reference.EC2Constants;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl;
import org.testng.annotations.Test;

View File

@ -58,7 +58,7 @@ public class EC2ContextModuleTest {
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_EC2_ENDPOINT))
.to("http://localhost");
bindConstant().annotatedWith(
Jsr330.named(EC2Constants.PROPERTY_EC2_EXPIREINTERVAL)).to(30);
Jsr330.named(EC2Constants.PROPERTY_AWS_EXPIREINTERVAL)).to(30);
super.configure();
}
});

View File

@ -53,7 +53,7 @@ public class EC2RestClientModuleTest {
.to("key");
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_EC2_ENDPOINT)).to(
"http://localhost");
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_EC2_EXPIREINTERVAL))
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_AWS_EXPIREINTERVAL))
.to(30);
}
});

View File

@ -29,9 +29,8 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.options.CreateImageOptions;
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
@ -41,6 +40,7 @@ import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
import org.jclouds.aws.ec2.xml.ImageIdHandler;
import org.jclouds.aws.ec2.xml.PermissionHandler;
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;

View File

@ -29,11 +29,11 @@ import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.Image;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.RootDeviceType;
import org.jclouds.aws.ec2.domain.Image.ImageType;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;

View File

@ -30,14 +30,14 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
import org.jclouds.aws.ec2.options.DescribeRegionsOptions;
import org.jclouds.aws.ec2.xml.DescribeAvailabilityZonesResponseHandler;
import org.jclouds.aws.ec2.xml.DescribeRegionsResponseHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;

View File

@ -30,12 +30,12 @@ import java.util.SortedMap;
import java.util.SortedSet;
import java.util.Map.Entry;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterTest;

View File

@ -30,10 +30,9 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.ReturnVoidOnVolumeAvailable;
import org.jclouds.aws.ec2.options.CreateSnapshotOptions;
import org.jclouds.aws.ec2.options.DescribeSnapshotsOptions;
@ -44,6 +43,7 @@ import org.jclouds.aws.ec2.xml.DescribeSnapshotsResponseHandler;
import org.jclouds.aws.ec2.xml.DescribeVolumesResponseHandler;
import org.jclouds.aws.ec2.xml.PermissionHandler;
import org.jclouds.aws.ec2.xml.SnapshotHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;

View File

@ -27,11 +27,11 @@ import java.util.SortedSet;
import java.util.concurrent.TimeUnit;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Snapshot;
import org.jclouds.aws.ec2.domain.Volume;
import org.jclouds.aws.ec2.predicates.SnapshotCompleted;

View File

@ -29,11 +29,11 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;

View File

@ -24,11 +24,11 @@ import static org.testng.Assert.assertNotNull;
import java.util.SortedSet;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterTest;

View File

@ -28,12 +28,11 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.options.RunInstancesOptions;
import org.jclouds.aws.ec2.xml.BlockDeviceMappingHandler;
import org.jclouds.aws.ec2.xml.BooleanValueHandler;
@ -44,6 +43,7 @@ import org.jclouds.aws.ec2.xml.InstanceTypeHandler;
import org.jclouds.aws.ec2.xml.RunInstancesResponseHandler;
import org.jclouds.aws.ec2.xml.StringValueHandler;
import org.jclouds.aws.ec2.xml.UnencodeStringValueHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;

View File

@ -25,8 +25,8 @@ import static org.testng.Assert.assertNotNull;
import java.util.Iterator;
import java.util.SortedSet;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.testng.annotations.BeforeGroups;

View File

@ -28,10 +28,10 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;

View File

@ -24,11 +24,11 @@ import static org.testng.Assert.assertNotNull;
import java.util.SortedSet;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterTest;

View File

@ -28,10 +28,10 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;

View File

@ -23,11 +23,11 @@ import static org.testng.Assert.assertEquals;
import java.util.Map;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
import org.testng.annotations.BeforeGroups;

View File

@ -28,13 +28,13 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
import org.jclouds.aws.ec2.filters.FormSigner;
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
import org.jclouds.aws.ec2.xml.DescribeSecurityGroupsResponseHandler;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;

View File

@ -28,12 +28,12 @@ import java.util.SortedSet;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.EC2ContextFactory;
import org.jclouds.aws.ec2.domain.IpPermission;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.SecurityGroup;
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;

View File

@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax;

View File

@ -28,9 +28,9 @@ import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Volume;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest;

View File

@ -28,8 +28,8 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Set;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.internal.GeneratedHttpRequest;

View File

@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.util.Set;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.http.functions.BaseHandlerTest;
import org.testng.annotations.Test;

View File

@ -27,8 +27,8 @@ import java.io.InputStream;
import java.util.Set;
import java.util.SortedSet;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Image;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.RootDeviceType;
import org.jclouds.aws.ec2.domain.Image.Architecture;
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;

View File

@ -28,11 +28,11 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Set;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.InstanceState;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.RootDeviceType;
import org.jclouds.aws.ec2.domain.RunningInstance;

View File

@ -26,8 +26,8 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.util.Set;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.internal.GeneratedHttpRequest;

View File

@ -24,8 +24,8 @@ import java.io.InputStream;
import java.net.URI;
import java.util.Map;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.config.ParserModule;

View File

@ -27,9 +27,9 @@ import java.io.InputStream;
import java.util.Set;
import java.util.SortedSet;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.IpPermission;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.SecurityGroup;
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
import org.jclouds.http.functions.BaseHandlerTest;

View File

@ -26,7 +26,7 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.util.Set;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Snapshot;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest;

View File

@ -29,9 +29,9 @@ import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.domain.Attachment;
import org.jclouds.aws.ec2.domain.AvailabilityZone;
import org.jclouds.aws.ec2.domain.Region;
import org.jclouds.aws.ec2.domain.Volume;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest;

Some files were not shown because too many files have changed in this diff Show More