AWS Developer Blog

New, Simplified Method Forms in the AWS SDK for Java

by Jason Fulghum | on | in Java | Permalink | Comments |  Share

We’re always looking for new ways to improve the tools our team builds, like the AWS SDK for Java and the AWS Toolkit for Eclipse. Sometimes those improvements come as brand new functionality, such as Amazon CloudWatch Metrics for the AWS SDK for Java, and sometimes they’re small tweaks to make the tools faster or easier to use.

Today, I want to show off a small tweak that we added recently to make invoking requests with the SDK a little bit easier and more concise. We’ve tweaked the AmazonDynamoDBClient and AmazonSNSClient classes so that lots of common operations are even easier and more succinct to invoke.

For some of the most commonly used operations with Amazon DynamoDB and Amazon SNS, you can now skip constructing request objects and just pass in your request parameters directly. The request objects are still useful in many cases, such as providing access to less common parameters, or allowing you to build your request parameters in one part of your code and pass the request objects to another part of your code to be executed. These new method forms simply provide an alternate way to quickly invoke operations with common parameter combinations.

Here’s an example of using a few of the new, simplified method forms in the Amazon SNS client:

AmazonSNSClient sns = new AmazonSNSClient(myCredentials);
String topicArn = sns.createTopic("myNewTopic").getTopicArn();
String subscriptionArn = sns.subscribe(topicArn, "email", "me@email.com").getSubscriptionArn();
sns.publish(topicArn, "hello SNS world!");
sns.unsubscribe(subscriptionArn);
sns.deleteTopic(topicArn);

We’ll be adding more methods like these to other service clients in the SDK, too. What clients would you like to see updated next? Are there other common request parameter combinations that you’d like us to add?