diff --git a/.gitignore b/.gitignore
index 5339548..5a36a45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,4 +17,5 @@ lib
logs
nohup.out
out
-target
\ No newline at end of file
+target
+spring-integration-aws/src/test/resources/awscredentials.properties
\ No newline at end of file
diff --git a/README.md b/README.md
index c7dbf51..eb6b3ef 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@ The Spring Integration Extensions project provides extension modules for [Spring
* [Atmosphere][] Support ([Websockets][])
* [XQuery][] Support
* [Splunk][] Support
+* [Amazon Web Services (AWS)][] Support
## Getting support
@@ -127,4 +128,5 @@ The Spring Integration Extensions Framework is released under version 2.0 of the
[Atmosphere]: https://github.com/Atmosphere/atmosphere
[Websockets]: http://www.html5rocks.com/en/tutorials/websockets/basics/
[XQuery]: http://en.wikipedia.org/wiki/XQuery
-[Splunk]:http://www.splunk.com/
\ No newline at end of file
+[Splunk]:http://www.splunk.com/
+[Amazon Web Services (AWS)]: http://aws.amazon.com/
\ No newline at end of file
diff --git a/samples/mail-ses-integration/README.md b/samples/mail-ses-integration/README.md
new file mode 100644
index 0000000..667fb78
--- /dev/null
+++ b/samples/mail-ses-integration/README.md
@@ -0,0 +1,4 @@
+AWS SES Spring Integration Sample
+=========================
+
+
diff --git a/samples/mail-ses-integration/pom.xml b/samples/mail-ses-integration/pom.xml
new file mode 100644
index 0000000..56cb721
--- /dev/null
+++ b/samples/mail-ses-integration/pom.xml
@@ -0,0 +1,84 @@
+
+ 4.0.0
+ org.springframework.integration.samples
+ mail-ses-integration
+ AWS SES Mail Demo
+ 1.0.0.BUILD-SNAPSHOT
+
+
+ 2.2.1
+
+
+
+ UTF-8
+ 2.2.0.RELEASE
+ 1.2.17
+ 4.10
+
+
+
+ org.springframework.integration
+ spring-integration-mail
+ ${spring.integration.version}
+
+
+ org.springframework.integration
+ spring-integration-test
+ ${spring.integration.version}
+
+
+ org.springframework.integration
+ spring-integration-aws
+ 0.5.0.BUILD-SNAPSHOT
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.subethamail
+ subethasmtp-wiser
+ 1.2
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.5.1
+
+ 1.6
+ 1.6
+ -Xlint:all
+ true
+ true
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.2.1
+
+ org.springframework.integration.samples.mailses.Main
+
+
+
+
+
+
+ repo.springsource.org.milestone
+ SpringSource Maven Milestone Repository
+ https://repo.springsource.org/libs-milestone
+
+
+
\ No newline at end of file
diff --git a/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/EmailService.java b/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/EmailService.java
new file mode 100644
index 0000000..a3a4050
--- /dev/null
+++ b/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/EmailService.java
@@ -0,0 +1,24 @@
+package org.springframework.integration.samples.mailses;
+
+import org.springframework.integration.annotation.Header;
+import org.springframework.integration.annotation.Payload;
+import org.springframework.integration.mail.MailHeaders;
+
+public interface EmailService {
+
+
+ void send(
+
+ @Header(MailHeaders.FROM)
+ String fromEmail,
+
+ @Header(MailHeaders.TO)
+ String toEmail,
+
+ @Header(MailHeaders.SUBJECT)
+ String subject,
+
+ @Payload
+ String body);
+
+}
diff --git a/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/Main.java b/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/Main.java
new file mode 100644
index 0000000..7972880
--- /dev/null
+++ b/samples/mail-ses-integration/src/main/java/org/springframework/integration/samples/mailses/Main.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.samples.mailses;
+
+import java.util.Scanner;
+
+import org.apache.log4j.Logger;
+import org.springframework.context.support.GenericXmlApplicationContext;
+import org.springframework.core.env.ConfigurableEnvironment;
+
+/**
+ * Starts the Spring Context and will initialize the Spring Integration routes.
+ *
+ * @author Gunnar Hillert
+ * @since 1.0
+ *
+ */
+public final class Main {
+
+ private static final Logger LOGGER = Logger.getLogger(Main.class);
+
+ private static final String HORIZONTAL_LINE = "\n=========================================================";
+
+ private Main() {
+ }
+
+ /**
+ * Load the Spring Integration Application Context
+ *
+ * @param args - command line arguments
+ */
+ public static void main(final String... args) {
+
+ final Scanner scanner = new Scanner(System.in);
+
+ LOGGER.info(HORIZONTAL_LINE + "\n"
+ + "\n Welcome to Spring Integration! "
+ + "\n"
+ + "\n For more information please visit: "
+ + "\n http://www.springsource.org/spring-integration "
+ + "\n" + HORIZONTAL_LINE);
+
+ final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
+ final ConfigurableEnvironment environment = context.getEnvironment();
+
+ final String fromEmailAddress;
+ final String toEmailAddress;
+ final String subject;
+ final String body;
+
+ System.out.print("\nFrom which email address would you like to send a message?: ");
+ fromEmailAddress = scanner.nextLine();
+
+ System.out.print("To which email address would you like to send a message?: ");
+ toEmailAddress = scanner.nextLine();
+
+ System.out.print("What is the subject line?: ");
+ subject = scanner.nextLine();
+
+ System.out.print("What is the body of the message?: ");
+ body = scanner.nextLine();
+
+ if (!environment.containsProperty("accessKey")) {
+ System.out.print("Please enter your access key: ");
+ final String accessKey = scanner.nextLine();
+ environment.getSystemProperties().put("accessKey", accessKey);
+ }
+
+ if (!environment.containsProperty("secretKey")) {
+ System.out.print("Please enter your secret key: ");
+ final String secretKey = scanner.nextLine();
+ environment.getSystemProperties().put("secretKey", secretKey);
+ }
+
+ context.load("classpath:META-INF/spring/integration/*-context.xml");
+ context.registerShutdownHook();
+ context.refresh();
+
+ final EmailService emailService = context.getBean(EmailService.class);
+
+ emailService.send(fromEmailAddress, toEmailAddress, subject, body);
+
+ System.out.println(String.format("The email to '%s' was sent successfully.", toEmailAddress));
+
+ System.exit(0);
+
+ }
+}
diff --git a/samples/mail-ses-integration/src/main/resources/META-INF/spring/integration/spring-integration-context.xml b/samples/mail-ses-integration/src/main/resources/META-INF/spring/integration/spring-integration-context.xml
new file mode 100644
index 0000000..81623df
--- /dev/null
+++ b/samples/mail-ses-integration/src/main/resources/META-INF/spring/integration/spring-integration-context.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/mail-ses-integration/src/main/resources/log4j.xml b/samples/mail-ses-integration/src/main/resources/log4j.xml
new file mode 100644
index 0000000..364cd81
--- /dev/null
+++ b/samples/mail-ses-integration/src/main/resources/log4j.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/mail-ses/README.md b/samples/mail-ses/README.md
new file mode 100644
index 0000000..35a1138
--- /dev/null
+++ b/samples/mail-ses/README.md
@@ -0,0 +1,5 @@
+AWS SES MailSender sample
+=========================
+
+This sample uses a Spring-provided *JavaMailSender* to send emails. This application demonstrates that by only replacing the *JavaMailSender* XML bean declaration with the *DefaultAmazonSESMailSender*, existing applications can send emails using Amazon SES without changing application code. The *DefaultAmazonSESMailSender* is provided by the *Spring Integration Extensions AWS Module*.
+
diff --git a/samples/mail-ses/pom.xml b/samples/mail-ses/pom.xml
new file mode 100644
index 0000000..a0eae15
--- /dev/null
+++ b/samples/mail-ses/pom.xml
@@ -0,0 +1,84 @@
+
+ 4.0.0
+ org.springframework.integration.samples
+ mail-ses
+ AWS SES Mail Demo
+ 1.0.0.BUILD-SNAPSHOT
+
+
+ 2.2.1
+
+
+
+ UTF-8
+ 2.2.0.RELEASE
+ 1.2.17
+ 4.10
+
+
+
+ org.springframework.integration
+ spring-integration-mail
+ ${spring.integration.version}
+
+
+ org.springframework.integration
+ spring-integration-test
+ ${spring.integration.version}
+
+
+ org.springframework.integration
+ spring-integration-aws
+ 0.5.0.BUILD-SNAPSHOT
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.subethamail
+ subethasmtp-wiser
+ 1.2
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.5.1
+
+ 1.6
+ 1.6
+ -Xlint:all
+ true
+ true
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.2.1
+
+ org.springframework.integration.samples.mailses.Main
+
+
+
+
+
+
+ repo.springsource.org.milestone
+ SpringSource Maven Milestone Repository
+ https://repo.springsource.org/libs-milestone
+
+
+
\ No newline at end of file
diff --git a/samples/mail-ses/src/main/java/org/springframework/integration/samples/mailses/Main.java b/samples/mail-ses/src/main/java/org/springframework/integration/samples/mailses/Main.java
new file mode 100644
index 0000000..2712acf
--- /dev/null
+++ b/samples/mail-ses/src/main/java/org/springframework/integration/samples/mailses/Main.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * 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.springframework.integration.samples.mailses;
+
+import java.util.List;
+import java.util.Scanner;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.log4j.Logger;
+import org.springframework.context.support.GenericXmlApplicationContext;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.mail.MailException;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessagePreparator;
+import org.subethamail.wiser.Wiser;
+import org.subethamail.wiser.WiserMessage;
+
+/**
+ * Starts the Spring Context and will initialize the Spring Integration routes.
+ *
+ * @author Gunnar Hillert
+ * @since 2.2
+ *
+ */
+public final class Main {
+
+ private static final Logger LOGGER = Logger.getLogger(Main.class);
+
+ private static final String HORIZONTAL_LINE = "\n=========================================================";
+
+ private Main() {
+ }
+
+ /**
+ * Load the Spring Integration Application Context
+ *
+ * @param args - command line arguments
+ */
+ public static void main(final String... args) {
+
+ final Scanner scanner = new Scanner(System.in);
+
+ LOGGER.info(HORIZONTAL_LINE + "\n"
+ + "\n Welcome to Spring Integration! "
+ + "\n"
+ + "\n For more information please visit: "
+ + "\n http://www.springsource.org/spring-integration "
+ + "\n" + HORIZONTAL_LINE);
+
+ System.out.println("Please enter a choice and press : ");
+ System.out.println("\t1. Use Embedded SMTP Server (Wiser)");
+ System.out.println("\t2. Use Amazon SES");
+
+ System.out.println("\tq. Quit the application");
+ System.out.print("Enter your choice: ");
+
+ final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
+ final ConfigurableEnvironment environment = context.getEnvironment();
+
+ boolean usingWiser = false;
+
+ String toEmailAddress;
+
+ while (true) {
+ final String input = scanner.nextLine();
+
+ if("1".equals(input.trim())) {
+ environment.setActiveProfiles("default");
+ usingWiser = true;
+
+ System.out.print("\nTo which email address would you like to send a message?: ");
+ toEmailAddress = scanner.nextLine();
+
+ break;
+ } else if("2".equals(input.trim())) {
+ environment.setActiveProfiles("aws");
+
+ if (!environment.containsProperty("accessKey")) {
+ System.out.print("\nPlease enter your access key: ");
+ final String accessKey = scanner.nextLine();
+ environment.getSystemProperties().put("accessKey", accessKey);
+ }
+
+ if (!environment.containsProperty("secretKey")) {
+ System.out.print("\nPlease enter your secret key: ");
+ final String secretKey = scanner.nextLine();
+ environment.getSystemProperties().put("secretKey", secretKey);
+ }
+ System.out.print("\nTo which email address would you like to send a message?: ");
+ toEmailAddress = scanner.nextLine();
+
+ break;
+ } else if("q".equals(input.trim())) {
+ System.out.println("Exiting application...bye.");
+ System.exit(0);
+ } else {
+ System.out.println("Invalid choice\n\n");
+ System.out.print("Enter you choice: ");
+ }
+ }
+
+ context.load("classpath:META-INF/spring/integration/*-context.xml");
+ context.registerShutdownHook();
+ context.refresh();
+
+ final JavaMailSender ms = context.getBean(JavaMailSender.class);
+ final String toEmailAddressToUse = toEmailAddress;
+ final MimeMessagePreparator preparator = new MimeMessagePreparator() {
+
+ public void prepare(MimeMessage mimeMessage) throws Exception {
+
+ mimeMessage.setRecipient(Message.RecipientType.TO,
+ new InternetAddress(toEmailAddressToUse));
+ mimeMessage.setFrom(new InternetAddress(toEmailAddressToUse));
+ mimeMessage.setSubject("Testing Email - Subject");
+ mimeMessage.setText("Hello World");
+ }
+
+ };
+
+ try {
+ ms.send(preparator);
+ } catch (MailException e) {
+ throw new IllegalStateException(e);
+ }
+
+ System.out.println(String.format("The email to '%s' was sent successfully.", toEmailAddress));
+
+ if (usingWiser) {
+ Wiser wiser = context.getBean(Wiser.class);
+ List messages = wiser.getMessages();
+
+ final String from;
+ final String subject;
+ try {
+ from = messages.get(0).getMimeMessage().getFrom()[0].toString();
+ subject = messages.get(0).getMimeMessage().getSubject();
+ } catch (MessagingException e) {
+ throw new IllegalStateException(e);
+ }
+
+ System.out.println(String.format("Wiser received an email from '%s' with subject '%s'", from, subject));
+ }
+
+ System.exit(0);
+
+ }
+}
diff --git a/samples/mail-ses/src/main/resources/META-INF/spring/integration/spring-integration-context.xml b/samples/mail-ses/src/main/resources/META-INF/spring/integration/spring-integration-context.xml
new file mode 100644
index 0000000..5d35a49
--- /dev/null
+++ b/samples/mail-ses/src/main/resources/META-INF/spring/integration/spring-integration-context.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/mail-ses/src/main/resources/log4j.xml b/samples/mail-ses/src/main/resources/log4j.xml
new file mode 100644
index 0000000..364cd81
--- /dev/null
+++ b/samples/mail-ses/src/main/resources/log4j.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-integration-aws/README.md b/spring-integration-aws/README.md
new file mode 100644
index 0000000..9ffaec4
--- /dev/null
+++ b/spring-integration-aws/README.md
@@ -0,0 +1,132 @@
+Spring Integration Extension for Amazon Web Services (AWS)
+==========================================================
+
+# Introduction
+## Amazon Web Services (AWS)
+
+Launched in 2006, [Amazon Web Services][] (AWS) provides key infrastructure services for business through its cloud computing platform. Using cloud computing businesses can adopt a new business model whereby they do not have to plan and invest in procuring their own IT infrastructure. They can use the infrastructure and services provided by the cloud service provider and pay as they use the services. Visit [http://aws.amazon.com/products/] for more details about various products offered by Amazon as a part their cloud computing services.
+
+*Spring Integration Extension for Amazon Web Services* provides Spring Integration adapters for the various services provided by the [AWS SDK for Java][].
+
+## Spring Integration's extensions to AWS
+
+This guide intends to explain briefly the various adapters available for [Amazon Web Services][] such as:
+
+* **Amazon Simple Email Service (SES)**
+* **Amazon Simple Storage Service (S3)** (Development complete, coming soon)
+* **Amazon Simple Queue Service (SQS)** (Development complete, coming soon)
+* **Amazon DynamoDB** (Analysis ongoing)
+* **Amazon SimpleDB** (Not initiated)
+* **Amazon SNS** (Not initiated)
+
+Sample XML Namespace configurations for each adapter as well as sample code snippets are provided wherever necessary. Of the above libraries, *SES* and *SNS* provide outbound adapters only. All other services have inbound and outbound adapters. The *SQS* inbound adapter is capable of receiving notifications sent out from *SNS* where the topic is an *SQS* Queue.
+
+For *DymamoDB* and *SimpleDB*, besides providing *Inbound*- and *Outbound Adapters*, a *MessageStore* implementation is provided, too.
+
+# Executing the test cases.
+
+All test cases for the adapters are present in the *src/test/java* folder. On executing the build, maven's surefire plugin will execute all the tests.
+
+> Please note that all the tests ending with **AWSTests.java* connect to the actual [Amazon Web Services][] and are excluded by default in the maven build. All other tests rely on mocking to test the functionality. You need to execute the **AWSTests.java* manually to test the connectivity to AWS using your credentials.
+
+All these **AWSTests.java* tests look for the file *awscredentials.properties* in the classpath. To be on the safe side, create the following file at *src/test/resources*:
+*spring-integration-aws/src/test/resources/awscredentials.properties*. It is added to the *.gitignore* file by default. This will prevent this file to be checked in accidentally and revealing your credentials.
+
+This file needs to have two properties *accessKey* and *secretKey*, holding the values of your access key and secret key respectively.
+
+> **Note: AWS Services are chargeable and we recommend not to execute the **AWSTests.java* as part of your regular builds. AWS does provide a free tier which is sufficient to perform your tests without being charged (not true for DynamoDB though), however keep a check on your account usage regularly. Get more information about AWS free tier at [http://aws.amazon.com/free/][]**
+
+#Adapters
+
+##Simple Email Service (SES)
+
+###Introduction
+
+Amazon Simple Email Service (SES) is a web service for sending emails from the cloud. It supports two types of mails currently, the simple mail and raw email.
+Use simple mail if your application just needs to send out emails with some html formatting and without embedded images or attachments. Raw emails gives more flixibility to
+send complex emails with embedded images and attachments.
+For more details about Amazon SES and its pricing visit [http://aws.amazon.com/ses/]
+We have an outbound channel adapter for the Amazon SES Service for sending out simple and raw emails with complete namespace support for configuring the adapter.
+To prevent misuse of the service, Amazon has enforced some restrictions, for sandbox you need to verify email ids which would be used in *to, cc, bcc* and *from*. For more details on how to use SES and
+other details refer to the SES documentation at [http://aws.amazon.com/documentation/ses/][].
+
+###Outbound Channel Adapter
+
+Below xml snippet is a simple definition of the outbound channel adapter
+
+
+
+
+
+
+*propertiesFile* attribute contains the AWS access key and secret key. The
+name of the properties are *accessKey* and *secretKey* respectively.
+An alternative to the *propertiesFile* attribute is the *accessKey* and the
+*secretKey* attributes containing the values of access key and the secret key. The definition will look as below.
+
+
+
+
+Both the approaches for providing the credentials are mutually exclusive to each other.
+
+####Sending Mail Messages
+We shall now see a java code snippet to send a mail using the SNS adapter
+
+
+* **Simple Mail Message**
+
+ A Simple Mail Message does not support attachments and embedded contents. It supports basic html content to be sent as the mail body.
+
+ Map headers = new HashMap();
+ headers.put("fromEmailId", "xyz@somemail.com");
+ headers.put("htmlFormat", true);
+ headers.put("subject", "Mail Sent from AWS SES Outbound adapter");
+ headers.put("toEmailId", "abc@anothermail.com");
+
+ Message msg =
+ MessageBuilder.withPayload("A Simple Mail Message sent from " +
+ "Amazon SES Outbound adapter from Spring integration")
+ .copyHeaders(headers)
+ .build();
+ channel.send(msg);
+
+ The above piece off code is pretty simple.
+ * We add four headers to the message for the *to email id*, *from email id*, *subject* and a *flag* to indicate whether the content is an html content or plain text content.
+ * Of these headers the *from email id* and *subject* are mandatory. We can specify one or more of *to*, *cc* or *bcc* email addresses.
+ * The message needs to have a payload of string which is either a plain
+ text or html content. The content will be rendered a html only if the
+ *htmlFormat *header is set appropriately.
+ * The value of the *htmlFormat* header can be Boolean *true*, or *y*,*yes*
+ or *true* as String. For String the value is case insensitive. Any other value will be considered as *false*.
+ * The message is sent over the channel to which is the input channel of
+ the outbound channel adapter.
+ * See *o.s.i.aws.ses.AmazonSESMailHeaders* for all the possible header values supported.
+
+* **Raw Mail Message**
+
+ Use raw mail when you need more flexibility to send mails, like setting mime types and email headers. As long as the content complies with the standard email format standard you can use this means for sending the mail to your recipients. In the below sample we use the spring's *o.s.mail.javamail.MimeMessageHelper* to construct the Mime message.
+
+ Session session = Session.getDefaultInstance(new Properties());
+ MimeMessageHelper helper = new MimeMessageHelper(new MimeMessage(session),true);
+ helper.setTo("abc@somemail.com");
+ helper.setFrom("xyz@anothermail.com");
+ helper.setText("A Sample Embedded image");
+ helper.addAttachment(file.getName(),new File(""));
+ helper.setSubject("Name Pic");
+ Message message =
+ MessageBuilder.withPayload(helper.getMimeMessage()).build();
+ channel.send(message);
+
+ The messages over this channel are consumed by the outbound SES adapter and the mail is sent out using SES.
+
+[AWS SDK for Java]: http://aws.amazon.com/sdkforjava/
+[Amazon Web Services]: http://aws.amazon.com/
+[http://aws.amazon.com/products/]: http://aws.amazon.com/products/
+[http://aws.amazon.com/ses/]: http://aws.amazon.com/ses/
+[http://aws.amazon.com/documentation/ses/]: http://aws.amazon.com/documentation/ses/
+[http://aws.amazon.com/free/]: http://aws.amazon.com/free/
\ No newline at end of file
diff --git a/spring-integration-aws/pom.xml b/spring-integration-aws/pom.xml
new file mode 100644
index 0000000..6e58330
--- /dev/null
+++ b/spring-integration-aws/pom.xml
@@ -0,0 +1,223 @@
+
+
+ 4.0.0
+ org.springframework.integration
+ spring-integration-aws
+ 0.5.0.BUILD-SNAPSHOT
+ Spring Integration Amazon Web Services Support
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ 2.2.1
+
+
+
+ 2.2.0.RELEASE
+ 3.1.3.RELEASE
+ 1.3.12
+ 1.5
+ 1.1.1
+ 2.0.1
+ 1.4.4
+ 1.9.11
+ 4.1.1
+ 1.1
+ 4.11
+ 1.9.0
+ UTF8
+
+
+
+
+
+ src/main/java
+
+ **/*
+
+
+ **/*.java
+
+
+
+ src/main/resources
+
+ **/*
+
+
+
+
+
+ src/test/java
+
+ **/*
+
+
+ **/*.java
+
+
+
+ src/test/resources
+
+ **/*
+
+
+
+
+
+ maven-compiler-plugin
+
+ 1.6
+ 1.6
+
+
+
+ maven-surefire-plugin
+
+
+ **/*Tests.java
+
+
+ **/*Abstract*.java
+ **/*AWSTests.java
+
+
+
+
+
+
+
+ springsource-libs-milestone
+ Spring Framework Maven Milestone Repository
+ https://repo.springsource.org/libs-milestone
+
+
+
+
+ com.amazonaws
+ aws-java-sdk
+ ${aws.sdk.version}
+ compile
+
+
+
+ commons-codec
+ commons-codec
+ ${commons.codec.version}
+ compile
+
+
+
+ commons-logging
+ commons-logging
+ ${commons.logging.version}
+ compile
+
+
+
+ commons-io
+ commons-io
+ ${commons.io.version}
+ compile
+
+
+
+ javax.mail
+ mail
+ ${java.mail.version}
+ compile
+
+
+
+ org.springframework.integration
+ spring-integration-core
+ ${spring.integration.version}
+ compile
+
+
+
+ org.springframework.integration
+ spring-integration-mail
+ ${spring.integration.version}
+ provided
+
+
+
+ org.codehaus.jackson
+ jackson-core-asl
+ ${jackson.version}
+ compile
+
+
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ ${jackson.version}
+ compile
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ ${apache.httpclient.version}
+ compile
+
+
+
+ org.apache.httpcomponents
+ httpcore
+ ${apache.httpclient.version}
+ compile
+
+
+
+ org.springframework.integration
+ spring-integration-test
+ ${spring.integration.version}
+ test
+
+
+
+ org.hamcrest
+ hamcrest-core
+ ${hamcrest.version}
+ test
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+ org.mockito
+ mockito-all
+ ${mockito.version}
+ test
+
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
+
+
+ org.springframework
+ spring-test
+ ${spring.test.version}
+ test
+
+
+
+
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AWSNamespaceHandler.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AWSNamespaceHandler.java
new file mode 100644
index 0000000..5894d8c
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AWSNamespaceHandler.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.config.xml;
+
+import org.springframework.integration.aws.ses.config.xml.AmazonSESOutboundAdapterParser;
+import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler;
+
+/**
+ * The namepsace handler for "int-aws" namespace
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public class AWSNamespaceHandler extends
+ AbstractIntegrationNamespaceHandler {
+
+
+ public void init() {
+ this.registerBeanDefinitionParser("ses-outbound-channel-adapter", new AmazonSESOutboundAdapterParser());
+ }
+
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParser.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParser.java
new file mode 100644
index 0000000..3a1d848
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AbstractAWSOutboundChannelAdapterParser.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * 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.springframework.integration.aws.config.xml;
+
+import static org.springframework.integration.aws.config.xml.AmazonWSParserUtils.getAmazonWSCredentials;
+
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
+import org.springframework.integration.core.MessageHandler;
+import org.w3c.dom.Element;
+
+/**
+ * The common adapter parser for all AWS Outbound channel adapters
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public abstract class AbstractAWSOutboundChannelAdapterParser extends
+ AbstractOutboundChannelAdapterParser {
+
+ /* (non-Javadoc)
+ * @see org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser#parseConsumer(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ @Override
+ protected final AbstractBeanDefinition parseConsumer(Element element,
+ ParserContext parserContext) {
+ String awsCredentialsGeneratedName = getAmazonWSCredentials(element,parserContext);
+
+ BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(getMessageHandlerImplementation());
+ builder.addConstructorArgReference(awsCredentialsGeneratedName);
+ processBeanDefinition(builder,awsCredentialsGeneratedName,element,parserContext);
+ return builder.getBeanDefinition();
+ }
+
+ protected abstract Class extends MessageHandler> getMessageHandlerImplementation();
+
+ /**
+ * The subclasses can override this method to set additional attributes and perform some
+ * additional operations on the {@link BeanDefinitionBuilder}
+ *
+ * @param builder
+ * @param awsCredentialsGeneratedName
+ * @param element
+ * @param context
+ */
+ protected void processBeanDefinition(BeanDefinitionBuilder builder,String awsCredentialsGeneratedName,
+ Element element,ParserContext context) {
+ //Default implementation does nothing
+ }
+
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AmazonWSParserUtils.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AmazonWSParserUtils.java
new file mode 100644
index 0000000..d8f0f34
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/config/xml/AmazonWSParserUtils.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * 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.springframework.integration.aws.config.xml;
+
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.integration.aws.core.BasicAWSCredentials;
+import org.springframework.integration.aws.core.PropertiesAWSCredentials;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Element;
+
+/**
+ * The utility class for the namespace parsers
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public final class AmazonWSParserUtils {
+
+ public static final String ACCESS_KEY = "accessKey";
+ public static final String SECRET_KEY = "secretKey";
+ public static final String PROPERTIES_FILE = "propertiesFile";
+ public static final String CREDENTIALS_REF = "credentials-ref";
+
+ private AmazonWSParserUtils() {
+ throw new AssertionError("Cannot instantiate the utility class");
+ }
+
+
+ /**
+ * Registers the {@link AmazonWSCredentials} bean with the current ApplicationContext if
+ * accessKey and secretKey is given, if the credentials-ref is given, the given value
+ * is returned.
+ *
+ * @param element
+ * @param parserContext
+ * @return
+ */
+ public static String getAmazonWSCredentials(Element element,ParserContext parserContext) {
+ //TODO: Some mechanism to use the same instance with same ACCESS_KEY to be implemented
+ String accessKey = element.getAttribute(ACCESS_KEY);
+ String secretKey = element.getAttribute(SECRET_KEY);
+ String propertiesFile = element.getAttribute(PROPERTIES_FILE);
+ String credentialsRef = element.getAttribute(CREDENTIALS_REF);
+ String awsCredentialsGeneratedName;
+
+ if(StringUtils.hasText(credentialsRef)) {
+ if(StringUtils.hasText(propertiesFile)
+ || StringUtils.hasText(accessKey)
+ || StringUtils.hasText(secretKey)) {
+ parserContext.getReaderContext().error("When " + CREDENTIALS_REF + " is specified, " +
+ "do not specify the " + PROPERTIES_FILE + " attribute or the "
+ + SECRET_KEY + " and " + ACCESS_KEY + " attributes", element);
+ }
+ awsCredentialsGeneratedName = credentialsRef;
+ }
+ else {
+ if(StringUtils.hasText(propertiesFile)) {
+ if(StringUtils.hasText(accessKey) && StringUtils.hasText(secretKey)) {
+ parserContext.getReaderContext().error("When " + ACCESS_KEY + " and " + SECRET_KEY +
+ " are specified, do not specify the " + PROPERTIES_FILE + " attribute", element);
+ }
+
+ BeanDefinitionBuilder builder =
+ BeanDefinitionBuilder.genericBeanDefinition(PropertiesAWSCredentials.class);
+ builder.addConstructorArgValue(propertiesFile);
+ awsCredentialsGeneratedName = BeanDefinitionReaderUtils.registerWithGeneratedName(
+ builder.getBeanDefinition(), parserContext.getRegistry());
+ } else {
+ BeanDefinitionBuilder builder
+ = BeanDefinitionBuilder.genericBeanDefinition(BasicAWSCredentials.class);
+ builder.addConstructorArgValue(accessKey);
+ builder.addConstructorArgValue(secretKey);
+ awsCredentialsGeneratedName = BeanDefinitionReaderUtils.registerWithGeneratedName(
+ builder.getBeanDefinition(), parserContext.getRegistry());
+
+ }
+ }
+
+ return awsCredentialsGeneratedName;
+ }
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSClientFactory.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSClientFactory.java
new file mode 100644
index 0000000..c76216f
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSClientFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.core;
+
+import com.amazonaws.AmazonWebServiceClient;
+
+/**
+ * The factory interface that would be used to get the implementation of the appropriate
+ * instance of {@link AmazonWebServiceClient}
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public interface AWSClientFactory {
+
+ /**
+ * Returns the instance of the {@link AmazonWebServiceClient} with the apropriate endpoint value
+ * set based on the provided url value
+ *
+ * @param url The url of the service
+ * @return The appropriate {@link AmazonWebServiceClient} for the provided endpoint URL
+ */
+ T getClient(String url);
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSCredentials.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSCredentials.java
new file mode 100644
index 0000000..3ae05ef
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSCredentials.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.core;
+
+/**
+ * The common interfaces for all implementations of Amazon WS Credentials
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public interface AWSCredentials {
+
+ /**
+ * Get the Access key to the Amazon WS account
+ * @return
+ */
+ public String getAccessKey();
+
+ /**
+ * Get the Secret key to the Amazon WS account
+ * @return
+ */
+ public String getSecretKey();
+
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSOperationException.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSOperationException.java
new file mode 100644
index 0000000..70c2df8
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AWSOperationException.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.core;
+
+/**
+ * The Base class for all other AWS operation exceptions
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public class AWSOperationException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3391888045993691634L;
+
+ private final String accessKey;
+
+ public AWSOperationException(String accessKey) {
+ super();
+ this.accessKey = accessKey;
+ }
+
+ public AWSOperationException(String accessKey,String message) {
+ super(message);
+ this.accessKey = accessKey;
+ }
+
+ public AWSOperationException(String accessKey,String message, Throwable cause) {
+ super(message, cause);
+ this.accessKey = accessKey;
+ }
+
+ public AWSOperationException(String accessKey,Throwable cause) {
+ super(cause);
+ this.accessKey = accessKey;
+ }
+
+ /**
+ * Get the access key for the user who encountered the exception
+ * @return
+ */
+ public String getAccessKey() {
+ return accessKey;
+ }
+
+
+
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AbstractAWSClientFactory.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AbstractAWSClientFactory.java
new file mode 100644
index 0000000..6cc42ee
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/AbstractAWSClientFactory.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.core;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+
+import com.amazonaws.AmazonWebServiceClient;
+
+
+/**
+ * The abstract factory class that will be used by all the client operations to acquire
+ * the appropriate implementation of the {@link AmazonWebServiceClient} based on the URL
+ * passed to the getClient method
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public abstract class AbstractAWSClientFactory implements AWSClientFactory {
+
+ /**
+ * A map storing the {@link AmazonWebServiceClient} endpoint as the key and the SQS Client as the
+ * value. Since setting the endpoint is not a thread safe operation once the client is instantiated,
+ * we maintain a map of endpoint and the {@link AmazonWebServiceClient} instantiated the first time a request
+ * for the designated endpoint is received
+ */
+ private final ConcurrentHashMap clientMap = new ConcurrentHashMap();
+
+ /**
+ * The String constant for HTTP
+ */
+ protected final static String HTTP = "http://";
+
+ /**
+ * The String constant for HTTPS
+ */
+ protected final static String HTTPS = "https://";
+
+ /**
+ * The String constant for SMTP
+ */
+ protected final String SMTP = "smtp://";
+
+ /**
+ * The default protocol to be used in case none is provided
+ */
+ protected final static String DEFAULT_PROTOCOL = HTTPS;
+
+
+ /**
+ * Returns the cached implementation of the {@link AmazonWebServiceClient} based on the URL provided.
+ * the client instance is acquired using the abstract getClientImplementation method.
+ * The instance is added to the client map with the endpoint string as the key and the
+ * {@link AmazonWebServiceClient} as the value.
+ *
+ * @param url the URL for which the client is requested.
+ * @return the implementation of the {@link AmazonWebServiceClient} to be used for the provided url
+ */
+ public final T getClient(String url) {
+ String endpoint = getEndpointFromURL(url);
+ if(!clientMap.containsKey(endpoint)) {
+ T client = getClientImplementation();
+ client.setEndpoint(endpoint);
+ T existingClient = clientMap.putIfAbsent(endpoint, client);
+ if(existingClient != null) {
+ //in rare scenarios where a new implementation was created after
+ //checking for the existence of the endpoint in the client map
+ client = existingClient;
+ }
+ return client;
+ } else
+ return clientMap.get(endpoint);
+ }
+
+ /**
+ * Return a copy of the client map
+ * @return the copy of the clientMap
+ */
+ public final Map getClientMap() {
+ return new HashMap(clientMap);
+ }
+
+ /**
+ * Clears the complete cache
+ */
+ public final void clear() {
+ clientMap.clear();
+ }
+
+ /**
+ * Extracts the endpoint from the URL provided
+ *
+ * @param url
+ * @return
+ */
+ private String getEndpointFromURL(String stringUrl) {
+ Assert.notNull(stringUrl,"Provided String URL is null");
+ String endpoint;
+ try {
+ if(!(stringUrl.startsWith(HTTP)
+ || stringUrl.startsWith(HTTPS)
+ || stringUrl.startsWith(SMTP))) {
+ stringUrl = DEFAULT_PROTOCOL + stringUrl;
+ }
+ URL url = new URL(stringUrl);
+ String host = url.getHost();
+ String protocol = url.getProtocol();
+ if(StringUtils.hasText(protocol)) {
+ endpoint = protocol + "://" + host;
+ }
+ else {
+ endpoint = host;
+ }
+ } catch (MalformedURLException e) {
+ throw new AWSOperationException(null, "The URL \"" + stringUrl + "\" is malformed",e);
+ }
+ return endpoint;
+ }
+
+ /**
+ * The subclass needs to implement this method and return an appropriate implementation
+ * @return
+ */
+ protected abstract T getClientImplementation();
+
+
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/BasicAWSCredentials.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/BasicAWSCredentials.java
new file mode 100644
index 0000000..30fe0cb
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/BasicAWSCredentials.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.core;
+
+import org.springframework.util.Assert;
+
+/**
+ * The basic implementation class holding the Access key and the secret
+ * key for the AWS account .
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public class BasicAWSCredentials implements AWSCredentials {
+
+ /**.
+ * Hold the Access key for the AWS account
+ */
+ private String accessKey;
+
+ /**.
+ * Hold the Secret key for the
+ */
+ private String secretKey;
+
+
+ /**.
+ * Default constructor
+ */
+ public BasicAWSCredentials() {
+
+ }
+
+ /**.
+ * The constructor accepting the access and secret key.
+ *
+ * @param accessKey Must not be null or empty
+ * @param secretKey Must not be null or empty
+ */
+ public BasicAWSCredentials(String accessKey, String secretKey) {
+ Assert.hasText(accessKey, "The accessKey parameter must not be null or empty.");
+ Assert.hasText(secretKey, "The secretKey parameter must not be null or empty.");
+
+ this.accessKey = accessKey;
+ this.secretKey = secretKey;
+ }
+
+ /**
+ * Get the Access key to the Amazon WS account
+ * @return
+ */
+ public String getAccessKey() {
+ return accessKey;
+ }
+
+ /**
+ * Set the Access key to the Amazon WS account
+ * @param accessKey
+ */
+ public void setAccessKey(String accessKey) {
+ Assert.hasText(accessKey, "The accessKey parameter must not be null or empty.");
+ this.accessKey = accessKey;
+ }
+
+ /**
+ * Get the Secret key to the Amazon WS account
+ * @return
+ */
+ public String getSecretKey() {
+ return secretKey;
+ }
+
+ /**.
+ * Set the Secret key to the Amazon WS account
+ * @param secretKey
+ */
+ public void setSecretKey(String secretKey) {
+ Assert.hasText(secretKey, "The secretKey parameter must not be null or empty.");
+ this.secretKey = secretKey;
+ }
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/InvalidAWSCredentialsException.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/InvalidAWSCredentialsException.java
new file mode 100644
index 0000000..5abde9f
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/InvalidAWSCredentialsException.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.core;
+
+/**
+ * Thrown when AWS Credentials provided by the user are incomplete or invalid
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public class InvalidAWSCredentialsException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public InvalidAWSCredentialsException() {
+ super();
+ }
+
+ public InvalidAWSCredentialsException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidAWSCredentialsException(String message) {
+ super(message);
+ }
+
+ public InvalidAWSCredentialsException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/PropertiesAWSCredentials.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/PropertiesAWSCredentials.java
new file mode 100644
index 0000000..567efa2
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/core/PropertiesAWSCredentials.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.core;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.util.Assert;
+import org.springframework.util.ClassUtils;
+import org.springframework.util.ResourceUtils;
+import org.springframework.util.StringUtils;
+
+/**
+ * Load the AWS credentials from the .properties file
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public class PropertiesAWSCredentials extends BasicAWSCredentials implements InitializingBean {
+
+
+ public static final String DEFAULT_AWS_ACCESS_KEY_PROPERTY = "accessKey";
+ public static final String DEFAULT_AWS_SECRET_KEY_PROPERTY = "secretKey";
+
+ private String accessKeyProperty = DEFAULT_AWS_ACCESS_KEY_PROPERTY;
+ private String secretKeyProperty = DEFAULT_AWS_SECRET_KEY_PROPERTY;
+ private String propertyFileName;
+
+ /**.
+ * Constructor accepting the properties file.
+ *
+ * @param propertyFileName Must not be null or empty
+ */
+ public PropertiesAWSCredentials(String propertyFileName) {
+ super();
+ Assert.hasText(propertyFileName, "The propertyFileName parameter must not be null or empty.");
+ this.propertyFileName = propertyFileName;
+ }
+
+ /**.
+ * Gets the property name which holds the
+ * @return
+ */
+ public String getAccessKeyProperty() {
+ return accessKeyProperty;
+ }
+
+ /**.
+ * Sets the name of the property that will be used as the key in the properties
+ * file to hold the AWS access key
+ * @param accessKeyProperty
+ */
+ public void setAccessKeyProperty(String accessKeyProperty) {
+ this.accessKeyProperty = accessKeyProperty;
+ }
+
+ /**.
+ * Gets the property name which holds the
+ * @return
+ */
+ public String getSecretKeyProperty() {
+ return secretKeyProperty;
+ }
+
+ /**.
+ * Sets the name of the property that will be used as the key in the properties
+ * file to hold the AWS secret key
+ * @param accessKeyProperty
+ */
+ public void setSecretKeyProperty(String secretKeyProperty) {
+ this.secretKeyProperty = secretKeyProperty;
+ }
+
+ /**.
+ * Get the name of the property file that will hold the AWS credentials
+ * @return
+ */
+ public String getPropertyFileName() {
+ return propertyFileName;
+ }
+
+ /**.
+ * Sets the name of the file that will hold the AW credentials.
+ *
+ * @param propertyFileName Must not be null or empty
+ */
+ public void setPropertyFileName(String propertyFileName) {
+ Assert.hasText(propertyFileName, "The propertyFileName parameter must not be null or empty.");
+ this.propertyFileName = propertyFileName;
+ }
+
+ /**.
+ * Load the properties file and the keys
+ */
+ public void afterPropertiesSet() throws Exception {
+ if (!StringUtils.hasText(propertyFileName))
+ throw new InvalidAWSCredentialsException("Mandatory property propertyFileName expected");
+
+ if(!StringUtils.hasText(accessKeyProperty))
+ throw new InvalidAWSCredentialsException("accessKeyValue has to be non empty and non null");
+
+ if(!StringUtils.hasText(secretKeyProperty))
+ throw new InvalidAWSCredentialsException("secretKeyValue has to be non empty and non null");
+
+ loadProperties();
+
+ }
+
+ /**.
+ * The private method that loads the properties from the .properties file and sets the access keys
+ */
+ private void loadProperties() {
+ Resource resource;
+ if(propertyFileName.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
+ resource = new ClassPathResource(propertyFileName.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length()), ClassUtils.getDefaultClassLoader());
+ } else {
+ resource = new ClassPathResource(propertyFileName, ClassUtils.getDefaultClassLoader());
+ }
+ if(!resource.exists())
+ throw new InvalidAWSCredentialsException("Unable to find resource \"" + propertyFileName + "\" in classpath");
+
+ Properties props = new Properties();
+ try {
+ props.load(resource.getInputStream());
+ } catch (IOException e) {
+ throw new InvalidAWSCredentialsException("Unable to load properties from \"" + propertyFileName + "\" in classpath");
+ }
+
+ setAccessKey((String)props.get(accessKeyProperty));
+ setSecretKey((String)props.get(secretKeyProperty));
+
+
+ }
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/AmazonSESMessageHandler.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/AmazonSESMessageHandler.java
new file mode 100644
index 0000000..9465d31
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/AmazonSESMessageHandler.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.ses;
+
+import org.springframework.integration.aws.core.AWSCredentials;
+import org.springframework.integration.aws.ses.core.DefaultAmazonSESMailSender;
+import org.springframework.integration.mail.MailSendingMessageHandler;
+import org.springframework.mail.javamail.JavaMailSender;
+
+/**
+ * The Message handler for the SES Mail. This will be used to send email
+ * using Amazon SES
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public class AmazonSESMessageHandler extends MailSendingMessageHandler {
+
+ /**
+ * The Default constructor that extends from the {@link MailSendingMessageHandler} and passes
+ * it an instance of {@link DefaultAmazonSESMailSender}
+ * @param credentials
+ */
+ public AmazonSESMessageHandler(AWSCredentials credentials) {
+ super(new DefaultAmazonSESMailSender(credentials));
+ }
+
+ /**
+ * The constructor that accepts the {@link JavaMailSender} instance, used for
+ * unit tests only
+ * @param mailSender
+ */
+ AmazonSESMessageHandler(JavaMailSender mailSender) {
+ super(mailSender);
+ }
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParser.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParser.java
new file mode 100644
index 0000000..fdb3a68
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/config/xml/AmazonSESOutboundAdapterParser.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.ses.config.xml;
+
+
+import org.springframework.integration.aws.config.xml.AbstractAWSOutboundChannelAdapterParser;
+import org.springframework.integration.aws.ses.AmazonSESMessageHandler;
+import org.springframework.integration.core.MessageHandler;
+
+/**
+ * parse the <ses-outbound-channel-adapter/> of the "int-aws" namespace
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public class AmazonSESOutboundAdapterParser extends
+ AbstractAWSOutboundChannelAdapterParser {
+
+
+ @Override
+ public Class extends MessageHandler> getMessageHandlerImplementation() {
+ return AmazonSESMessageHandler.class;
+ }
+}
diff --git a/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/AmazonSESMailSendException.java b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/AmazonSESMailSendException.java
new file mode 100644
index 0000000..03bb6da
--- /dev/null
+++ b/spring-integration-aws/src/main/java/org/springframework/integration/aws/ses/core/AmazonSESMailSendException.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * 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.springframework.integration.aws.ses.core;
+
+import java.util.Map;
+
+import org.springframework.integration.aws.core.AWSOperationException;
+
+/**
+ * This exception will be thrown upon failure in sending a mail from Amazon SES
+ *
+ * @author Amol Nayak
+ *
+ * @since 0.5
+ *
+ */
+public class AmazonSESMailSendException extends AWSOperationException {
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3035267174544370619L;
+
+ private final Map