Setting up the AWS Flow Framework for Java
The AWS Flow Framework for Java is included with the AWS SDK for Java. If you have not already set up the AWS SDK for Java, visit Getting Started in the AWS SDK for Java Developer Guide for information about installing and configuring the SDK itself.
This topic provides information about additional steps required to use the AWS Flow Framework for Java. Steps are provided for Eclipse and Maven.
Installing for Maven
Amazon provides Amazon SWF build tools in the Maven Central Repository to aid setup of AWS Flow Framework for Java in your Maven projects.
To set up the flow framework for Maven, add the following dependency to your project's
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-swf-build-tools</artifactId> <version>1.0</version> </dependency>
The Amazon SWF build tools are open source—to view or download the code or to build the tools yourself, visit the repository at https://github.com/aws/aws-swf-build-tools.
Installing for Eclipse
If you use the Eclipse IDE, install the AWS Flow Framework for Java using the AWS Toolkit for Eclipse.
Installing the AWS Toolkit for Eclipse
Installing the Toolkit for Eclipse is the simplest way to get started with the AWS Flow Framework for Java. To install the Toolkit for Eclipse, see Setting Up the AWS Toolkit for Eclipse in the AWS Toolkit for Eclipse Getting Started Guide.
Be sure to include both the AWS SDK for Java and AWS Simple Workflow Tools when selecting which packages to install in Eclipse's Available Software dialog box:
If you installed all of the available packages (by clicking the AWS Toolkit for Eclipse top-level node, or clicking Select All), both of these packages were automatically selected and installed for you.
Creating an AWS Flow Framework for Java Project
Creating a properly configured AWS Flow Framework for Java project in Eclipse involves a number of steps:
Create an AWS Java project.
Enable annotation processing for your project.
Enable and configure AspectJ.
Each of these steps will now be described in detail.
To create an AWS Java project
To select the Java perspective, click Window > Open Perspective > Java.
Click File > New > AWS Java Project.
Use the AWS Java project wizard to create a new project.
The first time you create an AWS Java project with Eclipse, the SDK for Java will be automatically downloaded and installed when the project wizard starts.
After creating your AWS Java project, enable annotation processing for the project. The AWS Flow Framework for Java includes an annotation processor that generates several key classes based on annotated source code.
To enable annotation processing
In Project Explorer, right-click your project and select Properties.
In the Properties dialog box, navigate to Java Compiler > Annotation Processing.
Check Enable project specific settings (which should also Enable annotation processing, but if it doesn't make sure that this option is also checked). Then click OK.
You will need to rebuild your project after enabling annotation processing.
Enabling and Configuring AspectJ
Next, you should enable and configure AspectJ.
Certain AWS Flow Framework for Java annotations such as
@Asynchronous require AspectJ. You don't need to use
AspectJ directly, but you must enable it with either load-time weaving or
The recommended approach is to use load-time weaving.
Before configuring AspectJ, you need the AspectJ version that matches your Java version:
If you are using Java 7 (recommended), download the latest AspectJ 1.7.X release.
If you are using Java 6, download the latest AspectJ 1.6.X release.
You can download either of these versions of AspectJ from: http://www.eclipse.org/aspectj/downloads.php.
After you have finished downloading AspectJ, execute the downloaded
.jar file to
install AspectJ. The AspectJ installation will ask you where you would like to install the binaries, and on
the final screen, will provide recommended steps for completing the installation. Remember the
location of the aspectjweaver.jar file; you'll need it to configure AspectJ in Eclipse.
Configuring AspectJ Load-Time Weaving
To configure AspectJ load-time weaving for your AWS Flow Framework for Java project, first designate the AspectJ
JAR file as a Java agent, and then configure it by adding an
aop.xml file to your
To add AspectJ as a Java agent
To open the Preferences dialog box, click Window > Preferences.
Navigate to Java > Installed JREs.
Select the appropriate JRE and click Edit.
In the Default VM arguments box, enter the path to the installed AspectJ binary. This will be a path such as
/home/user/aspectj1.7/lib/aspectjweaver.jar, depending on your operating system and on the version of AspectJ you downloaded.
On Linux, OS X, or Unix use:
On Windows, use a standard Windows-style path instead:
To configure AspectJ for AWS Flow Framework for Java, add an
aop.xml file to the project.
To add an aop.xml file
In your project's src directory, add a directory named
Add a file named
META-INFwith the following contents.
<aspectj> <aspects> <!-- declare two existing aspects to the weaver --> <aspect name="com.amazonaws.services.simpleworkflow.flow.aspectj.AsynchronousAspect"/> <aspect name="com.amazonaws.services.simpleworkflow.flow.aspectj.ExponentialRetryAspect"/> </aspects> <weaver options="-verbose"> <include within="MySimpleWorkflow.*" </weaver> </aspectj>
The value of
<include within=""/>depends on how you name your project's packages. The above example assumes that the project's packages followed the pattern MySimpleWorkflow.*. Use a value appropriate for your own project's packages.
AspectJ Compile-Time Weaving
To enable and configure AspectJ compile-time weaving, you must first install the AspectJ developer tools for Eclipse, which are available from http://www.eclipse.org/aspectj/downloads.php.
To install the AspectJ Developer Tools in Eclipse
On the Help menu, click Install New Software.
In the Available Software dialog box, enter http://download.eclipse.org/tools/ajdt/
version/update, where version represents your Eclipse version number. For example, if you are using Eclipse 4.3 (Kepler), you would enter: http://download.eclipse.org/tools/ajdt/43/update.
Be sure that the AspectJ version matches your Eclipse version, or installation of AspectJ will fail.
Click Add to add the location. Once the location is added, the AspectJ developer tools will be listed.
Click Select All to select all of the AspectJ developer tools, then click Next to install them.
You will need to restart Eclipse to complete the installation.
You must then configure your project.
To configure your project for AspectJ compile-time weaving
In Project Explorer, right-click your project and select Configure > Convert to AspectJ Project.
The AspectJ Runtime Library will be added to your project.
Right-click your project again and click Properties.
Click AspectJ Build and then click the Aspect Path tab.
Click Add External JARs and add the AWS SDK for Java JAR file to your project's Aspect Path.
The AWS Toolkit for Eclipse installs the AWS SDK for Java JAR file in your workspace, in the
.metadata/.plugins/com.amazonaws.eclipse.core/aws-java-sdk/AWS Version/libdirectory, where you replace AWS Version with the installed AWS SDK version number. Otherwise, you can use the JAR file that is included with the regular AWS SDK installation, which is in the
Working around issues with AspectJ and Eclipse
The AspectJ Eclipse plug-in has an issue that can prevent generated code from being compiled. To work around this issue, first remove AspectJ and then re-convert your project:
Right-click your project, click AspectJ Tools > Remove AspectJ Capability, and then click Yes to confirm.
Right-click your project, click Configure > Convert to AspectJ Project.