World Line

Introducing the GAE-AWS SDK for Java

with 13 comments

I’m making what I hope will be a useful release today — a version of the Amazon Web Services SDK for Java that will run from inside of Google App Engine. This wouldn’t work if you simply included the JAR that AWS provides directly into GAE’s WAR, because GAE’s security model doesn’t allow the Apache Commons HTTP Client to create the sockets and low-level networking primitives it requires to establish an HTTP connection; instead, Google requires you to make all connections through its URLFetch utility. This version of the SDK does exactly that, swapping out the Apache HTTP Connection Manager for one that returns URLFetchHttpConnections.

With it, you can make use of the multitude of powerful AWS services (excepting S3, which requires more work before it will integrate properly) from within Google App Engine, making both of these tools significantly more useful. In fact, AWS seems to nicely complement several of Google App Engine’s deficiencies; for example, my original motivation for creating this was to be able to make SimpleDB requests from GAE for a school project I’m working on.

Using it is very simple — just download the full package from its GitHub page, and add all of the JAR files in the package (including the third-party/ directory) to Google App Engine’s war/WEB-INF/lib/ directory, and add them to your build path in Eclipse. Then just use the SDK in the usual fashion! For example, the following lines of code:

		AmazonSimpleDB sdb = new AmazonSimpleDBClient(new PropertiesCredentials("AWSCredentials.properties"));
		sdb.setEndpoint("http://sdb.amazonaws.com");

		String serverInfo = getServletContext().getServerInfo();
		String userAgent = getThreadLocalRequest().getHeader("User-Agent");
		return "Hello, " + input + "!<br><br>I am running " + serverInfo
				+ ".<br><br>It looks like you are using:<br>" + userAgent
				+ ".<br><br>You have " + sdb.listDomains().getDomainNames().size() + " SDB domains.";

turns the usual GWT welcome page into this:

Notice the last line there!

I intend to merge in all upstream changes from the real AWS SDK for Java, of which this is simply a GitHub fork. Please post any issues or questions you have in the GitHub page!

About these ads

Written by Adrian Petrescu

June 22, 2010 at 9:38 am

Posted in Development

Tagged with ,

13 Responses

Subscribe to comments with RSS.

  1. Nice work! very cool.

    Jason F

    June 22, 2010 at 6:27 pm

  2. Neat-o.

    Zachary

    June 23, 2010 at 7:46 am

  3. With it, you can make use of the multitude of powerful AWS services (excepting S3, which requires more work before it will integrate properly) from within Google App Engine, making both of these tools significantly more useful. In fact, AWS seems to nicely complement several of Google App Engine’s deficiencies; for example, my original motivation for creating this was to be able to make SimpleDB requests from GAE for a school project I’m working on.

    +1

    Latisha

    June 24, 2010 at 12:55 pm

  4. [...] 23, 2010 by Michael Justin Leave a Comment Adrian Petrescu published a version of the Amazon Web Services SDK for Java that will run from inside of Google App Engine. [...]

  5. Hi, Thanks for the code, this plus some of what http://github.com/DomDerrien did with the connection wrapping has allowed me to get this working with Amazon MWS.

    Ashley Schroder

    August 30, 2010 at 4:13 am

  6. THanks so much.

    John Middendorf

    September 24, 2010 at 4:24 pm

  7. You mention S3 needs more work. What needs to be done? I’m interested in uploading photos to my S3 bucket via GAE.

    thanks

    John Middendorf

    September 24, 2010 at 4:56 pm

  8. Hi John,

    The hack I’m using now to parse replies is the problem; it’s actually quite possible that *sending* streams to S3 will work just fine. You can try this out by downloading the source from GitHub and just removing the exclude from my build.xml.

    Also, if you’re familiar with the concept, I’m almost certain that generating a presigned URL and having users upload the form directly to that will also work.

    In a few days I’ll be releasing a testing suite for this that runs directly on GAE, which will allow me to try out these kinds of things much more quickly. Stay tuned :)

    Adrian Petrescu

    September 24, 2010 at 5:02 pm

  9. Hi-thanks for this. Any word on the new suite?

    John Middendorf

    October 7, 2010 at 1:06 am

  10. [...] might be a solution.I saw one reference of someone 'porting' the AWS Java SDK to GWT; http://apetresc.wordpress.com/20….I don't know GWT very much, other than it transform Java into in Javascript. Perhaps you can [...]

  11. [...] been getting lots of great feedback on the GAE port of the AWS SDK for Java that I released a few months back as part of a school project I was working on. As I’d hoped, it’s grown way beyond that, [...]

  12. [...] and reconstitute enough information to be able to call UrlFetchService.  Noteably, Adrian Petrescu used this approach and forked the official AWS [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: