Getting started with Atom Hopper – a Java ATOMPub server based on Apache Abdera
I’ve been blogging lately about Apache Abdera and ATOM. ATOM can be used for a lot of things and is very flexible. Today I want to introduce you to a new ATOMPub server called: Atom Hopper. Atom Hopper is open sourced under the Apache 2.0 license.
Atom Hopper is an open source ATOMPub server built with Java and uses technologies like Apache Abdera and Hibernate. You can get the Atom Hopper source code from GitHub. Atom Hopper is actively developed at this time.
Atom Hopper can be run in several ways:
1. Just grab the source code and run it
2. Run it in embedded mode (Atom Hopper is dropped into embedded Jetty with some defaults and is good for testing and evaluating purposes)
3. Grab the WAR file and place it into Apache Tomcat, Eclipse Jetty, etc.
4. Generate the RPM file and install that (You need CentOS or Fedora to generate the RPM).
5. Generate the Debian package file and install that with dpkg.
See the readme file for more information.
As a developer to get started with Atom Hopper is very easy using Netbeans 7. Simply go to the GitHub repo and clone the source code for Atom Hopper to your computer. Once you have done that use Netbeans 7 to open the atom-hopper project that now exists on your computer.
Note: I’m running Atom Hopper on an Apple MacBook Pro with OS X 10.7.
When the project is loaded do a Clean and Build by right-clicking on the ATOM Hopper – ATOMpub Server Collection
Once all the dependencies are downloaded and everything is built you can test out Atom Hopper easily by right-clicking on the ATOM Hopper – Default Jetty Server project and selecting Properties.
Pass in the start argument using the following settings and then close the dialog.
Run the project (this runs the embedded version of Atom Hopper which is good for testing an evaluation purposes) and requires no additional work to get up and running as it uses an H2 database if nothing else is specified. If all goes well you should see this in the Netbeans output window:
By default this will start Atom Hopper on your local computer with a port address of 8080. It will use namespace (as the workspace) and feed as the feed name (these can be changed as needed and you can use multiple namespaces and feeds).
I am going to use the Poster add-on for Firefox to communicate with Atom Hopper.
Using the following address I should get back an empty feed (since there are currently no ATOM entries in Atom Hopper):
Place the address into the URL textbox for Poster and press the GET button and you should see the empty feed come back (you might see an initial pause before you get any feedback, this is because if the default database doesn’t exist Atom Hopper via Hibernate will go out and create one).
Let’s add an ATOM entry to Atom Hopper now using Poster.
Using the same address as above all you need to do is set the Content Type textbox in Poster to have this value: application/atom+xml
In the large textarea drop in some valid ATOM XML like this:
<entry xmlns="http://www.w3.org/2005/Atom"> <title type="text">This is the title</title> <updated>2011-10-06T21:39:49.904Z</updated> <author> <name>Chad</name> </author> <content type="text">Hello World</content> <category term="MyCategory1" /> <category term="MyCategory2" /> </entry>
Press the POST button and voila your ATOM XML will be entered into Atom Hopper. You should get back an HTTP 201 (created) from Poster.
Using Poster now press the GET button and you will get the feed back with your new ATOM XML entry. Try loading the Atom Hopper address above in browsers like Firefox or Safari.
A few things to point out from the feed coming back:
1. Atom Hopper supports weak eTags (can be used for caching, ie: checking if the feed has changed).
2. A unique ID is added
3. Categories are supported and can be searched upon
To stop the embedded version of Atom Hopper simply right-click on the ATOM Hopper – Default Jetty Server project and select Properties. Where you had put start, replace it with stop and run the project again. This will send a message to Atom Hopper to stop.
Atom Hopper supports several database backends such as H2, MySQL and Postgresql. You can also perform simple category searches, get the feed back in XML or JSON, as well as perform paging of the feed forwards or backwards.
Ultimately Atom Hopper can be used for many things: passing data between departments, games (keeping track of moves people have made?), gathering data into one spot, etc. It can also easily tie into PubSubHubBub.
I’ll be adding some future blog posts talking more about Atom Hopper and it’s features. If you find this project useful please add a comment or send me an email and let me know how your using Atom Hopper. Also, if you think you have something cool to contribute back to the project then please fork it and submit a pull request back. Please keep in mind this is a pre-1.0 release (as of this blog article) and bugs are still out there.